Sage Days 20.5: Tutorial
system:sage


<p style="text-align: right;"><span style="font-size: small;">(This worksheet is based on William Stein's <a title="download the worksheet" href="http://modular.math.washington.edu/talks/20090701-sage_graphics_tutorial/JPL09___intro_to_sage.sws">JPL09__intro_to_sage.sws</a> worksheet.)</span></p>
<h1 style="text-align: center;">Sage Days 20.5 - Tutorial I</h1>
<h1 style="text-align: center;"><span style="font-size: large;">Franco Saliola<br /></span></h1>
<p style="text-align: center;"><img src="sage.png" alt="" width="252" height="70" /></p>

{{{id=4|

///
}}}

<h2 style="text-align: center;">Entering, Editing, and Evaluating Input</h2>
<p>To <strong>evaluate code</strong> in <em>the Sage Notebook</em> type the code into an input cell and press <strong>shift-enter</strong> or click the <span style="color: #0000ff;"><span style="text-decoration: underline;">evaluate</span></span> link.&nbsp; Try it now with a simple expression (e.g., <strong>2 + 2</strong>).&nbsp;&nbsp; The first time you evaluate cell takes longer than subsequent times since a process starts.</p>

{{{id=2|

///
}}}

{{{id=7|

///
}}}

<p>Create new <strong>input cells</strong> by clicking on the blue line that appears between cells when you move your mouse around.&nbsp; Try it now.</p>

{{{id=10|

///
}}}

{{{id=12|

///
}}}

<p>You can <strong>go back </strong>and edit any cell by clicking in it (or using the keyboard to move up or down).&nbsp; Go back and change your 2+2 above to 3 + 3 and re-evaluate it.</p>

{{{id=9|

///
}}}

{{{id=8|

///
}}}

<p>You can also <strong>edit this text</strong> right here by double clicking on it, which will bring up the TinyMCE Javascript text editor.&nbsp; You can even put embedded mathematics like this $\sin(x) - y^3$ just like with LaTeX.</p>

{{{id=54|

///
}}}

{{{id=17|

///
}}}

<p>You can also easily make <em><strong>interactive widgets</strong></em> as illustrated below.&nbsp; Try clicking on the sliders to illustrate multiplication below.&nbsp;&nbsp; Also, you can try changing the slider ranges to something different by editing the input cell (make sure to also change xmax,ymax).</p>

{{{id=50|
@interact
def f(n=(1..15), m=(1..15)):
    print "n * m =", n*m, " =", factor(n*m)
    P = polygon([(0,0),(0,n),(m,n),(m,0)])
    P.show(aspect_ratio=1, gridlines='minor',figsize=[3,3],xmax=14,ymax=14)
///
}}}

{{{id=52|

///
}}}

<p>If you <strong>mess everything up</strong>, click on Action -&gt; Restart Worksheet at the top of the screen to reset all the variable names and restart everything.&nbsp; You can also click "Undo" in the upper right to revert the worksheet to a previously saved state.</p>

{{{id=51|

///
}}}

{{{id=16|

///
}}}

<p>Click the <span style="text-decoration: underline;"><span style="color: #0000ff;">Log</span></span> link at the top of this page to view a log of recent computations!</p>

{{{id=56|

///
}}}

{{{id=55|

///
}}}

<h2 style="text-align: center;">How to Get Context-Sensitive Help and Search the Documentation<br /></h2>
<p>You find out <strong>what functions</strong> you can call on an object X by typing <strong>X.&lt;tab key&gt;</strong>.</p>

{{{id=33|
X = 2009
///
}}}

<p>Type <span style="font-family: terminal,monaco;">X.</span> then press the tab key.</p>

{{{id=28|
X.
///
}}}

{{{id=40|

///
}}}

<p>Once you have selected a function, say <strong>factor, </strong>type <strong>X.factor(&lt;tab key&gt;</strong>&nbsp;or <strong>X.factor?&lt;tab key&gt;</strong>&nbsp;to <strong><em>get help and examples</em></strong> of how to use that function.&nbsp; Try this now with <strong>X.factor</strong>.</p>

{{{id=39|

///
}}}

{{{id=38|

///
}}}

<p>To get full-text searchable help and a more extensive tutorial, click the <span style="color: #0000ff;"><span style="text-decoration: underline;">Help</span></span> link in the upper right of this page, then click on <a title="Static version..." href="../../../doc/static" target="_blank">Fast Static Versions of the Documentation.</a></p>

{{{id=53|

///
}}}

{{{id=42|

///
}}}

<p>If you need <strong><em>live</em></strong> help from a person, <em>"operators are standing by"</em>.&nbsp; Just click on Help above, then click on "<a title="IRC" href="http://www.sagemath.org/help-irc.html" target="_blank">Help via Internet Chat (IRC)</a>". This brings you to the Sage chat room where you can often get help.</p>

{{{id=44|

///
}}}

{{{id=36|

///
}}}