python解决高等数学问题,妈妈再也不用担心我的学习
使用Python解决高等数学中极限、导数、偏导数、定积分、不定积分、双重积分等问题
Sympy是一个Python的科学计算库,它旨在成为功能齐全的计算机代数系统。 SymPy 包括从基本符号算术到微积分,代数,离散数学和量子物理学的功能。 它可以在 LaTeX 中显示结果。
Sympy官网
文章目录
立即学习“Python免费学习笔记(深入)”;
Python解决高等数学问题,妈妈再也不用担心我的学习1. 实用技巧1.1 符号函数1.2 展开表达式expand1.3 泰勒展开公式series1.4 符号展开2. 求极限limit3. 求导diff3.1 一元函数3.2 多元函数4. 积分integrate4.1 定积分4.2 不定积分4.3 双重积分5. 求解方程组solve6. 计算求和式summation
(免费学习推荐:python视频教程)
看到这图,是不是感觉快喘不过气了呢。Python来帮你解决。
- from sympy import *import sympy
登录后复制
输入“x= symbols(“x”)”命令定义一个符号
- x = Symbol("x")y = Symbol("y")
登录后复制
1. 实用技巧
1.1 符号函数
sympy提供了很多数学符号,总结如下
虚数单位
- sympy.I
登录后复制自然对数
- sympy.E
登录后复制无穷大
- sympy.oo
登录后复制圆周率
- sympy.pi
登录后复制求n次方根
- sympy.root(8,3)
登录后复制取对数
- sympy.log(1024,2)
登录后复制求阶乘
- sympy.factorial(4)
登录后复制三角函数
- sympy.sin(sympy.pi)sympy.tan(sympy.pi/4)sympy.cos(sympy.pi/2)
登录后复制
1.2 展开表达式expand
- f = (1+x)**3expand(f)
登录后复制
x 3 + 3 x 2 + 3 x + 1 displaystyle x^{3} + 3 x^{2} + 3 x + 1 x3+3×2+3x+1
1.3 泰勒展开公式series
- ln(1+x).series(x,0,4)
登录后复制
x − x 2 2 + x 3 3 + O ( x 4 ) displaystyle x – rac{x^{2}}{2} + rac{x^{3}}{3} + Oleft(x^{4}ight) x−2×2+3×3+O(x4)
- sin(x).series(x,0,8)
登录后复制
x − x 3 6 + x 5 120 − x 7 5040 + O ( x 8 ) displaystyle x – rac{x^{3}}{6} + rac{x^{5}}{120} – rac{x^{7}}{5040} + Oleft(x^{8}ight) x−6×3+120×5−5040×7+O(x8)
- cos(x).series(x,0,9)
登录后复制
1 − x 2 2 + x 4 24 − x 6 720 + x 8 40320 + O ( x 9 ) displaystyle 1 – rac{x^{2}}{2} + rac{x^{4}}{24} – rac{x^{6}}{720} + rac{x^{8}}{40320} + Oleft(x^{9}ight) 1−2×2+24×4−720×6+40320×8+O(x9)
- (1/(1+x)).series(x,0,5)
登录后复制
1 − x + x 2 − x 3 + x 4 + O ( x 5 ) displaystyle 1 – x + x^{2} – x^{3} + x^{4} + Oleft(x^{5}ight) 1−x+x2−x3+x4+O(x5)
- tan(x).series(x,0,4)
登录后复制
x + x 3 3 + O ( x 4 ) displaystyle x + rac{x^{3}}{3} + Oleft(x^{4}ight) x+3×3+O(x4)
- (1/(1-x)).series(x,0,4)
登录后复制
1 + x + x 2 + x 3 + O ( x 4 ) displaystyle 1 + x + x^{2} + x^{3} + Oleft(x^{4}ight) 1+x+x2+x3+O(x4)
- (1/(1+x)).series(x,0,4)
登录后复制
1 − x + x 2 − x 3 + O ( x 4 ) displaystyle 1 – x + x^{2} – x^{3} + Oleft(x^{4}ight) 1−x+x2−x3+O(x4)
1.4 符号展开
- a = Symbol("a")b = Symbol("b")#simplify( )普通的化简simplify((x**3 + x**2 - x - 1)/(x**2 + 2*x + 1))#trigsimp( )三角化简trigsimp(sin(x)/cos(x))#powsimp( )指数化简powsimp(x**a*x**b)
登录后复制
x a + b displaystyle x^{a + b} xa+b
2. 求极限limit
- limit(sin(x)/x,x,0)
登录后复制
1 displaystyle 1 1
- f2=(1+x)**(1/x)
登录后复制
- f2
登录后复制
( x + 1 ) 1 x displaystyle left(x + 1ight)^{rac{1}{x}} (x+1)x1
重要极限
- f1=sin(x)/xf2=(1+x)**(1/x)f3=(1+1/x)**xlim1=limit(f1,x,0)lim2=limit(f2,x,0)lim3=limit(f3,x,oo)print(lim1,lim2,lim3)
登录后复制
- 1 E E
登录后复制
dir可以表示极限的趋近方向
- f4 = (1+exp(1/x))f4
登录后复制
e 1 x + 1 displaystyle e^{rac{1}{x}} + 1 ex1+1
- lim4 = limit(f4,x,0,dir="-")lim4
登录后复制
1 displaystyle 1 1
- lim5 = limit(f4,x,0,dir="+")lim5
登录后复制
∞ displaystyle infty ∞
3. 求导diff
diff(函数,自变量,求导次数)
3.1 一元函数
求导问题
- diff(sin(2*x),x)
登录后复制
2 cos ( 2 x ) displaystyle 2 cos{left(2 x ight)} 2cos(2x)
- diff(ln(x),x)
登录后复制
1 x displaystyle rac{1}{x} x1
3.2 多元函数
求偏导问题
- diff(sin(x*y),x,y)
登录后复制
− x y sin ( x y ) + cos ( x y ) displaystyle – x y sin{left(x y ight)} + cos{left(x y ight)} −xysin(xy)+cos(xy)
4. 积分integrate
4.1 定积分
函数的定积分: integrate(函数,(变量,下限,上限))函数的不定积分: integrate(函数,变量)
- f = x**2 + 1integrate(f,(x,-1.1))
登录后复制
− 1.54366666666667 displaystyle -1.54366666666667 −1.54366666666667
- integrate(exp(x),(x,-oo,0))
登录后复制
1 displaystyle 1 1
4.2 不定积分
- f = 1/(1+x*x)integrate(f,x)
登录后复制
atan ( x ) displaystyle operatorname{atan}{left(x ight)} atan(x)
4.3 双重积分
- f = (4/3)*x + 2*yintegrate(f,(x,0,1),(y,-3,4))
登录后复制
11.6666666666667 displaystyle 11.6666666666667 11.6666666666667
5. 求解方程组solve
- #解方程组#定义变量f1=x+y-3f2=x-y+5solve([f1,f2],[x,y])
登录后复制
{x: -1, y: 4}
6. 计算求和式summation
计算求和式可以使用sympy.summation函数,其函数原型为sympy.summation(f, *symbols, **kwargs)
**
- sympy.summation(2 * n,(n,1,100))
登录后复制
10100
到这里就结束了,如果对你有帮助,欢迎点赞关注评论,你的点赞对我很重要。在此也祝愿大家可以把数学学好
相关免费学习推荐:python教程(视频)
以上就是学习Python解决高等数学问题的详细内容,更多请关注【创想鸟】其它相关文章!