tutorial-notebook-and-help
system:sage


Tutorial: Using the notebook and navigating the help system -- Thematic Tutorials v4.8
system:sage

<div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index" accesskey="I">index</a></li>
  
    
      <a href="../index.html"><img src="_static/sagelogo.png" style="vertical-align: middle" title="Sage Logo"></a>
    
  
  
        <li><a href="index.html">Thematic Tutorials v4.8</a> &raquo;</li>
 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="tutorial-using-the-notebook-and-navigating-the-help-system">
<span id="tutorial-notebook-and-help"></span><h1>Tutorial: Using the notebook and navigating the help system<a class="headerlink" href="#tutorial-using-the-notebook-and-navigating-the-help-system" title="Permalink to this headline">¶</a></h1>
<p>This worksheet is based on William Stein&#8217;s <a class="reference external" href="http://modular.math.washington.edu/talks/20090701-sage_graphics_tutorial/JPL09___intro_to_sage.sws">JPL09__intro_to_sage.sws</a>
worksheet.</p>
<div class="section" id="making-this-help-page-into-a-worksheet">
<h2>Making this help page into a worksheet<a class="headerlink" href="#making-this-help-page-into-a-worksheet" title="Permalink to this headline">¶</a></h2>
<p>Go into the <tt class="docutils literal"><span class="pre">File</span></tt> menu, and click on <tt class="docutils literal"><span class="pre">Copy</span> <span class="pre">worksheet</span></tt></p>
</div>
<div class="section" id="entering-editing-and-evaluating-input">
<h2>Entering, Editing, and Evaluating Input<a class="headerlink" href="#entering-editing-and-evaluating-input" title="Permalink to this headline">¶</a></h2>
<p>To <em>evaluate code</em> in the Sage Notebook, type the code into an input
cell and press <tt class="docutils literal"><span class="pre">shift-enter</span></tt> or click the <tt class="docutils literal"><span class="pre">evaluate</span></tt> link. Try
it now with a simple expression (e.g., <img class="math" src="_images/math/2da3a5ecd44fdb54a9a30c87a48a5b1638c139b0.png" alt="2 + 2">). The first time you
evaluate a cell takes longer than subsequent times since a new Sage
process is started:</p>
<div class="highlight-python">

{{{id=0|
# edit here
///
}}}

</div>
<p>Create new <em>input cells</em> by clicking on the blue line that appears
between cells when you move your mouse around. Try it now:</p>
<div class="highlight-python">

{{{id=1|
# edit here
///
}}}

</div>
<p>You can <em>go back</em> and edit any cell by clicking in it (or using the
keyboard to move up or down). Go back and change your 2+2 above to 3 +
3 and re-evaluate it.</p>
<p>You can also <em>edit this text</em> right here by double clicking on it,
which will bring up the TinyMCE Javascript text editor.  You can even
put embedded mathematics like this $sin(x) - y^3$ just like with
LaTeX.</p>
<p>You can also easily make <em>interactive widgets</em> as illustrated
below. Try clicking on the sliders to illustrate multiplication
below. Also, you can try changing the slider ranges to something
different by editing the input cell (make sure to also change
xmax,ymax):</p>
<div class="highlight-python">

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

</div>
<p>If you <em>mess everything up</em>, click on Action -&amp;gt; Restart Worksheet
at the top of the screen to reset all the variable names and restart
everything. You can also click &#8220;Undo&#8221; in the upper right to revert the
worksheet to a previously saved state.</p>
<p>Click the <tt class="docutils literal"><span class="pre">Log</span></tt> link at the top of this page to view a log of
recent computations!</p>
</div>
<div class="section" id="how-to-get-context-sensitive-help-and-search-the-documentation">
<h2>How to Get Context-Sensitive Help and Search the Documentation<a class="headerlink" href="#how-to-get-context-sensitive-help-and-search-the-documentation" title="Permalink to this headline">¶</a></h2>
<p>You find out <em>what functions</em> you can call on an object X by typing <tt class="docutils literal"><span class="pre">X.&lt;tab</span> <span class="pre">key&gt;</span></tt>:</p>
<div class="highlight-python">

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

</div>
<p>Now type <tt class="docutils literal"><span class="pre">X.</span></tt> then press the tab key:</p>
<div class="highlight-python">

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

