[genius] Fri Oct 10 17:16:38 2014 Jiri (George) Lebl <jirka 5z com>



commit 59cd88f4285fa2afc64175d86a57b840abe485fc
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date:   Fri Oct 10 17:17:05 2014 -0500

    Fri Oct 10 17:16:38 2014  Jiri (George) Lebl <jirka 5z com>
    
        * src/funclib.c: min/max now check their arguments better, especially
          if argument is a single element.
    
        * src/geniustests.txt: Add a bunch of tests to the suite
    
        * help/C/genius.xml: A bunch of updates to the manual

 ChangeLog           |    9 +
 NEWS                |   11 +
 help/C/genius.xml   |  116 +++++---
 help/genius.txt     |  787 +++++++++++++++++++++++++++------------------------
 src/funclib.c       |   19 ++
 src/geniustests.txt |   28 ++
 6 files changed, 554 insertions(+), 416 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ec15a8a..e1844bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Fri Oct 10 17:16:38 2014  Jiri (George) Lebl <jirka 5z com>
+
+       * src/funclib.c: min/max now check their arguments better, especially
+         if argument is a single element.
+
+       * src/geniustests.txt: Add a bunch of tests to the suite
+
+       * help/C/genius.xml: A bunch of updates to the manual
+
 Fri Oct 10 16:05:24 2014  Jiri (George) Lebl <jirka 5z com>
 
        * lib/calculus/fourier.gel: Fix PeriodicExtension
diff --git a/NEWS b/NEWS
index 5a32fd7..80cd06e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,14 @@
+Changes to 1.0.20
+
+* Add more sizes of icons including SVG, and add Keywords to the .desktop file
+* Documentation updates
+* Fix PeriodicExtension function
+* A couple of minor fixes in the plotting code including one possible crasher
+* Translation updates (FIXME)
+
+* During making of these changes the author (Jiri) was partially supported by
+  NSF grant DMS 1362337 and the Oklahoma State University
+
 Changes to 1.0.19
 
 * New menu: Examples.  These are annotated programs that show some
diff --git a/help/C/genius.xml b/help/C/genius.xml
index 8a2bfe3..da48807 100644
--- a/help/C/genius.xml
+++ b/help/C/genius.xml
@@ -192,7 +192,7 @@
     </para> 
 
     <para>
-       This manual describes mostly the graphical version of the calculator,
+           Parts of this manual describe the graphical version of the calculator,
        but the language is of course the same.  The command line only version
        lacks the graphing capabilities and all other capabilities that require
        the graphical user interface.
@@ -347,7 +347,9 @@ while a long calculation is running, or to debug a certain program.
            </para>
            <para>
                Alternatively you can write longer programs and those can
-               appear in separate tabs and can be stored in files for later
+               appear in separate tabs.  The programs are a set of commands or
+               functions that can be run all at once rather than entering them
+               at the command line.  The programs can be saved in files for later
                retrieval.
            </para>
           </listitem>
@@ -417,12 +419,18 @@ do <userinput>cd directory</userinput> as in the UNIX command shell.
     <sect1 id="genius-usage-create-program"> 
       <title>To Create a New Program </title> 
       <para>
+             If you wish to enter several more complicated commands, or perhaps write a complicated
+             function using the <link linkend="genius-gel">GEL</link> language.  You can create a new
+            program.
+      </para>
+      <para>
 To start writing a new program, choose
 <menuchoice><guimenu>File</guimenu><guimenuitem>New
 Program</guimenuitem></menuchoice>. A new tab will appear in the work area. You
 can write a <link linkend="genius-gel">GEL</link> program in this work area.
 Once you have written your program you can run it by 
-<menuchoice><guimenu>Calculator</guimenu><guimenuitem>Run</guimenuitem></menuchoice>.
+<menuchoice><guimenu>Calculator</guimenu><guimenuitem>Run</guimenuitem></menuchoice> (or
+the <guilabel>Run</guilabel> toolbar button).
 This will execute your program and will display any output on the <guilabel>Console</guilabel> tab.
 Executing a program is equivalent of taking the text of the program and
 typing it into the console.  The only difference is that this input is done
@@ -433,7 +441,16 @@ tab.  The currently selected program has its tab in bold type.  To select a
 program, just click on its tab.
       </para>
       <para>
-To save the program you've just written, choose <menuchoice><guimenu>File</guimenu><guimenuitem>Save 
As...</guimenuitem></menuchoice>
+To save the program you've just written, choose <menuchoice><guimenu>File</guimenu><guimenuitem>Save 
As...</guimenuitem></menuchoice>.
+Similarly as in other programs you can choose
+<menuchoice><guimenu>File</guimenu><guimenuitem>Save</guimenuitem></menuchoice> to save a program that 
already has
+a filename attached to it.  If you have many opened programs you have edited and wish to save you can also 
choose
+<menuchoice><guimenu>File</guimenu><guimenuitem>Save All Unsaved</guimenuitem></menuchoice>.
+      </para>
+      <para>
+             Programs that have unsaved changes will have a "[+]" next to their filename.  This way you can 
see if the file
+             on disk and the currently opened tab differ in content.  Programs which have not yet had a 
filename associated
+             with them are always considered unsaved and no "[+]" is printed.
       </para>
     </sect1>
 
@@ -451,6 +468,12 @@ To run a program from a file, choose
 Run...</guimenuitem></menuchoice>.  This will run the program without opening it
 in a separate tab.  This is equivalent to the <command>load</command> command.
       </para>
+      <para>
+             If you have made edits to a file you wish to throw away and want to reload to the version 
that's on disk,
+             you can choose the
+             <menuchoice><guimenu>File</guimenu><guimenuitem>Reload from Disk</guimenuitem></menuchoice> 
menuitem.  This is useful for experimenting
+             with a program and making temporary edits, to run a program, but that you do not intend to keep.
+      </para>
     </sect1>
 
   </chapter>
@@ -1118,28 +1141,16 @@ Not all functions can be used in this way.  For example, when you use a binary o
 
     </sect1>
 
-    <sect1 id="genius-gel-absolute-value-modulus">
-      <title>Absolute Value / Modulus</title>
-      <para>
-You can make an absolute value of something by putting the
-<literal>|</literal>'s around it.  For example:
-<programlisting>|a-b|</programlisting>
-</para>
-<para>
-In case the expression is a complex number the result will be the modulus
-(distance from the origin).  For example:
-<userinput>|3 * e^(1i*pi)|</userinput>
-returns 3.
-      </para>
-    </sect1>
-
     <sect1 id="genius-gel-separator">
       <title>Separator</title>
       <para>
-In GEL if you want to type more than one command you have to use
-the <literal>;</literal> operator, which is a way to separate expressions,
-such a combined expression will return whatever is the result of the last
-one, so suppose you type the following:
+             GEL is somewhat different from other languages in how it deals with multiple commands and 
functions.
+             In GEL you must chain commands together with a separator operator.
+That is, if you want to type more than one expression you have to use
+the <literal>;</literal> operator in between the expressions.   This is
+a way in which both expressions are evaluated and the result of the second one (or the last one
+if there is more than two expressions) is returned.
+Suppose you type the following:
 <programlisting>3 ; 5
 </programlisting>
 This expression will yield 5.
@@ -1150,13 +1161,18 @@ especially if the <literal>;</literal> is not the top most primitive. This sligh
 other programming languages where the <literal>;</literal> is a terminator of statements, whereas
 in GEL it&rsquo;s actually a binary operator. If you are familiar with pascal
 this should be second nature. However genius can let you pretend it is a
-terminator somewhat, if a <literal>;</literal> is found at the end of a parenthesis or a block,
-genius will itself append a null node to it as if you would have written
+terminator to some degree.  If a <literal>;</literal> is found at the end of a parenthesis or a block,
+genius will append a null to it as if you would have written
 <userinput>;null</userinput>.
 This is useful in case you do not want to return a value from say a loop,
 or if you handle the return differently. Note that it will slightly slow down
 the code if it is executed too often as there is one more operator involved.
       </para>
+      <para>
+             If you are typing expressions in a program you do not have to add a semicolon.  In this case
+             genius will simply print the return value whenever it executes the expression.  However, do 
note that if you are defining a
+             function, the body of the function is a single expression.
+      </para>
     </sect1>
 
     <sect1 id="genius-gel-comments">
@@ -1179,7 +1195,7 @@ x=123;
              &appname; implements modular arithmetic.
 To use it you just add "mod &lt;integer&gt;" after
 the expression.  Example:
-<programlisting>2^(5!) * 3^(6!) mod 5</programlisting>
+<userinput>2^(5!) * 3^(6!) mod 5</userinput>
 It could be possible to do modular arithmetic by computing with integers and then modding in the end with
 the <literal>%</literal> operator, which simply gives the remainder, but
 that may be time consuming if not impossible when working with larger numbers.
@@ -1285,9 +1301,12 @@ different from <literal>=</literal> because it never gets translated to a
          <term><userinput>|a|</userinput></term>
          <listitem>
            <para>
