美文网首页
Python --- SymPy

Python --- SymPy

作者: 唯师默蓝 | 来源:发表于2018-01-21 19:59 被阅读0次

解线性方程组:

  1. 安装sympy库,sudo pip install sympy;

源码:
from sympy import *
x = Symbol('x')
y = Symbol('y')

或者写成这个样子 -- x,y = symbols('x y')

print(solve([2*x - y - 3,3 * x + y -7],[x,y]))

即可解得答案。

解积分:

![KTCSW]50BYOR9L16`5T9H}5.png](https://img.haomeiwen.com/i3612808/f81f0856e69c21f5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

from sympy import *
t = Symbol('t')
x = Symbol('x')
m = integrate(sin(t) / (pi - t) , (t , 0 ,x))
n = integrate(m,(x , 0 , pi))
print(n)

解极限:

LFD60KVXNJ9{EA51$K0ELF0.png

源码:
from sympy import *
n = Symbol('n')
s = ((n+3)/(n+2)) ** n
print(limit(s,n,oo))

求微分方程:

wm.jpg

源码:
from sympy import *
f = Function('f')
x = Symbol('x')
print(dsolve(diff(f(x),x) - 2 * f(x)*x,f(x)))

相关文章

网友评论

      本文标题:Python --- SymPy

      本文链接:https://www.haomeiwen.com/subject/haobcxtx.html