Sagemath Quick Reference Sheet
Sagemath Quick Reference Sheet
Arithmetic
n
x = x^(1/n) |x| = abs(x) logb (x) = log(x,b)
n
X
Sums:
f (i) = sum(f(i) for i in (k..n))
2D graphics
1
0.75
0.5
0.25
-6
-4
-2
-0.25
-0.5
-0.75
-1
n
Y
Symbolic expressions
Define new symbolic variables: var("t u v y z")
Symbolic function: e.g. f (x) = x2
f(x)=x^2
Relations: f==g f<=g f>=g f<g f>g
Solve f = g: solve(f(x)==g(x), x)
solve([f(x,y)==0, g(x,y)==0], x,y)
factor(...)
expand(...)
(...).simplify_...
find_root(f(x), a, b) find x [a, b] s.t. f (x) 0
Calculus
lim f (x) = limit(f(x), x=a)
xa
d
dx (f (x)) =
x (f (x, y))
diff(f(x),x)
= diff(f(x,y),x)
diff = differentiate = derivative
R
f (x)dx = integral(f(x),x)
Rb
f (x)dx = integral(f(x),x,a,b)
a
Rb
f (x)dx numerical_integral(f(x),a,b)
a
Taylor polynomial, deg n about a: taylor(f(x),x,a,n)
Combinatorics
Python modules
import module name
module_name.htabi and help(module_name)
Profiling and debugging
time command : show timing information
timeit("command"): accurately time command
t = cputime(); cputime(t): elapsed CPU time
t = walltime(); walltime(t): elapsed wall time
%pdb: turn on interactive debugger (command line only)
%prun command: profile command (command line only)