-             Absolute value or modulus (if <varname>a</varname>
-            is a complex number).
-           </para>
+                  Absolute value.
+                  In case the expression is a complex number the result will be the modulus
+(distance from the origin).  For example:
+<userinput>|3 * e^(1i*pi)|</userinput>
+returns 3.
+         </para>
           <para>
            See
            <ulink url="http://mathworld.wolfram.com/AbsoluteValue.html";>Mathworld</ulink> for more 
information.
@@ -3017,7 +3036,7 @@ and this builtin function makes it possible to make GEL functions aware of modul
          <term><anchor id="gel-function-Identity"/>Identity</term>
          <listitem>
           <synopsis>Identity (x)</synopsis>
-          <para>Identity function, returns its argument.</para>
+         <para>Identity function, returns its argument.  It is equivalent to <userinput>function 
Identity(x)=x</userinput>.</para>
          </listitem>
         </varlistentry>
 
@@ -3796,6 +3815,7 @@ vectorfield plot.  (See <link linkend="gel-function-VectorfieldPlot"><function>V
          </para>
           <para>
            See
+           <ulink url="http://en.wikipedia.org/wiki/Catalan%27s_constant";>Wikipedia</ulink>, or
            <ulink url="http://mathworld.wolfram.com/CatalansConstant.html";>Mathworld</ulink> for more 
information.
          </para>
          </listitem>
@@ -3807,7 +3827,7 @@ vectorfield plot.  (See <link linkend="gel-function-VectorfieldPlot"><function>V
           <synopsis>EulerConstant</synopsis>
           <para>Aliases: <function>gamma</function></para>
           <para>
-           Euler's Constant gamma.  Sometimes called the
+           Euler's constant gamma.  Sometimes called the
            Euler-Mascheroni constant.
          </para>
           <para>
@@ -3837,7 +3857,9 @@ vectorfield plot.  (See <link linkend="gel-function-VectorfieldPlot"><function>V
          <term><anchor id="gel-function-Gravity"/>Gravity</term>
          <listitem>
           <synopsis>Gravity</synopsis>
-          <para>Free fall acceleration at sea level.</para>
+         <para>Free fall acceleration at sea level in meters per second squared.  This is the standard 
gravity constant 9.80665.  The gravity
+                 in your particular neck of the woods might be different due to different altitude and the 
fact that the earth is not perfectly
+                 round and uniform.</para>
           <para>
            See
            <ulink url="http://en.wikipedia.org/wiki/Standard_gravity";>Wikipedia</ulink> for more information.
@@ -3852,8 +3874,9 @@ vectorfield plot.  (See <link linkend="gel-function-VectorfieldPlot"><function>V
           <para>
            The base of the natural logarithm.  <userinput>e^x</userinput>
            is the exponential function
-           <link linkend="gel-function-exp"><function>exp</function></link>.  This is the
-           number approximately 2.71828182846...
+           <link linkend="gel-function-exp"><function>exp</function></link>.  It is approximately
+           2.71828182846...  This number is sometimes called Euler's number, although there are
+           several numbers that are also called Euler's.  An example is the gamma constant: <link 
linkend="gel-function-EulerConstant"><function>EulerConstant</function></link>.
          </para>
           <para>
            See
@@ -3895,7 +3918,8 @@ vectorfield plot.  (See <link linkend="gel-function-VectorfieldPlot"><function>V
           <para>
            Absolute value of a number and if <varname>x</varname> is
            a complex value the modulus of <varname>x</varname>.  I.e. this
-           the distance of <varname>x</varname> to the origin.
+           the distance of <varname>x</varname> to the origin.  This is equivalent
+           to <userinput>|x|</userinput>.
          </para>
           <para>
            See
@@ -3960,7 +3984,7 @@ all its elements are conjugated.</para>
          <listitem>
           <synopsis>Im (z)</synopsis>
           <para>Aliases: <function>ImaginaryPart</function></para>
-          <para>Get the imaginary part of a complex number.</para>
+          <para>Get the imaginary part of a complex number.  For example <userinput>Re(3+4i)</userinput> 
yields 4.</para>
           <para>
            See
            <ulink url="http://en.wikipedia.org/wiki/Imaginary_part";>Wikipedia</ulink> for more information.
@@ -3980,7 +4004,9 @@ all its elements are conjugated.</para>
          <term><anchor id="gel-function-IsComplex"/>IsComplex</term>
          <listitem>
           <synopsis>IsComplex (num)</synopsis>
-          <para>Check if argument is a complex (non-real) number.</para>
+         <para>Check if argument is a complex (non-real) number.  Do note that we really mean nonreal 
number.  That is,
+         <userinput>IsComplex(3)</userinput> yields false, while
+         <userinput>IsComplex(3-1i)</userinput> yields true.</para>
          </listitem>
         </varlistentry>
 
@@ -3997,7 +4023,7 @@ all its elements are conjugated.</para>
          <term><anchor id="gel-function-IsFloat"/>IsFloat</term>
          <listitem>
           <synopsis>IsFloat (num)</synopsis>
-          <para>Check if argument is a floating point number (non-complex).</para>
+          <para>Check if argument is a real floating point number (non-complex).</para>
          </listitem>
         </varlistentry>
 
@@ -4006,7 +4032,9 @@ all its elements are conjugated.</para>
          <listitem>
           <synopsis>IsGaussInteger (num)</synopsis>
           <para>Aliases: <function>IsComplexInteger</function></para>
-          <para>Check if argument is a possibly complex integer.</para>
+         <para>Check if argument is a possibly complex integer.  That is a complex integer is a number of
+                 the form <userinput>n+1i*m</userinput> where <varname>n</varname> and <varname>m</varname>
+         are integers.</para>
          </listitem>
         </varlistentry>
 
@@ -4022,7 +4050,7 @@ all its elements are conjugated.</para>
          <term><anchor id="gel-function-IsNonNegativeInteger"/>IsNonNegativeInteger</term>
          <listitem>
           <synopsis>IsNonNegativeInteger (num)</synopsis>
-          <para>Check if argument is a non-negative real integer.</para>
+          <para>Check if argument is a non-negative real integer.  That is, either a positive integer or 
zero.</para>
          </listitem>
         </varlistentry>
 
@@ -4069,7 +4097,7 @@ we accept the convention that 0 is not a natural number.</para>
          <listitem>
           <synopsis>Re (z)</synopsis>
           <para>Aliases: <function>RealPart</function></para>
-          <para>Get the real part of a complex number.</para>
+         <para>Get the real part of a complex number.  For example <userinput>Re(3+4i)</userinput> yields 
3.</para>
           <para>
            See
            <ulink url="http://en.wikipedia.org/wiki/Real_part";>Wikipedia</ulink> for more information.
@@ -4155,6 +4183,12 @@ value then <function>Sign</function> returns the direction or 0.
          <listitem>
           <synopsis>ln (x)</synopsis>
           <para>The natural logarithm, the logarithm to base <varname>e</varname>.</para>
+          <para>
+           See
+           <ulink url="http://en.wikipedia.org/wiki/Natural_logarithm";>Wikipedia</ulink> or
+           <ulink url="http://planetmath.org/encyclopedia/LogarithmFunction.html";>Planetmath</ulink> or
+           <ulink url="http://mathworld.wolfram.com/NaturalLogarithm.html";>Mathworld</ulink> for more 
information.
+         </para>
          </listitem>
         </varlistentry>
 
diff --git a/help/genius.txt b/help/genius.txt
index d96974e..261a1d8 100644
--- a/help/genius.txt
+++ b/help/genius.txt
@@ -1,6 +1,6 @@
 Genius Manual
 
-Jiří Lebl
+Jiř Lebl
 
    Oklahoma State University
 
@@ -12,10 +12,12 @@ Kai Willadsen
 
     <kaiw itee uq edu au>
 
-   Copyright © 1997-2014 Jiří (George) Lebl
+   Copyright © 1997-2014 Jiř (George) Lebl
 
    Copyright © 2004 Kai Willadsen
 
+   Manual for the Genius Math Tool.
+
    Permission is granted to copy, distribute and/or modify this
    document under the terms of the GNU Free Documentation License
    (GFDL), Version 1.1 or any later version published by the Free
@@ -75,134 +77,140 @@ Kai Willadsen
    To report a bug or make a suggestion regarding the Genius
    Mathematics Tool application or this manual, please visit the
    Genius Web page or email me at <jirka 5z com>.
-   This manual describes version 1.0.20 of Genius.
      __________________________________________________________
 
    Table of Contents
-   Introduction
-   Getting Started
-
-        To Start Genius Mathematics Tool
-        When You Start Genius
-
-   Basic Usage
-
-        Using the Work Area
-        To Create a New Program
-        To Open and Run a Program
-
-   Plotting
-
-        Line Plots
-        Parametric Plots
-        Slopefield Plots
-        Vectorfield Plots
-        Surface Plots
-
-   GEL Basics
-
-        Values
-
-              Numbers
-              Booleans
-              Strings
-              Null
-
-        Using Variables
-
-              Setting Variables
-              Built-in Variables
-              Previous Result Variable
-
-        Using Functions
+   1. Introduction
+   2. Getting Started
 
-              Defining Functions
-              Variable Argument Lists
-              Passing Functions to Functions
-              Operations on Functions
+        2.1. To Start Genius Mathematics Tool
+        2.2. When You Start Genius
 
-        Absolute Value / Modulus
-        Separator
-        Comments
-        Modular Evaluation
-        List of GEL Operators
+   3. Basic Usage
 
-   Programming with GEL
+        3.1. Using the Work Area
+        3.2. To Create a New Program
+        3.3. To Open and Run a Program
 
-        Conditionals
-        Loops
+   4. Plotting
 
-              While Loops
-              For Loops
-              Foreach Loops
-              Break and Continue
+        4.1. Line Plots
+        4.2. Parametric Plots
+        4.3. Slopefield Plots
+        4.4. Vectorfield Plots
+        4.5. Surface Plots
 
-        Sums and Products
-        Comparison Operators
-        Global Variables and Scope of Variables
-        Parameter variables
-        Returning
-        References
-        Lvalues
+   5. GEL Basics
 
-   Advanced Programming with GEL
+        5.1. Values
 
-        Error Handling
-        Toplevel Syntax
-        Returning Functions
-        True Local Variables
-        GEL Startup Procedure
-        Loading Programs
-
-   Matrices in GEL
-
-        Entering Matrices
-        Conjugate Transpose and Transpose Operator
-        Linear Algebra
-
-   Polynomials in GEL
-
-        Using Polynomials
-
-   Set Theory in GEL
-
-        Using Sets
-
-   List of GEL functions
-
-        Commands
-        Basic
-        Parameters
-        Constants
-        Numeric
-        Trigonometry
-        Number Theory
-        Matrix Manipulation
-        Linear Algebra
-        Combinatorics
-        Calculus
-        Functions
-        Equation Solving
-        Statistics
-        Polynomials
-        Set Theory
-        Commutative Algebra
-        Miscellaneous
-        Symbolic Operations
-        Plotting
-
-   Example Programs in GEL
-   Settings
-
-        Output
-        Precision
-        Terminal
-        Memory
-
-   About Genius Mathematics Tool
+              5.1.1. Numbers
+              5.1.2. Booleans
+              5.1.3. Strings
+              5.1.4. Null
+
+        5.2. Using Variables
+
+              5.2.1. Setting Variables
+              5.2.2. Built-in Variables
+              5.2.3. Previous Result Variable
+
+        5.3. Using Functions
+
+              5.3.1. Defining Functions
+              5.3.2. Variable Argument Lists
+              5.3.3. Passing Functions to Functions
+              5.3.4. Operations on Functions
+
+        5.4. Separator
+        5.5. Comments
+        5.6. Modular Evaluation
+        5.7. List of GEL Operators
+
+   6. Programming with GEL
+
+        6.1. Conditionals
+        6.2. Loops
+
+              6.2.1. While Loops
+              6.2.2. For Loops
+              6.2.3. Foreach Loops
+              6.2.4. Break and Continue
+
+        6.3. Sums and Products
+        6.4. Comparison Operators
+        6.5. Global Variables and Scope of Variables
+        6.6. Parameter variables
+        6.7. Returning
+        6.8. References
+        6.9. Lvalues
+
+   7. Advanced Programming with GEL
+
+        7.1. Error Handling
+        7.2. Toplevel Syntax
+        7.3. Returning Functions
+        7.4. True Local Variables
+        7.5. GEL Startup Procedure
+        7.6. Loading Programs
+
+   8. Matrices in GEL
+
+        8.1. Entering Matrices
+        8.2. Conjugate Transpose and Transpose Operator
+        8.3. Linear Algebra
+
+   9. Polynomials in GEL
+
+        9.1. Using Polynomials
+
+   10. Set Theory in GEL
+
+        10.1. Using Sets
+
+   11. List of GEL functions
+
+        11.1. Commands
+        11.2. Basic
+        11.3. Parameters
+        11.4. Constants
+        11.5. Numeric
+        11.6. Trigonometry
+        11.7. Number Theory
+        11.8. Matrix Manipulation
+        11.9. Linear Algebra
+        11.10. Combinatorics
+        11.11. Calculus
+        11.12. Functions
+        11.13. Equation Solving
+        11.14. Statistics
+        11.15. Polynomials
+        11.16. Set Theory
+        11.17. Commutative Algebra
+        11.18. Miscellaneous
+        11.19. Symbolic Operations
+        11.20. Plotting
+
+   12. Example Programs in GEL
+   13. Settings
+
+        13.1. Output
+        13.2. Precision
+        13.3. Terminal
+        13.4. Memory
+
+   14. About Genius Mathematics Tool
+
+   List of Figures
+   2-1. Genius Mathematics Tool Window
+   4-1. Create Plot Window
+   4-2. Plot Window
+   4-3. Parametric Plot Tab
+   4-4. Parametric Plot
+   4-5. Surface Plot
      __________________________________________________________
 
-Introduction
+Chapter 1. Introduction
 
    The Genius Mathematics Tool application is a general calculator
    for use as a desktop calculator, an educational tool in
@@ -224,7 +232,7 @@ Introduction
    of course does not implement any feature that requires the
    graphical interface.
 
-   This manual describes mostly the graphical version of the
+   Parts of this manual describe the graphical version of the
    calculator, but the language is of course the same. The command
    line only version lacks the graphing capabilities and all other
    capabilities that require the graphical user interface.
@@ -235,9 +243,9 @@ Introduction
    file.
      __________________________________________________________
 
-Getting Started
+Chapter 2. Getting Started
 
-To Start Genius Mathematics Tool
+2.1. To Start Genius Mathematics Tool
 
    You can start Genius Mathematics Tool in the following ways:
 
@@ -266,14 +274,14 @@ To Start Genius Mathematics Tool
           plotting will not be available.
      __________________________________________________________
 
-When You Start Genius
+2.2. When You Start Genius
 
    When you start the GNOME edition of Genius Mathematics Tool,
-   the window pictured in Figure 1 is displayed.
+   the window pictured in Figure 2-1 is displayed.
 
-   [genius_window.png]
+   Figure 2-1. Genius Mathematics Tool Window
 
-   Figure 1. Genius Mathematics Tool Window
+   [genius_window.png]
 
    The Genius Mathematics Tool window contains the following
    elements:
@@ -326,13 +334,15 @@ When You Start Genius
           are immediately returned after you hit the Enter key.
 
           Alternatively you can write longer programs and those
-          can appear in separate tabs and can be stored in files
-          for later retrieval.
+          can appear in separate tabs. The programs are a set of
+          commands or functions that can be run all at once rather
+          than entering them at the command line. The programs can
+          be saved in files for later retrieval.
      __________________________________________________________
 
-Basic Usage
+Chapter 3. Basic Usage
 
-Using the Work Area
+3.1. Using the Work Area
 
    Normally you interact with the calculator in the Console tab of
    the work area. If you are running the text only version then
@@ -377,26 +387,40 @@ genius> load path/to/program.gel
    directory do cd directory as in the UNIX command shell.
      __________________________________________________________
 
-To Create a New Program
+3.2. To Create a New Program
+
+   If you wish to enter several more complicated commands, or
+   perhaps write a complicated function using the GEL language.
+   You can create a new program.
 
    To start writing a new program, choose File->New Program. A new
    tab will appear in the work area. You can write a GEL program
    in this work area. Once you have written your program you can
-   run it by Calculator->Run. This will execute your program and
-   will display any output on the Console tab. Executing a program
-   is equivalent of taking the text of the program and typing it
-   into the console. The only difference is that this input is
-   done independent of the console and just the output goes onto
-   the console. Calculator->Run will always run the currently
-   selected program even if you are on the Console tab. The
-   currently selected program has its tab in bold type. To select
-   a program, just click on its tab.
+   run it by Calculator->Run (or the Run toolbar button). This
+   will execute your program and will display any output on the
+   Console tab. Executing a program is equivalent of taking the
+   text of the program and typing it into the console. The only
+   difference is that this input is done independent of the
+   console and just the output goes onto the console.
+   Calculator->Run will always run the currently selected program
+   even if you are on the Console tab. The currently selected
+   program has its tab in bold type. To select a program, just
+   click on its tab.
 
    To save the program you've just written, choose File->Save
-   As...
+   As.... Similarly as in other programs you can choose File->Save
+   to save a program that already has a filename attached to it.
+   If you have many opened programs you have edited and wish to
+   save you can also choose File->Save All Unsaved.
+
+   Programs that have unsaved changes will have a "[+]" next to
+   their filename. This way you can see if the file on disk and
+   the currently opened tab differ in content. Programs which have
+   not yet had a filename associated with them are always
+   considered unsaved and no "[+]" is printed.
      __________________________________________________________
 
-To Open and Run a Program
+3.3. To Open and Run a Program
 
    To open a file, choose File->Open. A new tab containing the
    file will appear in the work area. You can use this to edit the
@@ -405,9 +429,15 @@ To Open and Run a Program
    To run a program from a file, choose File->Load and Run....
    This will run the program without opening it in a separate tab.
    This is equivalent to the load command.
+
+   If you have made edits to a file you wish to throw away and
+   want to reload to the version that's on disk, you can choose
+   the File->Reload from Disk menuitem. This is useful for
+   experimenting with a program and making temporary edits, to run
+   a program, but that you do not intend to keep.
      __________________________________________________________
 
-Plotting
+Chapter 4. Plotting
 
    Plotting support is only available in the graphical GNOME
    version. All plotting accessible from the graphical interface
@@ -415,11 +445,11 @@ Plotting
    window by either clicking on the Plot button on the toolbar or
    selecting Plot from the Calculator menu. You can also access
    the plotting functionality by using the plotting functions of
-   the GEL language. See the Chapter called GEL Basics to find out
-   how to enter expressions that Genius understands.
+   the GEL language. See Chapter 5 to find out how to enter
+   expressions that Genius understands.
      __________________________________________________________
 
-Line Plots
+4.1. Line Plots
 
    To graph real valued functions of one variable open the Create
    Plot window. You can also use the LinePlot function on the
@@ -428,11 +458,11 @@ Line Plots
    Once you click the Plot button, a window opens up with some
    notebooks in it. You want to be in the Function line plot
    notebook tab, and inside you want to be on the Functions /
-   Expressions notebook tab. See Figure 1.
+   Expressions notebook tab. See Figure 4-1.
 
-   [line_plot.png]
+   Figure 4-1. Create Plot Window
 
-   Figure 1. Create Plot Window
+   [line_plot.png]
 
    Type expressions with x as the independent variable into the
    textboxes. Alternatively you can give names of functions such
@@ -445,7 +475,7 @@ Line Plots
    dialog. The y (dependent) range can be set automatically by
    turning on the Fit dependent axis checkbox. The names of the
    variables can also be changed. Pressing the Plot button
-   produces the graph shown in Figure 2.
+   produces the graph shown in Figure 4-2.
 
    The variables can be renamed by clicking the Change variable
    names... button, which is useful if you wish to print or save
@@ -454,9 +484,9 @@ Line Plots
    completely, which is also useful if printing or saving, when
    the legend might simply be clutter.
 
-   [line_plot_graph.png]
+   Figure 4-2. Plot Window
 
-   Figure 2. Plot Window
+   [line_plot_graph.png]
 
    From here you can print out the plot, create encapsulated
    postscript or a PNG version of the plot or change the zoom. If
@@ -467,7 +497,7 @@ Line Plots
    the LinePlot function.
      __________________________________________________________
 
-Parametric Plots
+4.2. Parametric Plots
 
    In the create plot window, you can also choose the Parametric
    notebook tab to create two dimensional parametric plots. This
@@ -477,24 +507,24 @@ Parametric Plots
    variable t is given explicitly, and the function is sampled
    according to the given increment. The x and y range can be set
    automatically by turning on the Fit dependent axis checkbox, or
-   it can be specified explicitly. See Figure 3.
+   it can be specified explicitly. See Figure 4-3.
 
-   [parametric.png]
+   Figure 4-3. Parametric Plot Tab
 
-   Figure 3. Parametric Plot Tab
+   [parametric.png]
 
-   An example of a parametric plot is given in Figure 4. Similar
+   An example of a parametric plot is given in Figure 4-4. Similar
    operations can be done on such graphs as can be done on the
    other line plots. For plotting using the command line see the
    documentation of the LinePlotParametric or LinePlotCParametric
    function.
 
-   [parametric_graph.png]
+   Figure 4-4. Parametric Plot
 
-   Figure 4. Parametric Plot
+   [parametric_graph.png]
      __________________________________________________________
 
-Slopefield Plots
+4.3. Slopefield Plots
 
    In the create plot window, you can also choose the Slope field
    notebook tab to create a two dimensional slope field plot.
@@ -520,7 +550,7 @@ Slopefield Plots
    from the command line or programs.
      __________________________________________________________
 
-Vectorfield Plots
+4.4. Vectorfield Plots
 
    In the create plot window, you can also choose the Vector field
    notebook tab to create a two dimensional vector field plot.
@@ -549,7 +579,7 @@ Vectorfield Plots
    command line or programs.
      __________________________________________________________
 
-Surface Plots
+4.5. Surface Plots
 
    Genius can also plot surfaces. Select the Surface plot tab in
    the main notebook of the Create Plot window. Here you can
@@ -558,8 +588,8 @@ Surface Plots
    is the real part of z and y is the imaginary part). For example
    to plot the modulus of the cosine function for complex
    parameters, you could enter |cos(z)|. This would be equivalent
-   to |cos(x+1i*y)|. See Figure 5. For plotting using the command
-   line see the documentation of the SurfacePlot function.
+   to |cos(x+1i*y)|. See Figure 4-5. For plotting using the
+   command line see the documentation of the SurfacePlot function.
 
    The z range can be set automatically by turning on the Fit
    dependent axis checkbox. The variables can be renamed by
@@ -569,9 +599,9 @@ Surface Plots
    legend, which is also useful if printing or saving, when the
    legend might simply be clutter.
 
-   [surface_graph.png]
+   Figure 4-5. Surface Plot
 
-   Figure 5. Surface Plot
+   [surface_graph.png]
 
    In surface mode, left and right arrow keys on your keyboard
    will rotate the view along the z axis. Alternatively you can
@@ -586,7 +616,7 @@ Surface Plots
    an audience.
      __________________________________________________________
 
-GEL Basics
+Chapter 5. GEL Basics
 
    GEL stands for Genius Extension Language. It is the language
    you use to write programs in Genius. A program in GEL is simply
@@ -597,7 +627,7 @@ GEL Basics
    possible, especially for use as a calculator.
      __________________________________________________________
 
-Values
+5.1. Values
 
    Values in GEL can be numbers, Booleans, or strings. GEL also
    treats matrices as values. Values can be used in calculations,
@@ -605,7 +635,7 @@ Values
    uses.
      __________________________________________________________
 
-Numbers
+5.1.1. Numbers
 
    Integers are the first type of number in GEL. Integers are
    written in the normal way.
@@ -658,19 +688,19 @@ Numbers
 8.01i
 77*e^(1.3i)
 
-   Important
+Important
 
-   When entering imaginary numbers, a number must be in front of
-   the i. If you use i by itself, Genius will interpret this as
-   referring to the variable i. If you need to refer to i by
-   itself, use 1i instead.
+          When entering imaginary numbers, a number must be in front of
+          the i. If you use i by itself, Genius will interpret this as
+          referring to the variable i. If you need to refer to i by
+          itself, use 1i instead.
 
-   In order to use mixed fraction notation with imaginary numbers
-   you must have the mixed fraction in parentheses. (i.e., (1
-   2/5)i)
+          In order to use mixed fraction notation with imaginary numbers
+          you must have the mixed fraction in parentheses. (i.e., (1
+          2/5)i)
      __________________________________________________________
 
-Booleans
+5.1.2. Booleans
 
    Genius also supports native Boolean values. The two Boolean
    constants are defined as true and false; these identifiers can
@@ -701,7 +731,7 @@ Booleans
    before being compared to true.
      __________________________________________________________
 
-Strings
+5.1.3. Strings
 
    Like numbers and Booleans, strings in GEL can be stored as
    values inside variables and passed to functions. You can also
@@ -736,7 +766,7 @@ string(22)
    and <=> (comparison) operators
      __________________________________________________________
 
-Null
+5.1.4. Null
 
    There is a special value called null. No operations can be
    performed on it, and nothing is printed when it is returned.
@@ -755,7 +785,7 @@ x=5;
    or an empty reference.
      __________________________________________________________
 
-Using Variables
+5.2. Using Variables
 
    Syntax:
 VariableName
@@ -768,25 +798,24 @@ genius> e
    variable. This will return the value of the variable. You can
    use a variable anywhere you would normally use a number or
    string. In addition, variables are necessary when defining
-   functions that take arguments (see the Section called Defining
-   Functions).
+   functions that take arguments (see Section 5.3.1).
 
    Tip Using Tab completion
 
 
-   You can use Tab completion to get Genius to complete variable
-   names for you. Try typing the first few letters of the name and
-   pressing Tab.
+       You can use Tab completion to get Genius to complete variable
+       names for you. Try typing the first few letters of the name and
+       pressing Tab.
 
    Important Variable names are case sensitive
 
 
-   The names of variables are case sensitive. That means that
-   variables named hello, HELLO and Hello are all different
-   variables.
+             The names of variables are case sensitive. That means that
+             variables named hello, HELLO and Hello are all different
+             variables.
      __________________________________________________________
 
-Setting Variables
+5.2.1. Setting Variables
 
    Syntax:
 <identifier> = <value>
@@ -810,25 +839,22 @@ a = b = 5
    where a Boolean expression is expected.
 
    For more information about the scope of variables, that is when
-   are what variables visible, see the Section called Global
-   Variables and Scope of Variables in the Chapter called
-   Programming with GEL.
+   are what variables visible, see Section 6.5.
      __________________________________________________________
 
-Built-in Variables
+5.2.2. Built-in Variables
 
    GEL has a number of built-in ‘variables’, such as e, pi or
    GoldenRatio. These are widely used constants with a preset
    value, and they cannot be assigned new values. There are a
-   number of other built-in variables. See the Section called
-   Constants in the Chapter called List of GEL functions for a
-   full list. Note that i is not by default the square root of
-   negative one (the imaginary number), and is undefined to allow
-   its use as a counter. If you wish to write the imaginary number
-   you need to use 1i.
+   number of other built-in variables. See Section 11.4 for a full
+   list. Note that i is not by default the square root of negative
+   one (the imaginary number), and is undefined to allow its use
+   as a counter. If you wish to write the imaginary number you
+   need to use 1i.
      __________________________________________________________
 
-Previous Result Variable
+5.2.3. Previous Result Variable
 
    The Ans and ans variables can be used to get the result of the
    last expression. For example, if you had performed some
@@ -836,7 +862,7 @@ Previous Result Variable
 Ans+389
      __________________________________________________________
 
-Using Functions
+5.3. Using Functions
 
    Syntax:
 FunctionName(argument1, argument2, ...)
@@ -854,25 +880,24 @@ gcd(921,317)
 
    There are many built-in functions, such as sin, cos and tan.
    You can use the help built-in command to get a list of
-   available functions, or see the Chapter called List of GEL
-   functions for a full listing.
+   available functions, or see Chapter 11 for a full listing.
 
    Tip Using Tab completion
 
 
-   You can use Tab completion to get Genius to complete function
-   names for you. Try typing the first few letters of the name and
-   pressing Tab.
+       You can use Tab completion to get Genius to complete function
+       names for you. Try typing the first few letters of the name and
+       pressing Tab.
 
-   Important Function names are case sensitive
+  Important Function names are case sensitive
 
 
-   The names of functions are case sensitive. That means that
-   functions named dosomething, DOSOMETHING and DoSomething are
-   all different functions.
+            The names of functions are case sensitive. That means that
+            functions named dosomething, DOSOMETHING and DoSomething are
+            all different functions.
      __________________________________________________________
 
-Defining Functions
+5.3.1. Defining Functions
 
    Syntax:
 function <identifier>(<comma separated arguments>) = <function body>
@@ -892,7 +917,7 @@ function addup(a,b,c) = a+b+c
    then addup(1,4,9) yields 14
      __________________________________________________________
 
-Variable Argument Lists
+5.3.2. Variable Argument Lists
 
    If you include ... after the last argument name in the function
    declaration, then Genius will allow any number of arguments to
@@ -905,7 +930,7 @@ function f(a,b...) = b
    Then f(1,2,3) yields [2,3], while f(1) yields a null.
      __________________________________________________________
 
-Passing Functions to Functions
+5.3.3. Passing Functions to Functions
 
    In Genius, it is possible to pass a function as an argument to
    another function. This can be done using either ‘function
@@ -920,9 +945,8 @@ function b(x) = x*x;
 f(b,2)
 
    To pass functions that are not defined, you can use an
-   anonymous function (see the Section called Defining Functions).
-   That is, you want to pass a function without giving it a name.
-   Syntax:
+   anonymous function (see Section 5.3.1). That is, you want to
+   pass a function without giving it a name. Syntax:
 function(<comma separated arguments>) = <function body>
 `(<comma separated arguments>) = <function body>
 
@@ -933,7 +957,7 @@ f(`(x) = x*x,2)
    This will return 5.
      __________________________________________________________
 
-Operations on Functions
+5.3.4. Operations on Functions
 
    Some functions allow arithmetic operations, and some single
    argument functions such as exp or ln, to operate on the
@@ -955,28 +979,21 @@ LinePlot(sin^2)
 
    Warning
 
-   Not all functions can be used in this way. For example, when
-   you use a binary operation the functions must take the same
-   number of arguments.
+           Not all functions can be used in this way. For example, when
+           you use a binary operation the functions must take the same
+           number of arguments.
      __________________________________________________________
 
-Absolute Value / Modulus
-
-   You can make an absolute value of something by putting the |'s
-   around it. For example:
-   |a-b|
-
-   In case the expression is a complex number the result will be
-   the modulus (distance from the origin). For example: |3 *
-   e^(1i*pi)| returns 3.
-     __________________________________________________________
+5.4. Separator
 
-Separator
-
-   In GEL if you want to type more than one command you have to
-   use the ; operator, which is a way to separate expressions,
-   such a combined expression will return whatever is the result
-   of the last one, so suppose you type the following:
+   GEL is somewhat different from other languages in how it deals
+   with multiple commands and functions. In GEL you must chain
+   commands together with a separator operator. That is, if you
+   want to type more than one expression you have to use the ;
+   operator in between the expressions. This is a way in which
+   both expressions are evaluated and the result of the second one
+   (or the last one if there is more than two expressions) is
+   returned. Suppose you type the following:
 3 ; 5
 
    This expression will yield 5.
@@ -987,16 +1004,22 @@ Separator
    the ; is a terminator of statements, whereas in GEL it’s
    actually a binary operator. If you are familiar with pascal
    this should be second nature. However genius can let you
-   pretend it is a terminator somewhat, if a ; is found at the end
-   of a parenthesis or a block, genius will itself append a null
-   node to it as if you would have written ;null. This is useful
-   in case you do not want to return a value from say a loop, or
-   if you handle the return differently. Note that it will
-   slightly slow down the code if it is executed too often as
-   there is one more operator involved.
+   pretend it is a terminator to some degree. If a ; is found at
+   the end of a parenthesis or a block, genius will append a null
+   to it as if you would have written ;null. This is useful in
+   case you do not want to return a value from say a loop, or if
+   you handle the return differently. Note that it will slightly
+   slow down the code if it is executed too often as there is one
+   more operator involved.
+
+   If you are typing expressions in a program you do not have to
+   add a semicolon. In this case genius will simply print the
+   return value whenever it executes the expression. However, do
+   note that if you are defining a function, the body of the
+   function is a single expression.
      __________________________________________________________
 
-Comments
+5.5. Comments
 
    GEL is similar to other scripting languages in that # denotes a
    comments, that is text that is not meant to be evaluated.
@@ -1008,21 +1031,20 @@ Comments
 x=123;
      __________________________________________________________
 
-Modular Evaluation
+5.6. Modular Evaluation
 
    Genius implements modular arithmetic. To use it you just add
-   "mod <integer>" after the expression. Example:
-   2^(5!) * 3^(6!) mod 5
-
-   It could be possible to do modular arithmetic by computing with
-   integers and then modding in the end with the % operator, which
-   simply gives the remainder, but that may be time consuming if
-   not impossible when working with larger numbers. For example,
-   10^(10^10) % 6 will simply not work (the exponent will be too
-   large), while 10^(10^10) mod 6 is instantaneous. The first
-   expression first tries to compute the integer 10^(10^10) and
-   then find remainder after division by 6, while the second
-   expression evaluates everything modulo 6 to begin with.
+   "mod <integer>" after the expression. Example: 2^(5!) * 3^(6!)
+   mod 5 It could be possible to do modular arithmetic by
+   computing with integers and then modding in the end with the %
+   operator, which simply gives the remainder, but that may be
+   time consuming if not impossible when working with larger
+   numbers. For example, 10^(10^10) % 6 will simply not work (the
+   exponent will be too large), while 10^(10^10) mod 6 is
+   instantaneous. The first expression first tries to compute the
+   integer 10^(10^10) and then find remainder after division by 6,
+   while the second expression evaluates everything modulo 6 to
+   begin with.
 
    You can calculate the inverses of numbers mod some integer by
    just using rational numbers (of course the inverse has to
@@ -1063,7 +1085,7 @@ genius> 2*2 mod 7
    mod.
      __________________________________________________________
 
-List of GEL Operators
+5.7. List of GEL Operators
 
    Everything in gel is really just an expression. Expressions are
    stringed together with different operators. As we have seen,
@@ -1086,7 +1108,9 @@ List of GEL Operators
           gets translated to a ==.
 
    |a|
-          Absolute value or modulus (if a is a complex number).
+          Absolute value. In case the expression is a complex
+          number the result will be the modulus (distance from the
+          origin). For example: |3 * e^(1i*pi)| returns 3.
 
           See Mathworld for more information.
 
@@ -1145,9 +1169,8 @@ List of GEL Operators
 
    a mod b
           Modular evaluation operator. The expression a is
-          evaluated modulo b. See the Section called Modular
-          Evaluation. Some functions and operators behave
-          differently modulo an integer.
+          evaluated modulo b. See Section 5.6. Some functions and
+          operators behave differently modulo an integer.
 
    a!
           Factorial operator. This is like 1*...*(n-2)*(n-1)*n.
@@ -1221,13 +1244,11 @@ List of GEL Operators
 
    &a
           Variable referencing (to pass a reference to a
-          variable). See the Section called References in the
-          Chapter called Programming with GEL.
+          variable). See Section 6.8.
 
    *a
           Variable dereferencing (to access a referenced
-          variable). See the Section called References in the
-          Chapter called Programming with GEL.
+          variable). See Section 6.8.
 
    a'
           Matrix conjugate transpose. That is, rows and columns
@@ -1327,34 +1348,34 @@ genius> 1:2:9
 
    Note
 
-   The @() operator makes the : operator most useful. With this
-   you can specify regions of a matrix. So that a@(2:4,6) is the
-   rows 2,3,4 of the column 6. Or a@(,1:2) will get you the first
-   two columns of a matrix. You can also assign to the @()
-   operator, as long as the right value is a matrix that matches
-   the region in size, or if it is any other type of value.
+        The @() operator makes the : operator most useful. With this
+        you can specify regions of a matrix. So that a@(2:4,6) is the
+        rows 2,3,4 of the column 6. Or a@(,1:2) will get you the first
+        two columns of a matrix. You can also assign to the @()
+        operator, as long as the right value is a matrix that matches
+        the region in size, or if it is any other type of value.
 
    Note
 
-   The comparison operators (except for the <=> operator, which
-   behaves normally), are not strictly binary operators, they can
-   in fact be grouped in the normal mathematical way, e.g.:
-   (1<x<=y<5) is a legal boolean expression and means just what it
-   should, that is (1<x and x≤y and y<5)
+        The comparison operators (except for the <=> operator, which
+        behaves normally), are not strictly binary operators, they can
+        in fact be grouped in the normal mathematical way, e.g.:
+        (1<x<=y<5) is a legal boolean expression and means just what it
+        should, that is (1<x and x≤y and y<5)
 
    Note
 
-   The unitary minus operates in a different fashion depending on
-   where it appears. If it appears before a number it binds very
-   closely, if it appears in front of an expression it binds less
-   than the power and factorial operators. So for example -1^k is
-   really (-1)^k, but -foo(1)^k is really -(foo(1)^k). So be
-   careful how you use it and if in doubt, add parentheses.
+        The unitary minus operates in a different fashion depending on
+        where it appears. If it appears before a number it binds very
+        closely, if it appears in front of an expression it binds less
+        than the power and factorial operators. So for example -1^k is
+        really (-1)^k, but -foo(1)^k is really -(foo(1)^k). So be
+        careful how you use it and if in doubt, add parentheses.
      __________________________________________________________
 
-Programming with GEL
+Chapter 6. Programming with GEL
 
-Conditionals
+6.1. Conditionals
 
    Syntax:
 if <expression1> then <expression2> [else <expression3>]
@@ -1376,9 +1397,9 @@ if a=5 then a=a-1
 if a==5 then a:=a-1
      __________________________________________________________
 
-Loops
+6.2. Loops
 
-While Loops
+6.2.1. While Loops
 
    Syntax:
 while <expression1> do <expression2>
@@ -1393,7 +1414,7 @@ do <expression2> until <expression1>
    is translated into == just as for the if statement.
      __________________________________________________________
 
-For Loops
+6.2.2. For Loops
 
    Syntax:
 for <identifier> = <from> to <to> do <body>
@@ -1430,10 +1451,10 @@ for x = 0 to 1 by 1/10 do print(x)
    execution of your code may differ on older versions.
      __________________________________________________________
 
-Foreach Loops
+6.2.3. Foreach Loops
 
    Syntax:
-   for <identifier> in <matrix> do <body>
+for <identifier> in <matrix> do <body>
 
    For each element in the matrix, going row by row from left to
    right we execute the body with the identifier set to the
@@ -1449,7 +1470,7 @@ for n in RowsOf ([1,2:3,4]) do print(n)
    will print out [1,2] and then [3,4].
      __________________________________________________________
 
-Break and Continue
+6.2.4. Break and Continue
 
    You can also use the break and continue commands in loops. The
    continue continue command will restart the current loop at its
@@ -1461,7 +1482,7 @@ while(<expression1>) do (
 )
      __________________________________________________________
 
-Sums and Products
+6.3. Sums and Products
 
    Syntax:
 sum <identifier> = <from> to <to> do <body>
@@ -1480,10 +1501,10 @@ prod <identifier> in <matrix> do <body>
    sum returns 0 and prod returns 1 as is the standard convention.
 
    For floating point numbers the same roundoff error protection
-   is done as in the for loop. See the Section called For Loops.
+   is done as in the for loop. See Section 6.2.2.
      __________________________________________________________
 
-Comparison Operators
+6.4. Comparison Operators
 
    The following standard comparison operators are supported in
    GEL and have the obvious meaning: ==, >=, <=, !=, <>, <, >.
@@ -1515,7 +1536,7 @@ if a==b then c
    a=1 will not set a=1 since the first argument was true.
      __________________________________________________________
 
-Global Variables and Scope of Variables
+6.5. Global Variables and Scope of Variables
 
    GEL is a dynamically scoped language. We will explain what this
    means below. That is, normal variables and functions are
@@ -1608,7 +1629,7 @@ set("a",3)
    Variables and Returning Functions.
      __________________________________________________________
 
-Parameter variables
+6.6. Parameter variables
 
    As we said before, there exist special variables called
    parameters that exist in all scopes. To declare a parameter
@@ -1625,7 +1646,7 @@ parameter foo = 1
    Some parameters are built-in and modify the behavior of genius.
      __________________________________________________________
 
-Returning
+6.7. Returning
 
    Normally a function is one or several expressions separated by
    a semicolon, and the value of the last expression is returned.
@@ -1646,7 +1667,7 @@ function f(x) = (
 )
      __________________________________________________________
 
-References
+6.8. References
 
    It may be necessary for some functions to return more than one
    value. This may be accomplished by returning a vector of
@@ -1681,7 +1702,7 @@ t=&f;
    gives us 4.
      __________________________________________________________
 
-Lvalues
+6.9. Lvalues
 
    An lvalue is the left hand side of an assignment. In other
    words, an lvalue is what you assign something to. Valid lvalues
@@ -1712,9 +1733,9 @@ a@(4:8,3) := [1,2,3,4,5]'
    comparison.
      __________________________________________________________
 
-Advanced Programming with GEL
+Chapter 7. Advanced Programming with GEL
 
-Error Handling
+7.1. Error Handling
 
    If you detect an error in your function, you can bail out of
    it. For normal errors, such as wrong types of arguments, you
@@ -1733,7 +1754,7 @@ function f(M) = (
 )
      __________________________________________________________
 
-Toplevel Syntax
+7.2. Toplevel Syntax
 
    The syntax is slightly different if you enter statements on the
    top level versus when they are inside parentheses or inside
@@ -1766,7 +1787,7 @@ if Something() then (
 )
      __________________________________________________________
 
-Returning Functions
+7.3. Returning Functions
 
    It is possible to return functions as value. This way you can
    build functions that construct special purpose functions
@@ -1860,7 +1881,7 @@ g(10)
    of 5 was added to the private dictionary.
      __________________________________________________________
 
-True Local Variables
+7.4. True Local Variables
 
    When passing functions into other functions, the normal scoping
    of variables might be undesired. For example:
@@ -1912,7 +1933,7 @@ function f(g,x) = (
    function does not see implementation details and get confused.
      __________________________________________________________
 
-GEL Startup Procedure
+7.5. GEL Startup Procedure
 
    First the program looks for the installed library file (the
    compiled version lib.cgel) in the installed directory, then it
@@ -1924,7 +1945,7 @@ GEL Startup Procedure
    lib.cgel
      __________________________________________________________
 
-Loading Programs
+7.6. Loading Programs
 
    Sometimes you have a larger program you wrote into a file and
    want to read that file into Genius Mathematics Tool. In these
@@ -1950,14 +1971,14 @@ cd directory_with_gel_programs
 ls *.gel
      __________________________________________________________
 
-Matrices in GEL
+Chapter 8. Matrices in GEL
 
    Genius has support for vectors and matrices and possesses a
    sizable library of matrix manipulation and linear algebra
    functions.
      __________________________________________________________
 
-Entering Matrices
+8.1. Entering Matrices
 
    To enter matrices, you can use one of the following two
    syntaxes. You can either enter the matrix on one line,
@@ -2008,12 +2029,12 @@ b = [ a,  10
 
    Note
 
-   Be careful about using returns for expressions inside the [ ]
-   brackets, as they have a slightly different meaning there. You
-   will start a new row.
+        Be careful about using returns for expressions inside the [ ]
+        brackets, as they have a slightly different meaning there. You
+        will start a new row.
      __________________________________________________________
 
-Conjugate Transpose and Transpose Operator
+8.2. Conjugate Transpose and Transpose Operator
 
    You can conjugate transpose a matrix by using the ' operator.
    That is the entry in the ith column and the jth row will be the
@@ -2033,7 +2054,7 @@ Conjugate Transpose and Transpose Operator
    with real matrices and vectors.
      __________________________________________________________
 
-Linear Algebra
+8.3. Linear Algebra
 
    Genius implements many useful linear algebra and matrix
    manipulation routines. See the Linear Algebra and Matrix
@@ -2069,14 +2090,14 @@ Linear Algebra
    will be very fast.
      __________________________________________________________
 
-Polynomials in GEL
+Chapter 9. Polynomials in GEL
 
    Currently Genius can handle polynomials of one variable written
    out as vectors, and do some basic operations with these. It is
    planned to expand this support further.
      __________________________________________________________
 
-Using Polynomials
+9.1. Using Polynomials
 
    Currently polynomials in one variable are just horizontal
    vectors with value only nodes. The power of the term is the
@@ -2108,19 +2129,18 @@ f(2)
    function such as FindRootBisection, FindRootFalsePosition,
    FindRootMullersMethod, or FindRootSecant.
 
-   See the Section called Polynomials in the Chapter called List
-   of GEL functions in the function list for the rest of functions
-   acting on polynomials.
+   See Section 11.15 in the function list for the rest of
+   functions acting on polynomials.
      __________________________________________________________
 
-Set Theory in GEL
+Chapter 10. Set Theory in GEL
 
    Genius has some basic set theoretic functionality built in.
    Currently a set is just a vector (or a matrix). Every distinct
    object is treated as a different element.
      __________________________________________________________
 
-Using Sets
+10.1. Using Sets
 
    Just like vectors, objects in sets can include numbers,
    strings, null, matrices and vectors. It is planned in the
@@ -2154,13 +2174,13 @@ genius> IsIn (1, [0,1,2])
    IsSubset(null,X) is always true.
      __________________________________________________________
 
-List of GEL functions
+Chapter 11. List of GEL functions
 
    To get help on a specific function from the console type:
 help FunctionName
      __________________________________________________________
 
-Commands
+11.1. Commands
 
    help
 
@@ -2203,7 +2223,7 @@ plugin plugin_name
           the system in the proper directory.
      __________________________________________________________
 
-Basic
+11.2. Basic
 
    AskButtons
 
@@ -2278,7 +2298,8 @@ GetCurrentModulo
 
 Identity (x)
 
-          Identity function, returns its argument.
+          Identity function, returns its argument. It is
+          equivalent to function Identity(x)=x.
 
    IntegerFromBoolean
 
@@ -2646,7 +2667,7 @@ warranty
           Gives the warranty information.
      __________________________________________________________
 
-Parameters
+11.3. Parameters
 
    ChopTolerance
 
@@ -2918,7 +2939,7 @@ VectorfieldTicks = [vertical,horizontal]
           Version 1.0.10 onwards.
      __________________________________________________________
 
-Constants
+11.4. Constants
 
    CatalanConstant
 
@@ -2928,7 +2949,7 @@ CatalanConstant
           to be the series where terms are (-1^k)/((2*k+1)^2),
           where k ranges from 0 to infinity.
 
-          See Mathworld for more information.
+          See Wikipedia, or Mathworld for more information.
 
    EulerConstant
 
@@ -2936,7 +2957,7 @@ EulerConstant
 
           Aliases: gamma
 
-          Euler's Constant gamma. Sometimes called the
+          Euler's constant gamma. Sometimes called the
           Euler-Mascheroni constant.
 
           See Wikipedia or Planetmath or Mathworld for more
@@ -2955,7 +2976,11 @@ GoldenRatio
 
 Gravity
 
-          Free fall acceleration at sea level.
+          Free fall acceleration at sea level in meters per second
+          squared. This is the standard gravity constant 9.80665.
+          The gravity in your particular neck of the woods might
+          be different due to different altitude and the fact that
+          the earth is not perfectly round and uniform.
 
           See Wikipedia for more information.
 
@@ -2964,8 +2989,11 @@ Gravity
 e
 
           The base of the natural logarithm. e^x is the
-          exponential function exp. This is the number
-          approximately 2.71828182846...
+          exponential function exp. It is approximately
+          2.71828182846... This number is sometimes called Euler's
+          number, although there are several numbers that are also
+          called Euler's. An example is the gamma constant:
+          EulerConstant.
 
           See Wikipedia or Planetmath or Mathworld for more
           information.
@@ -2982,7 +3010,7 @@ pi
           information.
      __________________________________________________________
 
-Numeric
+11.5. Numeric
 
    AbsoluteValue
 
@@ -2992,7 +3020,7 @@ AbsoluteValue (x)
 
           Absolute value of a number and if x is a complex value
           the modulus of x. I.e. this the distance of x to the
-          origin.
+          origin. This is equivalent to |x|.
 
           See Wikipedia, Planetmath (absolute value), Planetmath
           (modulus), Mathworld (absolute value) or Mathworld
@@ -3038,7 +3066,8 @@ Im (z)
 
           Aliases: ImaginaryPart
 
-          Get the imaginary part of a complex number.
+          Get the imaginary part of a complex number. For example
+          Re(3+4i) yields 4.
 
           See Wikipedia for more information.
 
@@ -3052,7 +3081,10 @@ IntegerQuotient (m,n)
 
 IsComplex (num)
 
-          Check if argument is a complex (non-real) number.
+          Check if argument is a complex (non-real) number. Do
+          note that we really mean nonreal number. That is,
+          IsComplex(3) yields false, while IsComplex(3-1i) yields
+          true.
 
    IsComplexRational
 
@@ -3067,7 +3099,7 @@ IsComplexRational (num)
 
 IsFloat (num)
 
-          Check if argument is a floating point number
+          Check if argument is a real floating point number
           (non-complex).
 
    IsGaussInteger
@@ -3076,7 +3108,9 @@ IsGaussInteger (num)
 
           Aliases: IsComplexInteger
 
-          Check if argument is a possibly complex integer.
+          Check if argument is a possibly complex integer. That is
+          a complex integer is a number of the form n+1i*m where n
+          and m are integers.
 
    IsInteger
 
@@ -3088,7 +3122,8 @@ IsInteger (num)
 
 IsNonNegativeInteger (num)
 
-          Check if argument is a non-negative real integer.
+          Check if argument is a non-negative real integer. That
+          is, either a positive integer or zero.
 
    IsPositiveInteger
 
@@ -3127,7 +3162,8 @@ Re (z)
 
           Aliases: RealPart
 
-          Get the real part of a complex number.
+          Get the real part of a complex number. For example
+          Re(3+4i) yields 3.
 
           See Wikipedia for more information.
 
@@ -3194,6 +3230,9 @@ ln (x)
 
           The natural logarithm, the logarithm to base e.
 
+          See Wikipedia or Planetmath or Mathworld for more
+          information.
+
    log
 
 log (x)
@@ -3300,7 +3339,7 @@ trunc (x)
           Truncate number to an integer (return the integer part).
      __________________________________________________________
 
-Trigonometry
+11.6. Trigonometry
 
    acos
 
@@ -3510,7 +3549,7 @@ tanh (x)
           See Planetmath for more information.
      __________________________________________________________
 
-Number Theory
+11.7. Number Theory
 
    AreRelativelyPrime
 
@@ -4015,7 +4054,7 @@ lcm (a,args...)
           See Planetmath or Mathworld for more information.
      __________________________________________________________
 
-Matrix Manipulation
+11.8. Matrix Manipulation
 
    ApplyOverMatrix
 
@@ -4438,7 +4477,7 @@ zeros (rows,columns...)
           columns are zero.
      __________________________________________________________
 
-Linear Algebra
+11.9. Linear Algebra
 
    AuxiliaryUnitMatrix
 
@@ -5140,7 +5179,7 @@ rref (M)
           See Wikipedia or Planetmath for more information.
      __________________________________________________________
 
-Combinatorics
+11.10. Combinatorics
 
    Catalan
 
@@ -5379,7 +5418,7 @@ nPr (n,r)
           See Mathworld or Wikipedia for more information.
      __________________________________________________________
 
-Calculus
+11.11. Calculus
 
    CompositeSimpsonsRule
 
@@ -5685,7 +5724,7 @@ TwoSidedThreePointFormula (f,x0,h)
           Compute two-sided derivative using three-point formula.
      __________________________________________________________
 
-Functions
+11.12. Functions
 
    Argument
 
@@ -5949,7 +5988,7 @@ sinc (x)
           Version 1.0.16 onwards.
      __________________________________________________________
 
-Equation Solving
+11.13. Equation Solving
 
    CubicFormula
 
@@ -6221,7 +6260,7 @@ d","Second");
           Version 1.0.10 onwards.
      __________________________________________________________
 
-Statistics
+11.14. Statistics
 
    Average
 
@@ -6316,7 +6355,7 @@ StandardDeviation (m)
           Calculate the standard deviation of a whole matrix.
      __________________________________________________________
 
-Polynomials
+11.15. Polynomials
 
    AddPoly
 
@@ -6403,7 +6442,7 @@ TrimPoly (p)
           Trim zeros from a polynomial (as vector).
      __________________________________________________________
 
-Set Theory
+11.16. Set Theory
 
    Intersection
 
@@ -6448,7 +6487,7 @@ Union (X,Y)
           vectors pretending to be sets).
      __________________________________________________________
 
-Commutative Algebra
+11.17. Commutative Algebra
 
    MacaulayBound
 
@@ -6479,7 +6518,7 @@ MacaulayRep (c,d)
           Version 1.0.15 onwards.
      __________________________________________________________
 
-Miscellaneous
+11.18. Miscellaneous
 
    ASCIIToString
 
@@ -6509,7 +6548,7 @@ StringToAlphabet (str,alphabet)
           letters.
      __________________________________________________________
 
-Symbolic Operations
+11.19. Symbolic Operations
 
    SymbolicDerivative
 
@@ -6556,7 +6595,7 @@ SymbolicTaylorApproximationFunction (f,x0,n)
           around x0 to the nth degree. (See SymbolicDerivative)
      __________________________________________________________
 
-Plotting
+11.20. Plotting
 
    ExportPlot
 
@@ -7093,7 +7132,7 @@ VectorfieldPlot (funcx, funcy, x1, x2, y1, y2)
 genius> VectorfieldPlot(`(x,y)=x^2-y, `(x,y)=y^2-x, -1, 1, -1, 1)
      __________________________________________________________
 
-Example Programs in GEL
+Chapter 12. Example Programs in GEL
 
    Here is a function that calculates factorials:
 function f(x) = if x <= 1 then 1 else (f(x-1)*x)
@@ -7168,30 +7207,28 @@ function MyOwnREF(m) = (
 )
      __________________________________________________________
 
-Settings
+Chapter 13. Settings
 
    To configure Genius Mathematics Tool, choose
    Settings->Preferences. There are several basic parameters
    provided by the calculator in addition to the ones provided by
    the standard library. These control how the calculator behaves.
 
-   Note Changing Settings with GEL
+ Note Changing Settings with GEL
 
 
-   Many of the settings in Genius are simply global variables, and
-   can be evaluated and assigned to in the same way as normal
-   variables. See the Section called Using Variables in the
-   Chapter called GEL Basics about evaluating and assigning to
-   variables, and the Section called Parameters in the Chapter
-   called List of GEL functions for a list of settings that can be
-   modified in this way.
+         Many of the settings in Genius are simply global variables, and
+         can be evaluated and assigned to in the same way as normal
+         variables. See Section 5.2 about evaluating and assigning to
+         variables, and Section 11.3 for a list of settings that can be
+         modified in this way.
 
-   As an example, you can set the maximum number of digits in a
-   result to 12 by typing:
-MaxDigits = 12
+         As an example, you can set the maximum number of digits in a
+         result to 12 by typing:
+      MaxDigits = 12
      __________________________________________________________
 
-Output
+13.1. Output
 
    Maximum digits to output
           The maximum digits in a result (MaxDigits)
@@ -7254,8 +7291,8 @@ Output
 
    In addition to these preferences, there are some preferences
    that can only be changed by setting them in the workspace
-   console. For others that may affect the output see the Section
-   called Parameters in the Chapter called List of GEL functions.
+   console. For others that may affect the output see Section
+   11.3.
 
    IntegerOutputBase
           The base that will be used to output integers
@@ -7269,7 +7306,7 @@ Output
           for typsetting in LaTeX, MathML (XML), or in Troff.
      __________________________________________________________
 
-Precision
+13.2. Precision
 
    Floating point precision
           The floating point precision in bits (FloatPrecision).
@@ -7288,7 +7325,7 @@ Precision
           box, restart genius and then uncheck it again.
      __________________________________________________________
 
-Terminal
+13.3. Terminal
 
    Terminal refers to the console in the work area.
 
@@ -7308,7 +7345,7 @@ Terminal
           remotely.
      __________________________________________________________
 
-Memory
+13.4. Memory
 
    Maximum number of nodes to allocate
           Internally all data is put onto small nodes in memory.
@@ -7331,9 +7368,9 @@ Memory
           amount of memory that genius uses.
      __________________________________________________________
 
-About Genius Mathematics Tool
+Chapter 14. About Genius Mathematics Tool
 
-   Genius Mathematics Tool was written by Jiří (George) Lebl
+   Genius Mathematics Tool was written by Jiř (George) Lebl
    (<jirka 5z com>). The history of Genius Mathematics Tool goes
    back to late 1997. It was the first calculator program for
    GNOME, but it then grew beyond being just a desktop calculator.
@@ -7351,7 +7388,7 @@ About Genius Mathematics Tool
    in the file COPYING included with the source code of this
    program.
 
-   Jiří Lebl was during various parts of the development partially
+   Jiř Lebl was during various parts of the development partially
    supported for the work by NSF grants DMS 0900885, DMS 1362337,
    the University of Illinois at Urbana-Champaign, the University
    of California at San Diego, the University of
diff --git a/src/funclib.c b/src/funclib.c
index 7069719..4132b3f 100644
--- a/src/funclib.c
+++ b/src/funclib.c
@@ -3060,10 +3060,20 @@ max_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
                        g_assert (max != NULL);
                        return gel_copynode (max);
                } else if (a[0]->type == GEL_VALUE_NODE) {
+                       if (mpw_is_complex (a[0]->val.value)) {
+                               gel_errorout (_("%s: Cannot compare complex numbers"),
+                                             "max");
+                               return NULL;
+                       }
+
                        /*
                         * Evil optimization to avoid copying the node from the argument
                         */
                        return gel_stealnode (a[0]);
+               } else {
+                       gel_errorout (_("%s: Input not a number of matrix of numbers."),
+                                     "max");
+                       return NULL;
                }
        }
 
@@ -3147,10 +3157,19 @@ min_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
                        g_assert (min != NULL);
                        return gel_copynode (min);
                } else if (a[0]->type == GEL_VALUE_NODE) {
+                       if (mpw_is_complex (a[0]->val.value)) {
+                               gel_errorout (_("%s: Cannot compare complex numbers"),
+                                             "min");
+                               return NULL;
+                       }
                        /*
                         * Evil optimization to avoid copying the node from the argument
                         */
                        return gel_stealnode (a[0]);
+               } else {
+                       gel_errorout (_("%s: Input not a number of matrix of numbers."),
+                                     "min");
+                       return NULL;
                }
        }
 
