Professional Documents
Culture Documents
A Tour of Sage
This is a tour of Sage that closely follows the tour of Mathematica that is at the beginning of the Mathematica Book.
Sage as a Calculator
The Sage command line has a s g : prompt; you do not have to add it. If you use the Sage ae notebook, then put everything after the s g : prompt in an input cell, and press shift-enter to ae compute the corresponding output.
sg:3+5 ae 8
matrix in Sage.
sg:x=vr'' ae a(x) #cet asmoi vral rae yblc aibe sg:itgaesr()sr(+) x ae nert(qtx*qt1x, ) 14(x+1^32/^32 +sr( +1/qtx)(x+1^/^ -2( +1/ +1 +1 /*( )(/)x(/) qtx )sr()/( )2x2 *x )x ) /
This asks Sage to solve a quadratic equation. The symbol = represents equality in Sage. =
sg:a=vr'' ae a(a) sg:S=slex2+x= a x;S ae ov(^ = , ) [ = -/*qt4a+1 -12 x= 12sr(* +1 -12 x = 12sr(* ) /, = /*qt4a ) /]
1/ 4
11/ 10/ 12
It takes Sage a few seconds to compute the eigenvalues of the matrix and plot them.
sg:e=megnaus) #bu 2scns ae .ievle( aot eod sg:w=[i asei) frii rnelne) ae (, b([]) o n ag(e()] sg:so(onsw) ae hwpit()
2/ 4
11/ 10/ 12
Thanks to the GNU Multiprecision Library (GMP), Sage can handle very large numbers, even numbers with millions or billions of digits.
sg:fcoil10 ae atra(0) 93614341286938667097562486165268515992916844 32254945619285260401986312489939279932950916 sg:n=fcoil1000 #bu 25scns ae atra(000) aot . eod
11/ 10/ 12
(^0+x1* -x1*^ -x1*^ +x1*^ +x1*^ x2 ^9y ^7y3 ^6y4 ^4y6 ^3y7 x1*^ -x1*^0-x9y1 +x7y1 +x6y1 ^1y9 ^0y1 ^*^1 ^*^3 ^*^4 x4y1 -x3y1 +xy1 +y2)*(^0+x5*^ ^*^6 ^*^7 *^9 ^0 x6 ^7y3 x5*^ -x4*^2+x4*^8+x3*^1-x3*^7^1y9 ^8y1 ^2y1 ^9y2 ^3y2 x3*^0-x2*^3+x2*^9+x1*^2-x1*^8^0y3 ^7y3 ^1y3 ^8y4 ^2y4 x9y5 +x3y5 +y6) ^*^1 ^*^7 ^0 sg:Fepn( ae .xad) x9 +y9 ^9 ^9
Sage takes just under 5 seconds to compute the numbers of ways to partition one hundred million as a sum of positive integers.
sg:z=Priin(08.adnlt( #bu 45scns ae attos1^)criaiy) aot . eod sg:srz[4] ae t():0 '70105429430784715009 16574964116339693240'
4/ 4