0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【備忘録】sympyによるグラフの図示

Last updated at Posted at 2021-05-14

最近Pythonのモジュールであるnumpyやscipy, sympy, matplotlibを勉強中。
個人的備忘録として簡易的な関数の微分とグラフ図示を記事として纏める。

今回はガウス積分でよく出てくる
$$y = e ^ {-x^2} $$
これをサンプルとして使う。

python
import sympy as sp
import matplotlib.pyplot as plt

x = sp.symbols('x')
fx = sp.E ** -x ** 2
# f(x)の一階微分
fx_1 = sp.diff(fx, x)

p = sp.plot(fx, fx_1, (x, -3.5, 3), legend=True, show=False)
p[0].label = "$f(x) = e^{-x^2}$"
p[1].label = "$f(x) = -2xe^{-x^2}$"
p[1].line_color = "red"

plt.rcParams['figure.figsize'] = (9, 2.7)
p.show()

a.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?