diff --git a/src/geniustests.txt b/src/geniustests.txt
index 4350cee..66f87eb 100644
--- a/src/geniustests.txt
+++ b/src/geniustests.txt
@@ -175,7 +175,12 @@ max(1.3,5/4)                                                       1.3
 max(1.3,1.3)                                                   1.3
 min(1.3,1.3)                                                   1.3
 min(-1.3,1.3)                                                  -1.3
+min(null)                                                      min((null))
+max(null)                                                      max((null))
+min(3i)                                                                min(3i)
+max(3i)                                                                max(3i)
 min(3i,5)                                                      min(3i,5)
+max(3i,5)                                                      max(3i,5)
 max([1,2,3],2)                                                 [2,2,3]
 min([1,2,3],2)                                                 [1,2,2]
 prod k=2 to 4 do k+1                                           60
@@ -203,6 +208,16 @@ IsRational(3.1)                                                    false
 IsRational(3)                                                  true
 IsComplex(3i)                                                  true
 IsComplex(3)                                                   false
+IsComplex(3-1i)                                                        true
+IsComplexInteger(3-1i)                                         true
+IsComplexInteger(3)                                            true
+IsComplexInteger(3.0)                                          false
+IsComplexInteger(3+1.1i)                                       false
+IsValue(0.1+8i)                                                true
+IsValue(false)                                                 false
+IsValue([0.1])                                                 false
+IsValue(null)                                                  false
+IsValue(`(x)=x^2)                                              false
 IsFloat(3.1)                                                   true
 IsFloat(3)                                                     false
 I(4)                                                           [1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1]
@@ -242,6 +257,8 @@ not &d                                                              (not (&d))
 not 3i                                                         false
 if(3=="3")then 1 else 0                                                1
 if(3=="3 ")then 1 else 0                                       0
+IsNull([1])                                                    false
+IsNull(`(x)=x^2)                                               false
 IsNull(1)                                                      false
 IsNull(.)                                                      true
 [1,2;3,4]+[5,6;7,8]                                            [6,8;10,12]
