資訊內容
學習Python解決高等數學問題
ykZ少兒編程網-https://www.pxcodes.com
使用Python解決高等數學中極限、導數、偏導數、定積分、不定積分、雙重積分等問題ykZ少兒編程網-https://www.pxcodes.com
Sympy是一個Python的科學計算庫,它旨在成為功能齊全的計算機代數系統。 SymPy 包括從基本符號算術到微積分,代數,離散數學和量子物理學的功能。 它可以在 LaTeX 中顯示結果。ykZ少兒編程網-https://www.pxcodes.com
Sympy*網ykZ少兒編程網-https://www.pxcodes.com
文章目錄ykZ少兒編程網-https://www.pxcodes.com
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視頻教程)ykZ少兒編程網-https://www.pxcodes.com
ykZ少兒編程網-https://www.pxcodes.com
看到這圖,是不是感覺快喘不過氣了呢。Python來幫你解決。ykZ少兒編程網-https://www.pxcodes.com
from sympy import *import sympy輸入“x= symbols(“x”)”命令定義一個符號ykZ少兒編程網-https://www.pxcodes.com
x = Symbol("x")y = Symbol("y")1. 實用技巧ykZ少兒編程網-https://www.pxcodes.com
1.1 符號函數ykZ少兒編程網-https://www.pxcodes.com
sympy提供了很多數學符號,總結如下ykZ少兒編程網-https://www.pxcodes.com
虛數單位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 展開表達式expandykZ少兒編程網-https://www.pxcodes.com
f = (1+x)**3expand(f)x 3 + 3 x 2 + 3 x + 1 displaystyle x^{3} + 3 x^{2} + 3 x + 1 x3+3x2+3x +1ykZ少兒編程網-https://www.pxcodes.com
1.3 泰勒展開公式seriesykZ少兒編程網-https://www.pxcodes.com
ln(1+x).series(x,0,4)x ? x 2 2 + x 3 3 + O ( x 4 ) displaystyle x - frac{x^{2}}{2} + frac{x^{3}}{3} + Oleft(x^{4}ight) x?2x2+3x3+O (x4)ykZ少兒編程網-https://www.pxcodes.com
sin(x).series(x,0,8)x ? x 3 6 + x 5 120 ? x 7 5040 + O ( x 8 ) displaystyle x - frac{x^{3}}{6} + frac{x^{5}}{120} - frac{x^{7}}{5040} + Oleft(x^{8}ight) x?6x3+120x 5?5040x7+O(x8)ykZ少兒編程網-https://www.pxcodes.com
cos(x).series(x,0,9)1 ? x 2 2 + x 4 24 ? x 6 720 + x 8 40320 + O ( x 9 ) displaystyle 1 - frac{x^{2}}{2} + frac{x^{4}}{24} - frac{x^{6}}{720} + frac{x^{8}}{40320} + Oleft(x^{9}ight) 1? 2x2+24x4?720x6+ 40320x8+O(x9)ykZ少兒編程網-https://www.pxcodes.com
(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?x 3+x4+O(x5)ykZ少兒編程網-https://www.pxcodes.com
tan(x).series(x,0,4)x + x 3 3 + O ( x 4 ) displaystyle x + frac{x^{3}}{3} + Oleft(x^{4}ight) x+3x3+ O(x4)ykZ少兒編程網-https://www.pxcodes.com
(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)ykZ少兒編程網-https://www.pxcodes.com
(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)ykZ少兒編程網-https://www.pxcodes.com
1.4 符號展開ykZ少兒編程網-https://www.pxcodes.com
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} x a+bykZ少兒編程網-https://www.pxcodes.com
2. 求極限limitykZ少兒編程網-https://www.pxcodes.com
limit(sin(x)/x,x,0)1 displaystyle 1 1ykZ少兒編程網-https://www.pxcodes.com
f2=(1+x)**(1/x)f2( x + 1 ) 1 x displaystyle left(x + 1ight)^{frac{1}{x}} (x+1)x1ykZ少兒編程網-https://www.pxcodes.com
重要極限ykZ少兒編程網-https://www.pxcodes.com
f1=sin(x)/x f2=(1+x)**(1/x)f3=(1+1/x)**x lim1=limit(f1,x,0)lim2=limit(f2,x,0)lim3=limit(f3,x,oo)print(lim1,lim2,lim3)1 E Edir可以表示極限的趨近方向ykZ少兒編程網-https://www.pxcodes.com
f4 = (1+exp(1/x))f4e 1 x + 1 displaystyle e^{frac{1}{x}} + 1 e x1+1ykZ少兒編程網-https://www.pxcodes.com
lim4 = limit(f4,x,0,dir="-")lim41 displaystyle 1 1ykZ少兒編程網-https://www.pxcodes.com
lim5 = limit(f4,x,0,dir="+")lim5∞ displaystyle infty ∞ykZ少兒編程網-https://www.pxcodes.com
3. 求導diffykZ少兒編程網-https://www.pxcodes.com
diff(函數,自變量,求導次數)ykZ少兒編程網-https://www.pxcodes.com
3.1 一元函數ykZ少兒編程網-https://www.pxcodes.com
求導問題ykZ少兒編程網-https://www.pxcodes.com
diff(sin(2*x),x)2 cos ? ( 2 x ) displaystyle 2 cos{left(2 x ight)} 2cos(2x)ykZ少兒編程網-https://www.pxcodes.com
diff(ln(x),x)1 x displaystyle frac{1}{x} x1ykZ少兒編程網-https://www.pxcodes.com
3.2 多元函數ykZ少兒編程網-https://www.pxcodes.com
求偏導問題ykZ少兒編程網-https://www.pxcodes.com
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)ykZ少兒編程網-https://www.pxcodes.com
4. 積分integrateykZ少兒編程網-https://www.pxcodes.com
4.1 定積分ykZ少兒編程網-https://www.pxcodes.com
函數的定積分: integrate(函數,(變量,下限,上限))函數的不定積分: integrate(函數,變量)f = x**2 + 1integrate(f,(x,-1.1))? 1.54366666666667 displaystyle -1.54366666666667 ?1.54366666666667ykZ少兒編程網-https://www.pxcodes.com
integrate(exp(x),(x,-oo,0))1 displaystyle 1 1ykZ少兒編程網-https://www.pxcodes.com
4.2 不定積分ykZ少兒編程網-https://www.pxcodes.com
f = 1/(1+x*x)integrate(f,x)atan ? ( x ) displaystyle operatorname{atan}{left(x ight)} atan(x)ykZ少兒編程網-https://www.pxcodes.com
4.3 雙重積分ykZ少兒編程網-https://www.pxcodes.com
f = (4/3)*x + 2*y integrate(f,(x,0,1),(y,-3,4))11.6666666666667 displaystyle 11.6666666666667 11.666666 6666667ykZ少兒編程網-https://www.pxcodes.com
5. 求解方程組solveykZ少兒編程網-https://www.pxcodes.com
#解方程組#定義變量f1=x+y-3f2=x-y+5solve([f1,f2],[x,y]){x: -1, y: 4}ykZ少兒編程網-https://www.pxcodes.com
6. 計算求和式summationykZ少兒編程網-https://www.pxcodes.com
計算求和式可以使用sympy.summation函數,其函數原型為sympy.summation(f, *symbols, **kwargs)ykZ少兒編程網-https://www.pxcodes.com
**ykZ少兒編程網-https://www.pxcodes.com
10100ykZ少兒編程網-https://www.pxcodes.com
到這里就結束了,如果對你有幫助,歡迎點贊關注評論,你的點贊對我很重要。在此也祝愿大家可以把數學學好ykZ少兒編程網-https://www.pxcodes.com
相關免費學習推薦:python教程(視頻)ykZ少兒編程網-https://www.pxcodes.com
以上就是學習Python解決高等數學問題的詳細內容,更多請關注少兒編程網其它相關文章!ykZ少兒編程網-https://www.pxcodes.com

- 上一篇
python單引號和雙引號、三引號的區別是什么
簡介區別:單引號和雙引號是等效的,如果要換行,那么需要使用符號“”;三引號則可以直接換行,并且可以包含注釋。單引號里不能加單引號,但可加“”或者是雙引號進行轉義輸出。雙引號里面不能再加雙引號,但是可以加“”或者是單引號進行轉義輸出。本教程操作環境:windows7系統、DellG3電腦、Pytho
- 下一篇
python 操作 excel 系列之:數據清洗
簡介python在對excel操作的同時,前面文章中說了數據的讀取、插入、簡單分析,還有一個非常重要的點就是數據清洗。那什么叫數據清洗,說白了就是去除數據文本中的垃圾值,比如:存在的空值、多余的空格、數據格式等等的處理。相關免費學習推薦:python視頻教程1,導入python庫、讀取excel數據#導