我想画一个函数的泰勒展开式,例如:sin
from sympy import *
from sympy.plotting import *
m, x = symbols("m x")
plot(*Array([2, 4, 6]).applyfunc(lambda m: sin(x).series(x0=0, n=m)), (x, -pi/2, pi/2))
Run Code Online (Sandbox Code Playgroud)
但是,既然Array([2, 4, 6]).applyfunc(lambda m: sin(x).series(x0=0, n=m)给出了
sympy 无法绘制它们。
所以我想知道有没有办法删除O(x^n)?在 Mathematica 中,我可以用来Normal做到这一点。
有一种方法可以删除 O:
\n\nIn [5]: s = sin(x).series(x) \n\nIn [6]: s \nOut[6]: \n 3 5 \n x x \xe2\x8e\x9b 6\xe2\x8e\x9e\nx - \xe2\x94\x80\xe2\x94\x80 + \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80 + O\xe2\x8e\x9dx \xe2\x8e\xa0\n 6 120 \n\nIn [7]: s.removeO() \nOut[7]: \n 5 3 \n x x \n\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80 - \xe2\x94\x80\xe2\x94\x80 + x\n120 6 \n\nIn [8]: s.getO() \nOut[8]: \n \xe2\x8e\x9b 6\xe2\x8e\x9e\nO\xe2\x8e\x9dx \xe2\x8e\xa0\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1425 次 |
| 最近记录: |