Skip to content

Instantly share code, notes, and snippets.

@iguoli
Last active March 8, 2018 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iguoli/d9fd3711b5fe2ad0931f503965adf949 to your computer and use it in GitHub Desktop.
Save iguoli/d9fd3711b5fe2ad0931f503965adf949 to your computer and use it in GitHub Desktop.
SymPy学习笔记, python, sympy, Symbol, CAS

SymPy是一个用来处理数学符号的Python库,一个计算机代数系统(Computer Algebra System, CAS)。

from sympy import Symbol, symbols
from sympy import limit, sin, cos, pi, oo
from sympy import simplify, expand


# 求极限,(1+1/n)^n趋于无穷大时的极限(极限值为欧拉数e)
n = Symbol('n')
f = lambda n: (1 + 1/n)**n
limit(f(n), n, oo)

# 表达式展开,求(x+y)^2的二项式展开
x, y = symbols('x, y')
expand((x + y)**2)

# 表达式化简
simplify(sin(x)**2 + cos(x)**2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment