CoCalc Public Filestmp / 2015-02-09-100411.sagews
Authors: Harald Schilly, ℏal Snyder, William A. Stein
%html(hide=False)
$("<style>.sagews-output-stdout{color: blue;}</style>").appendTo($("body"))

$("").appendTo($("body"))
print "hi"

hi
salvus.tex("4 &lt; 5")

$4 < 5$
latex('foo')

\text{\texttt{foo}}
show(["Matrix = ", 2])

$\left[\text{\texttt{Matrix{ }={ }}}, 2\right]$
pretty_print(2/3,4/5,plot(sin))

$\frac{2}{3}$

help(pretty_print)

Help on function show in module sage_salvus: show(obj, svg=True, d3=True, **kwds) Show a 2d or 3d graphics object, animation, or matplotlib figure, or show an expression typeset nicely using LaTeX. - display: (default: True); if True, use display math for expression (big and centered). - svg: (default: True); if True, show 2d plots using svg (otherwise use png) - d3: (default: True); if True, show graphs (vertices and edges) using an interactive D3 viewer for the many options for this viewer, type 'import graphics; graphics.graph_to_d3_jsonable?' If false, graphs are converted to plots and displayed as usual. - renderer: (default: 'webgl'); for 3d graphics - 'webgl' (fastest) using hardware accelerated 3d; - 'canvas' (slower) using a 2d canvas, but may work better with transparency; - 'tachyon' -- a ray traced static image. - spin: (default: False); spins 3d plot, with number determining speed (requires mouse over plot) - events: if given, {'click':foo, 'mousemove':bar}; each time the user clicks, the function foo is called with a 2-tuple (x,y) where they clicked. Similarly for mousemove. This works for Sage 2d graphics and matplotlib figures. ANIMATIONS: - animations are by default encoded and displayed using an efficiently web-friendly format (currently webm, which is **not supported** by Safari or IE). - delay - integer (default: 20); delay in hundredths of a second between frames. - gif=False -- if you set gif=True, instead use an animated gif, which is much less efficient, but works on all browsers. You can also use options directly to the animate command, e.g., the figsize option below: a = animate([plot(sin(x + a), (x, 0, 2*pi)) for a in [0, pi/4, .., 2*pi]], figsize=6) show(a, delay=30) EXAMPLES: Here's an example that illustrates creating a clickable image with events:: @interact def f0(fun=x*sin(x^2), mousemove='', click='(0,0)'): click = sage_eval(click) g = plot(fun, (x,0,5), zorder=0) + point(click, color='red', pointsize=100, zorder=10) ymax = g.ymax(); ymin = g.ymin() m = fun.derivative(x)(x=click[0]) b = fun(x=click[0]) - m*click[0] g += plot(m*x + b, (click[0]-1,click[0]+1), color='red', zorder=10) def h(p): f0.mousemove = p def c(p): f0(click=p) show(g, events={'click':c, 'mousemove':h}, svg=True, gridlines='major', ymin=ymin, ymax=ymax)