Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (1 vote)
654 views

SymPy Cheatsheet

The document provides a cheatsheet for SymPy, an open-source Python library for symbolic mathematics. It lists the basics of SymPy including declaring symbols, substitution, numerical evaluation, expanding/simplifying expressions, and common functions. It also covers geometry objects like points, lines, and circles. Examples are given for evaluating constants like pi, expanding expressions, plotting functions, and solving equations. Discrete math, calculus, linear algebra, and differential equations are also summarized.

Uploaded by

Taimoo Naseem
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
654 views

SymPy Cheatsheet

The document provides a cheatsheet for SymPy, an open-source Python library for symbolic mathematics. It lists the basics of SymPy including declaring symbols, substitution, numerical evaluation, expanding/simplifying expressions, and common functions. It also covers geometry objects like points, lines, and circles. Examples are given for evaluating constants like pi, expanding expressions, plotting functions, and solving equations. Discrete math, calculus, linear algebra, and differential equations are also summarized.

Uploaded by

Taimoo Naseem
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

SymPy Cheatsheet (http://sympy.

org)
Basics Geometry Examples
Sympy help: help(function) Points: a = Point(xcoord, ycoord) Find 100 digits of π e :
Declare symbol: x = Symbol(’x’) Lines: l = Line(pointA, pointB) (pi**E).n(100)
Substitution: expr.subs(old, new) Circles: c = Circle(center, radius)
Numerical evaluation: expr.evalf() Triangles: t = Triangle(a, b, c) Expand (x + y)2 (x − y)(x2 + y):
Expanding: expr.expand() Area: object.area ((x + y)**2 * (x - y) * (x**2 + y)).expand()
Common denominator: ratsimp(expr) Intersection: intersection(a, b)
Simplify expression: simplify(expr) 1 x sin x − 1
Checking tangency: c.is_tangent(l) Simplify + :
x x2 − 1
simplify((1/x) + (x * sin(x) - 1)/(x**2 - 1))
Constants Numbers types Plotting
Check if line passing through points (0, 1) and (1, 1)
π: pi Integers (Z): Integer(x) Plot: Plot(f, [a, b])
is tangent to circle with center at (5, 5) and radius 3:
e: E Rationals (Q): Rational(p, q) Zoom: +/−: R/F or PgUp/PgDn or Numpad +/-
Circle(Point(5,5), 3).is_tangent(
∞: oo Reals (R): Float(x) Rotate X,Y axis: Arrow Keys or WASD
Line(Point(0,1), Point(1,1)))
i: I Rotate Z axis: Q and E or Numpad 7 and 9
View XY: F1
Find roots of x4 − 4x3 + 2x2 − x = 0:
Basic funtions View XZ: F2
solve(x**4 - 4*x**3 + 2*x**2 - x, x)
View YZ: F3
Trigonometric: sin cos tan cot View Perspective: F4
Cyclometric: asin acos atan acot Solve the equations system: x + y = 4, xy = 3:
Axes Visibility: F5
Hyperbolic: sinh cosh tanh coth solve([x + y - 4, x*y - 3], [x, y])
Axes Colors: F6
Area hyperbolic: asinh acosh atanh acoth Screenshot: F8 √
n
Exponential: exp(x) Calculate limit of the sequence n:
Exit plot: ESC
Square root: sqrt(x) limit(n**(1/n), n, oo)
Logarithm (logb a): log(a, b)
Discrete math |x|
Natural logarithm: log(a) Calculate left-sided limit of the function x
in 0:
Gamma (Γ(x)): gamma(x) Factorial (n!): factorial(n) limit(abs(x)/x, x, 0, dir=’-’)
( )
Absolute value: abs(x) Binomial coefficient nk : binomial(n, k) ∑
∑ Calculate the sum 100 2
Sum ( bn=a expr): summation(expr, (n, a, b)) n=0 n :
∏ summation(n**2, (n, 0, 100))
Calculus Product ( bn=a expr): product(expr, (n, a, b))

lim f (x):
x→a
limit(f, x, a) Calculate the sum ∞ 1
n=0 n2 :
Linear algebra summation(1/n**2, (n, 0, oo))
lim f (x): limit(f, x, a, dir=’-’)
x→a−
lim f (x): limit(f, x, a, dir=’+’)
Matrix definition: m = Matrix([[a, b], [c, d]]) ∫
x→a+ Determinant: m.det() Calculate the integral cos3 x dx:
d integrate(cos(x)**3, x)
dx
f (x): diff(f, x) Inverse: m.inv()

∫ f (x, y):
∂x
diff(f, x) Identity matrix n × n: eye(n) ∫∞
f (x) dx : integrate(f, x) Zero matrix n × n: zeros(n) Calculate the integral 1 xdx2 :
∫b
a
f (x) dx : integrate(f, (x, a, b)) Ones matrix n × n: ones(n) integrate(1/x**2, (x, 1, oo))
Taylor series (at a, deg n) f.series(x, a, n)
1
Find 10 terms of series expansion of at 0:
Printing 1−2x
(1/(1 - 2*x)).series(x, 0, 10)
Equations LATEX print: print latex()
′′
Equation f (x) = 0: solve(f, x) Python print: print python() Solve the differential equation f (x) + 9f (x) = 1:
System of equations: solve([f, g], [x, y]) Pretty print: pprint() dsolve(f(x).diff(x, x) + 9*f(x) - 1, f(x))
Differential equation: dsolve(equation, f(x))

You might also like