回答編集履歴
3
修正
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
sympy.utilities.lambdify.lambdify() で式を関数化して、`xs = np.linspace(0, 10, 100)` の各点の d
|
1
|
+
sympy.utilities.lambdify.lambdify() で式を関数化して、`xs = np.linspace(0, 10, 100)` の各点の dx の数値解 ys を計算し、plot(xs, ys) で描画すればよいです。
|
2
2
|
|
3
3
|
|
4
4
|
|
2
修正
test
CHANGED
@@ -14,25 +14,25 @@
|
|
14
14
|
|
15
15
|
from matplotlib import pyplot as plt
|
16
16
|
|
17
|
-
from sympy.utilities.lambdify import lambdify
|
18
|
-
|
19
17
|
|
20
18
|
|
21
19
|
x = sp.symbols("x")
|
22
20
|
|
23
|
-
|
21
|
+
f = x ** 2 + sp.sin(x) + sp.cos(x) ** 2
|
24
22
|
|
25
|
-
d
|
23
|
+
dx = sp.diff(f, x)
|
26
24
|
|
27
25
|
|
28
26
|
|
29
27
|
|
30
28
|
|
29
|
+
from sympy.utilities.lambdify import lambdify
|
30
|
+
|
31
31
|
|
32
32
|
|
33
33
|
xs = np.linspace(0, 10, 100)
|
34
34
|
|
35
|
-
ys = sp.lambdify(x, d
|
35
|
+
ys = sp.lambdify(x, dx, "numpy")(xs)
|
36
36
|
|
37
37
|
|
38
38
|
|
1
修正
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
[
|
5
|
+
[Creating a function from a symbolic expression](https://www.sympy.org/scipy-2017-codegen-tutorial/notebooks/22-lambdify.html)
|
6
6
|
|
7
7
|
|
8
8
|
|