Sage Quick Reference (Basic Math) find_root(f(x), a, b) find x ∈ [a, b] s.t. f(x) ≈ 0 options e.g. aspect ratio=[1, 1, 1] color=’red’ opacity Peter Jipsen, latest version at n .org/quickref X plot3d(f(x, y),[xb,xe],[yb,ye],options) f(i) = sum([f(i) for i in [k..n]]) GNU Free Document License, extend for your own use add option plot_points=[m, n] or use plot3d adaptive Aim: map standard math notation to Sage commands i=k n parametric plot3d((f(t),g(t),h(t)),[t ,t ],options) Y b e f(i) = prod([f(i) for i in [k..n]]) parametric plot3d((f(u, v),g(u, v),h(u, v)), i=k Notebook (and commandline) [ub,ue],[vb,ve],options) Evaluate cell: hshift-enteri Calculus use + to combine graphics objects comhtabi tries to complete command lim f(x) = limit(f(x), x=a) x→a Discrete math command?htabi shows documentation lim f(x) = limit(f(x), x=a, dir=’minus’) command??htabi shows source x→a− bxc = floor(x) dxe = ceil(x) lim f(x) = limit(f(x), x=a, dir=’plus’) a.htabi shows all methods for object a (more: dir(a)) x→a+ Remainder of n divided by k = n%k k|n iff n%k==0 string or regexp shows links to docs d n! = factorial(n) x  = binomial(x,m) search_doc(’ ’) dx (f(x)) = diff(f(x),x) m search_src(’string or regexp’) shows links to source ∂ φ = golden_ratio φ(n) = euler phi(n) ∂x (f(x, y)) = diff(f(x,y),x) lprint() toggle LaTeX output mode diff = differentiate = derivative Strings: e.g. s = ’Hello’ = "Hello" = ""+"He"+’llo’ version() print version of Sage f(x)dx = integral(f(x),x) s[0]=’H’ s[-1]=’o’ s[1:3]=’el’ s[3:]=’lo’ Insert cell: click on blue line between cells integral = integrate Lists: e.g. [1,’Hello’,x] = []+[1,’Hello’]+[x] Delete cell: delete content then backspace R b Tuples: e.g. (1,’Hello’,x) (immutable) a f(x)dx = integral(f(x),x,a,b) Taylor polynomial, deg n about a: taylor(f(x),x,a,n) Sets: e.g. {1, 2, 1, a} = Set([1,2,1,’a’]) (= {1, 2, a}) Numerical types List comprehension ≈ set builder notation, e.g. Integers: Z = ZZ e.g. -2 -1 0 1 10^100 2d graphics {f(x): x ∈ X, x > 0} = Set([f(x) for x in X if x>0]) Rationals: = QQ e.g. 1/2 1/1000 314/100 -42 Q line([(x1,y1),...,(xn,yn)],options) Decimals: R ≈ RR e.g. .5 0.001 3.14 -42. x y ... x y options Linear algebra polygon([( 1, 1), ,( n, n)], )   Complex: ≈ e.g. 1 CC 1+i 2.5-3*i circle((x,y),r,options) = vector([1,2]) 2 text("txt",(x,y),options) Basic constants and functions 1 2 options as in plot.options, e.g. thickness=pixel, = matrix([[1,2],[3,4]]) Constants: π = pi e = e i = i ∞ = oo 3 4 rgbcolor=(r,g,b), hue=h where 0 ≤ r, b, g, h ≤ 1 Approximate: pi.n(digits=18) = 3.14159265358979324 1 2 use option figsize=[w,h] to adjust aspect ratio = det(matrix([[1,2],[3,4]])) Functions: sin cos tan sec csc cot sinh cosh tanh 3 4 plot(f(x),x ,x ,options) sech csch coth log ln exp min max Av = A*v A−1 = A^-1 At = A.transpose() √ parametric plot((f(t),g(t)),t ,t ,options) ab = a*b a = a/b ab = a^b x = sqrt(x) min max methods: nrows() ncols() nullity() rank() trace()... √ b polar plot(f(t),t ,t ,options) n x = x^(1/n) |x| = abs(x) log (x) = log(x,b) min max b combine graphs: circle((1,1),1)+line([(0,0),(2,2)]) Symbolic variables: e.g. t,u,v,y,z = var(’t u v y z’) Sage modules and packages animate(list of graphics objects, options).show(delay=20) Define function: e.g. f(x) = x2 f(x)=x^2 from module name import * (many preloaded) or f=lambda x: x^2 or def f(x): return x^2 e.g. calculus coding combinat crypto functions 3d graphics games geometry graphs groups logic matrix line3d([(x ,y ,z ),...,(x ,y ,z )],options) Operations on expressions 1 1 1 n n n numerical plot probability rings sets stats sphere((x,y,z),r,options) factor(...) expand(...) (...).simplify_... sage.module name.all.htabi shows exported commands tetrahedron((x,y,z),size,options) Symbolic equations: f(x)==g(x) Std packages: GP/PARI GAP R Shell ... cube((x,y,z),size,options) _ is previous output Opt packages: Biopython Fricas(Axiom) Kash ... octahedron((x,y,z),size,options) _+a _-a _*a _/a manipulates equation %package name then use package command syntax dodecahedron((x,y,z),size,options) Solve f(x) = g(x): solve(f(x)==g(x),x) time command to show timing information icosahedron((x,y,z),size,options) solve([f(x,y)==0, g(x,y)==0], x,y) (Sage quick reference version 1.1)

1