{{{id=302| 1+2+3 # testing /// }}} {{{id=301| /// }}}
Sage is not a drop-in replacement: does not run programs written in the custom languages of the Ma's.
Sage is not like Octave (versus Matlab).
Sage's culture, architecture, programming language, and feel are different than the Ma's.
{{{id=272| /// }}} {{{id=271| /// }}} {{{id=158| /// }}} {{{id=133| /// }}} {{{id=132| /// }}} {{{id=94| /// }}}{{{id=8| /// }}} {{{id=135| /// }}} {{{id=83| /// }}}
See this article for more details about the (pre-)history of Sage.
{{{id=98| /// }}} {{{id=157| /// }}} {{{id=156| /// }}} {{{id=181| /// }}} {{{id=185| /// }}} {{{id=184| /// }}}Some random examples involving Sage:
{{{id=275| factorial(3) /// }}} {{{id=274| A = random_matrix(QQ, 4); b = A^(-1); b /// }}} {{{id=305| show(b) /// }}} {{{id=273| latex(b) /// }}} {{{id=304| show(integrate(sin(x)*cos(x), x)) /// }}} {{{id=190| G = plot(sin(x)*cos(x), (0, 4), figsize=3) G /// }}} {{{id=260| G.save('a.pdf') /// }}} {{{id=259| a = octave('rand(5)'); a /// }}} {{{id=258| a.eig() /// }}} {{{id=262| /// }}} {{{id=276| /// }}} {{{id=261| /// }}} {{{id=256| /// }}} {{{id=320| /// }}}(using numpy)
"Sage's graph theory crushes anything I have met from the point of view of methods implemented. I would say: 'if you found a proprietary graph library and you are convinced that it is better for your needs than Sage, your license is on me.' But those licenses are really expensive :-D"
{{{id=306| graphs. /// }}} {{{id=216| G = graphs.BuckyBall() G.plot().show(figsize=8) /// }}} {{{id=76| set_random_seed(1) G = graphs.RandomLobster(8, .6, .3) show(G, figsize=7) /// }}} {{{id=77| G.automorphism_group() /// }}} {{{id=159| G.chromatic_number() /// }}} {{{id=196| G.shortest_path(13,20) /// }}} {{{id=74| /// }}} {{{id=113| /// }}} {{{id=288| /// }}} {{{id=287| /// }}} {{{id=299| /// }}} {{{id=297| /// }}}Even then, Cython provides a speedup:
{{{id=143| %cython def c_sum2(long long n): return n*(2*n+1)*(n+1)/6 /// }}} {{{id=197| c_sum2(3) /// }}} {{{id=236| c_sum2(2*10^6) /// }}} {{{id=237| n = 2*10^6 timeit('sum2(n)') /// }}} {{{id=238| timeit('c_sum2(n)') /// }}} {{{id=235| 2.01/.218 /// }}} {{{id=240| /// }}} {{{id=239| /// }}}But at a cost!
{{{id=145| c_sum2(2*10^6) # WARNING: overflow -- it's just like C... /// }}} {{{id=147| n=2*10^6; n*(2*n+1)*(n+1) > 2^63 /// }}} {{{id=284| /// }}} {{{id=283| /// }}} {{{id=137| /// }}}Solve a cubic equation:
{{{id=15| x = var('x'); show(solve(x^3 + x - 1==0, x)[0]) /// }}}Solve a system of two linear equations with one unknown coefficient $\alpha$:
{{{id=17| var('alpha, y') show(solve([3*x + 7*y == 2, alpha*x + 3*y == 8], x,y)[0]) /// }}}Solve a system of 500 linear equations exactly over the rational numbers:
{{{id=127| n = 500 A = random_matrix(QQ,n,n,num_bound=10, den_bound=10) v = random_matrix(QQ,n,1,num_bound=10, den_bound=10) A.visualize_structure() /// }}} {{{id=148| # IML is used -- http://www.cs.uwaterloo.ca/~astorjoh/iml.html time w = A \ v /// }}} {{{id=150| print w.str() /// }}} {{{id=149| /// }}} {{{id=310| /// }}} {{{id=151| /// }}}Symbolic Calculus makes use of Maxima and Ginac under the hood.
{{{id=26| var('x') f = sqrt(1 - x^2) plot(f, thickness=3, color='red', aspect_ratio=1, fill=True, figsize=4) /// }}} {{{id=163| var('t') assume(t+1 > 0) g = integrate(f, (x, -1, t)); show(g) /// }}} {{{id=162| show(g(t=1) - g(t=-1)) /// }}} {{{id=311| /// }}} {{{id=160| /// }}} {{{id=161| /// }}}See http://www.davidson.edu/math/chartier/Starwars/
{{{id=49| # Yoda! (53,756 vertices) from scipy import io yoda = io.loadmat(DATA + 'yodapose.mat') from sage.plot.plot3d.index_face_set import IndexFaceSet V = yoda['V']; F3=yoda['F3']-1; F4=yoda['F4']-1 Y = IndexFaceSet(F3,V,color=Color('#444444')) + IndexFaceSet(F4,V,color=Color('#007700')) Y = Y.rotateX(-1) Y.show(aspect_ratio=1, frame=False, zoom=1.2) /// }}} {{{id=96| /// }}}If you made it this far, next try the Sage Tutorial.
{{{id=312| /// }}} {{{id=131| /// }}}