@@ -936,6 +953,11 @@ NullSpace([1,1;2,2])                                               [1;-1]
 NullSpace([1,1;2,2;3,3])                                       [1;-1]
 NullSpace([0,0;1,1;2,2;3,3])                                   [1;-1]
 NullSpace([0,0;1,0;2,0;3,0])                                   [0;-1]
+Parse("3+4")                                                   7
+1+Parse("3+4")                                                 8
+Evaluate("3+4")                                                        7
+1+Evaluate("3+4")                                              8
+Parse("x+4")                                                   (x+4)
 Parse("a+b")                                                   (a+b)
 Parse(null)+1                                                  ((null)+1)
 Parse("x=1;x=x+1;x")                                           ((x=1);(x=(x+1));x)
@@ -1184,6 +1206,12 @@ SetElement("r",-1,2,99)                                          
SetElement("r",-1,2,99)
 |EvenPeriodicExtension (`(x)=x^3,2) call (-0.7) - (0.7)^3|<10^-20      true
 |EvenPeriodicExtension (`(x)=x^3,2) call (-0.7+4) - (0.7)^3|<10^-20    true
 |EvenPeriodicExtension (`(x)=x^3,2) call (0.7+2) - (0.7)^3|<10^-20     false
+Re(3+4i)                                                       3
+Im(3+4i)                                                       4
+Im(4i)                                                         4
+Re(4i)                                                         0
+Re(4)                                                          4
+Im(4)                                                          0
 load "nullspacetest.gel"                                       true
 load "longtest.gel"                                            true
 load "testprec.gel"                                            true


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]