0% found this document useful (0 votes)
69 views2 pages

Gloo13 Sympy - BW

The Sympy Cheat Sheet provides a comprehensive overview of basic operations, matrix manipulations, special functions, calculus, and solvers in SymPy, a Python library for symbolic mathematics. It includes various functions and methods for tasks such as substitution, differentiation, integration, and solving equations. The document is structured to serve as a quick reference for users looking to utilize SymPy effectively.

Uploaded by

kokomyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views2 pages

Gloo13 Sympy - BW

The Sympy Cheat Sheet provides a comprehensive overview of basic operations, matrix manipulations, special functions, calculus, and solvers in SymPy, a Python library for symbolic mathematics. It includes various functions and methods for tasks such as substitution, differentiation, integration, and solving equations. The document is structured to serve as a quick reference for users looking to utilize SymPy effectively.

Uploaded by

kokomyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Sympy Cheat Sheet

by gloo13 via cheatography.com/185324/cs/39863/

Basic Operations Matrices Matrices (cont)

expr.s​ubs​‐ substitute x with 2 etc. Matrix([1, matrix constr​uct​or(​mutable M.eige​ returns a list of tuples of the form
([(x, 2), (y, 2, 3]) matrix) nve​‐ (eigen​value, algebr​aic​_mu​lti​pli​‐
4), (z, 0)]) shape(​‐ shape of matrix cts() city, [eigen​vec​tors])

sympif​y(s​‐ convert strings into SymPy expr) M.diag​ returns a tuple (P, D), where D is
tr_​expr) expres​sions M.row(0) get the first row ona​‐ diagonal and M = P DP **−1
expr.e​val​‐ evaluate a numerical lize()
M.col(-1) get the last column
f(15, expression into a floating M.char​ return the charac​ter​istic
M.col_​‐ delete first column
chop=True) point number pol​y(l​‐ polynomial
del(0)
lambdi​fy(x, converts the SymPy names amda)
M.row_​‐ delete second row
expr, to the names of the given
del(1)
”numpy”) numerical library Trigon​ometric Simpli​fic​ation
M.row_​ins​‐ insert a row
init_p​rin​‐ This will automa​tically enable trigsi​mp(​‐ simplify expres​sions using
ert(1,
ting() the best printer available in expr) trigon​ometric identities
Matrix​([[0,
your enviro​nment. expand​‐ expand trigon​ometric functions
4]]))
simpli​fy(​‐ simplify mathem​atical _tr​ig(​expr)
M.col_​ins​‐ insert a column
expr) expres​sions
ert(0,
Powers
expand​‐ expand polynomial expres​‐ Matrix([1, -
(expr) sions 2])) powsim​p(expr) use power
factor​(expr) takes a polynomial and identities
M**-1 inverse of M
factors it into irredu​cible expand​_po​wer​_ex​p(x**(a x**a * x**b
M.T transpose of M
factors over the rational + b))
eye(n) create a nxn identity matrix
numbers expand​_po​wer​_ba​‐ x**a * y**a
zeros(n,m) creates a nxm matrix of
factor​_li​st(​‐ returns a list with the factors. se((xy)*a)
zeroes
expr) More struct​ured. powden​est((xa)b)powd​‐ x**(a*b)
ones(n,m) creates a nxm matrix of ones
collec​‐ collects common powers of a ene​st((xa)b)
t(expr, x) term in an expression diag(expr) creates a matrix with expr in
the diagonal Expone​ntials and logarithms
cancel​‐ take any rational function and
(expr) put it into the standard M.det() computes the determ​inant of expand​_lo​g(expr)
canonical form M
logcom​bin​e(expr)
apart(​expr) performs a partial fraction M.rref() put a matrix into reduced row
decomp​osition on a rational echelon form Special Functions
function M.null​‐ returns a list of column
factor​ial(n) return the factorial of n
space() vectors that span the
binomi​al(n, k) return the binomial coeffi​‐
nullspace of the matrix
cient of n and k
M.colu​mns​‐ returns a list of column
gamma(z) return the gamma function
pace() vectors that span the column​‐
space of the matrix expr.r​ewr​ite​‐ rewrite expr in terms of
(fu​nction) function
M.eige​‐ eigenvals returns a dictionary
nvals() of eigenv​alue: algebr​aic​_mu​‐ expand​_fu​‐ expand special functions
lti​plicity pairs nc(​expr)

By gloo13 Not published yet. Sponsored by Readable.com


cheatography.com/gloo13/ Last updated 13th August, 2023. Measure your website readability!
Page 1 of 2. https://readable.com
Sympy Cheat Sheet
by gloo13 via cheatography.com/185324/cs/39863/

Special Functions (cont) Calculus (cont)

hypere​‐ rewrite hyper in terms of more differ​ent​iat​‐ differ​entiate using finite


xpa​nd(​‐ standard functions e_f​ini​te(​‐ differ​ences
expr) expr)
combsi​‐ simplify combin​atorial expres​‐ expr.a​s_f​‐ generate approx​ima​tions of
mp(​‐ sions ini​te_​dif​fer​‐ the derivative to arbitrary
expr) ence() order
gammas​ simplify expres​sions with
imp​‐ gamma functions or combin​‐ Solvers
(expr) atorial functions solves​et(​expr, x, solve expr=0
domain​=S.C​om​‐
Assump​tions plexes, dict=F​alse)

positive negative linsol​ve(​[expr1, solve a linear system


real complex expr2, ...], (x, y, ...)) of equations

integer nonlin​sol​ve(​[expr1, solve a non linear


expr2, ...], [x, y, ...]) system of equations
expr.a​‐ The full set of known predicates
ssu​‐ for a symbol dsolve​(di​ffeq, f(x)) soves differ​ential
mpt​‐ equation diffeq
ions0 roots(​expr, x) o get the solutions of
posify​‐ replace all symbols in an a polynomial
(expr) expression with symbols that including multip​licity
have the assumption positi​‐
ve=True

Calculus

diff(expr, x, n) nth order derivative of


expr in terms of x
Deriva​tiv​e(expr, create an uneval​uated
x, n) derivative
deriv.d​oit() evaluate an uneval​uated
derivative
integr​ate​(expr, x, integrate expr from a to
a, b) b
Integr​al(​expr, x, create an uneval​uated
n) integral
limit(​expr, x, xo) limit of expr to xo
Limit(​expr, x, xo) create an uneval​uated
limit
expr.s​eri​es(x, nth order series
x0, n) expansion of expr
around x0
expr.s​eri​es(x, remove O notation
x0, n).rem​‐
oveO()

By gloo13 Not published yet. Sponsored by Readable.com


cheatography.com/gloo13/ Last updated 13th August, 2023. Measure your website readability!
Page 2 of 2. https://readable.com

You might also like