</div>
<p>Once you have selected a function, say <tt class="docutils literal"><span class="pre">factor</span></tt>, type
<tt class="docutils literal"><span class="pre">X.factor(&lt;tab</span> <span class="pre">key&gt;</span></tt> or <tt class="docutils literal"><span class="pre">X.factor?</span></tt> to get help and examples
of how to use that function. Try this now:</p>
<div class="highlight-python">

{{{id=5|
# edit here
///
}}}

</div>
<p>To get full-text searchable help and a more extensive tutorial, click
the <tt class="docutils literal"><span class="pre">Help</span></tt> link in the upper right of this page. The help pages
are dynamic, and you can play with their examples. You can also access
the <a class="reference external" href="http:../../../../doc/static">Fast Static Versions of the Documentation</a>.</p>
<p>If you are ready, you can now go to ``</p>
<p>If you need <em>live</em> help from a person, just click on Help above, then
click on <a class="reference external" href="http://www.sagemath.org/help-irc.html/">Help via Internet Chat (IRC)</a>. This brings you to the
Sage chat room where you can often get help.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference internal" href="#">Tutorial: Using the notebook and navigating the help system</a><ul>
<li><a class="reference internal" href="#making-this-help-page-into-a-worksheet">Making this help page into a worksheet</a></li>
<li><a class="reference internal" href="#entering-editing-and-evaluating-input">Entering, Editing, and Evaluating Input</a></li>
<li><a class="reference internal" href="#how-to-get-context-sensitive-help-and-search-the-documentation">How to Get Context-Sensitive Help and Search the Documentation</a></li>
</ul>
</li>
</ul>

            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/tutorial-notebook-and-help.txt" rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index">index</a></li>
  
    
      <a href="../index.html"><img src="_static/sagelogo.png" style="vertical-align: middle" title="Sage Logo"></a>
    
  
  
        <li><a href="index.html">Thematic Tutorials v4.8</a> &raquo;</li>
 
      </ul>
    </div>
    
    <div class="footer">
        &copy; Copyright 2005--2011, The Sage Development Team.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
    </div>
    <script type="text/javascript">
/*global jQuery, window */
/* Sphinx sidebar toggle.  Putting this code at the end of the body
 * enables the toggle for the live, static, and offline docs.  Note:
 * sage.misc.html.math_parse() eats jQuery's dollar-sign shortcut. */
var jq = jQuery;  
jq(document).ready(function () {
    var bar, bod, bg, fg, key, tog, wid_old, wid_new, resize, get_state, set_state;
    bod = jq('div.bodywrapper');
    bar = jq('div.sphinxsidebar');
    tog = jq('<div class="sphinxsidebartoggle"></div>');
    
    /* Delayed resize helper.  Not perfect but good enough. */
    resize = function () {
        setTimeout(function () {
            tog.height(bod.height());
        }, 100);
    };
    jq(window).resize(function () {
        resize();
    });
    
    /* Setup and add the toggle. See Sphinx v0.5.1 default.css. */
    fg = jq('div.sphinxsidebar p a').css('color') || 'rgb(152, 219, 204)';
    bg = jq('div.document').css('background-color') || 'rgb(28, 78, 99)';
    wid_old = '230px';
    wid_new = '5px';
    tog.css('background-color', bg)
        .css('border-width', '0px')
        .css('border-right', wid_new + ' ridge ' + bg)
        .css('cursor', 'pointer')
        .css('position', 'absolute')
        .css('left', '-' + wid_new)
        .css('top', '0px')
        .css('width', wid_new);
    bod.css('position', 'relative');
    bod.prepend(tog);
    resize();
    
    /* Cookie helpers. */
    key = 'sphinxsidebar=';
    set_state = function (s) {
        var date = new Date();
        /* Expiry in 7 days. */
        date.setTime(date.getTime() + (7 * 24 * 3600 * 1000));
        document.cookie = key + encodeURIComponent(s) + '; expires=' +
            date.toUTCString() + '; path=/';
    };
    get_state = function () {
        var i, c, crumbs = document.cookie.split(';');
        for (i = 0; i < crumbs.length; i += 1) {
            c = crumbs[i].replace(/^\s+/, '');
            if (c.indexOf(key) === 0) {
                return decodeURIComponent(c.substring(key.length, c.length));
            }
        }
        return null;
    };
    
    /* Event handlers. */
    tog.mouseover(function (ev) {
        tog.css('border-right-color', fg);
    }).mouseout(function (ev) {
        tog.css('border-right-color', bg);
    }).click(function (ev) {
        if (bod.hasClass('wide')) {
            bod.removeClass('wide');
            bod.css('margin-left', wid_old);
            bar.css('width', wid_old);
            bar.show();
            set_state('visible');
        } else {
            set_state('hidden');
            bar.hide();
            bar.css('width', '0px');
            bod.css('margin-left', wid_new);
            bod.addClass('wide');
        }
        resize();
    });
    
    /* Hide the normally visible sidebar? */
    if (get_state() === 'hidden') {
        tog.trigger('click');
    } else {
        set_state('visible');
    }
});
    </script>