[genius] Tue Jun 29 11:38:38 2010 Jiri (George) Lebl <jirka 5z com>
- From: George Lebl <jirka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [genius] Tue Jun 29 11:38:38 2010 Jiri (George) Lebl <jirka 5z com>
- Date: Tue, 29 Jun 2010 16:38:59 +0000 (UTC)
commit c37a76fc2c9abaa8565846206ee44ba627d210d4
Author: Jiri (George) Lebl <jirka 5z com>
Date: Tue Jun 29 11:38:43 2010 -0500
Tue Jun 29 11:38:38 2010 Jiri (George) Lebl <jirka 5z com>
* src/graphing.c: Add SurfacePlotVariableNames and some fixes
* help/C/*.xml: document above and some fixes
ChangeLog | 6 +
help/C/gel-function-list.xml | 19 +-
help/C/genius.txt | 2283 ++++++++++++++++++++++--------------------
help/C/genius.xml | 9 +-
src/graphing.c | 109 ++-
5 files changed, 1310 insertions(+), 1116 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5c274fc..9da2ac6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Jun 29 11:38:38 2010 Jiri (George) Lebl <jirka 5z com>
+
+ * src/graphing.c: Add SurfacePlotVariableNames and some fixes
+
+ * help/C/*.xml: document above and some fixes
+
Tue Jun 29 11:11:04 2010 Jiri (George) Lebl <jirka 5z com>
* src/graphing.c: allow changing variable names for surfaces when
diff --git a/help/C/gel-function-list.xml b/help/C/gel-function-list.xml
index c0c59cd..a89d86d 100644
--- a/help/C/gel-function-list.xml
+++ b/help/C/gel-function-list.xml
@@ -745,6 +745,18 @@ slopefield plot. (See <link linkend="gel-function-SlopefieldPlot"><function>Slo
</listitem>
</varlistentry>
+ <varlistentry id="gel-function-SurfacePlotVariableNames">
+ <term>SurfacePlotVariableNames</term>
+ <listitem>
+ <synopsis>SurfacePlotVariableNames = ["x","y","z"]</synopsis>
+ <para>Tells genius which variable names are used as default names for <link linkend="genius-gel-function-list-plotting">surface plotting
+ functions</link> using <link linkend="gel-function-SurfacePlot"><function>SurfacePlot</function></link>.
+ Note that the <varname>z</varname> does not refer to the dependent (vertical) axis, but to the indepent complex variable
+ <userinput>z=x+iy</userinput>.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="gel-function-SurfacePlotWindow">
<term>SurfacePlotWindow</term>
<listitem>
@@ -980,7 +992,8 @@ all its elements are conjugated.</para>
<term>IsComplexRational</term>
<listitem>
<synopsis>IsComplexRational (num)</synopsis>
- <para>Check if argument is a possibly complex rational number.</para>
+ <para>Check if argument is a possibly complex rational number. That is, if both real and imaginary parts are
+ given as rational numbers. Of course rational simply means "not stored as a floating point number."</para>
</listitem>
</varlistentry>
@@ -1031,7 +1044,7 @@ we accept the convention that 0 is not a natural number.</para>
<term>IsRational</term>
<listitem>
<synopsis>IsRational (num)</synopsis>
- <para>Check if argument is a rational number (non-complex).</para>
+ <para>Check if argument is a rational number (non-complex). Of course rational simply means "not stored as a floating point number."</para>
</listitem>
</varlistentry>
@@ -4775,7 +4788,7 @@ and has period <userinput>b-a</userinput>.</para>
<term>GaussDistribution</term>
<listitem>
<synopsis>GaussDistribution (x,sigma)</synopsis>
- <para>Integral of the GaussFunction from 0 to x (area under the normal curve).</para>
+ <para>Integral of the GaussFunction from 0 to <varname>x</varname> (area under the normal curve).</para>
<para>
See
<ulink url="http://mathworld.wolfram.com/NormalDistribution.html">Mathworld</ulink> for more information.
diff --git a/help/C/genius.txt b/help/C/genius.txt
index 14256bf..a3afc0a 100644
--- a/help/C/genius.txt
+++ b/help/C/genius.txt
@@ -12,7 +12,7 @@
<kaiw itee uq edu au>
- Copyright (c) 1997-2009 Jiri (George) Lebl
+ Copyright (c) 1997-2010 Jiri (George) Lebl
Copyright (c) 2004 Kai Willadsen
@@ -69,203 +69,193 @@
application or this manual, follow the directions in the GNOME Feedback
Page.
+ This manual describes version 1.0.10 of Genius.
+
----------------------------------------------------------------------
Table of Contents
- 1. Introduction
-
- 2. Getting Started
-
- 2.1. To Start Genius Mathematics Tool
-
- 2.2. When You Start Genius
-
- 3. Basic Usage
-
- 3.1. Using the Work Area
+ Introduction
- 3.2. To Create a New Program
+ Getting Started
- 3.3. To Open and Run a Program
+ To Start Genius Mathematics Tool
- 4. Plotting
+ When You Start Genius
- 4.1. Line Plots
+ Basic Usage
- 4.2. Parametric Plots
+ Using the Work Area
- 4.3. Slopefield Plots
+ To Create a New Program
- 4.4. Vectorfield Plots
+ To Open and Run a Program
- 4.5. Surface Plots
+ Plotting
- 5. GEL Basics
+ Line Plots
- 5.1. Values
+ Parametric Plots
- 5.1.1. Numbers
+ Slopefield Plots
- 5.1.2. Booleans
+ Vectorfield Plots
- 5.1.3. Strings
+ Surface Plots
- 5.1.4. Null
+ GEL Basics
- 5.2. Using Variables
+ Values
- 5.2.1. Setting Variables
+ Numbers
- 5.2.2. Built-in Variables
+ Booleans
- 5.2.3. Previous Result Variable
+ Strings
- 5.3. Using Functions
+ Null
- 5.3.1. Defining Functions
+ Using Variables
- 5.3.2. Variable Argument Lists
+ Setting Variables
- 5.3.3. Passing Functions to Functions
+ Built-in Variables
- 5.3.4. Operations on Functions
+ Previous Result Variable
- 5.4. Absolute Value / Modulus
+ Using Functions
- 5.5. Separator
+ Defining Functions
- 5.6. Modular Evaluation
+ Variable Argument Lists
- 5.7. List of GEL Operators
+ Passing Functions to Functions
- 6. Programming with GEL
+ Operations on Functions
- 6.1. Conditionals
+ Absolute Value / Modulus
- 6.2. Loops
+ Separator
- 6.2.1. While Loops
+ Modular Evaluation
- 6.2.2. For Loops
+ List of GEL Operators
- 6.2.3. Foreach Loops
+ Programming with GEL
- 6.2.4. Break and Continue
+ Conditionals
- 6.3. Sums and Products
+ Loops
- 6.4. Comparison Operators
+ While Loops
- 6.5. Global Variables and Scope of Variables
+ For Loops
- 6.6. Returning
+ Foreach Loops
- 6.7. References
+ Break and Continue
- 6.8. Lvalues
+ Sums and Products
- 7. Advanced Programming with GEL
+ Comparison Operators
- 7.1. Error Handling
+ Global Variables and Scope of Variables
- 7.2. Toplevel Syntax
+ Parameter variables
- 7.3. Returning Functions
+ Returning
- 7.4. True Local Variables
+ References
- 7.5. GEL Startup Procedure
+ Lvalues
- 7.6. Loading Programs
+ Advanced Programming with GEL
- 8. Matrices in GEL
+ Error Handling
- 8.1. Entering Matrices
+ Toplevel Syntax
- 8.2. Conjugate Transpose and Transpose Operator
+ Returning Functions
- 8.3. Linear Algebra
+ True Local Variables
- 9. Polynomials in GEL
+ GEL Startup Procedure
- 9.1. Using Polynomials
+ Loading Programs
- 10. Set Theory in GEL
+ Matrices in GEL
- 10.1. Using Sets
+ Entering Matrices
- 11. List of GEL functions
+ Conjugate Transpose and Transpose Operator
- 11.1. Commands
+ Linear Algebra
- 11.2. Basic
+ Polynomials in GEL
- 11.3. Parameters
+ Using Polynomials
- 11.4. Constants
+ Set Theory in GEL
- 11.5. Numeric
+ Using Sets
- 11.6. Trigonometry
+ List of GEL functions
- 11.7. Number Theory
+ Commands
- 11.8. Matrix Manipulation
+ Basic
- 11.9. Linear Algebra
+ Parameters
- 11.10. Combinatorics
+ Constants
- 11.11. Calculus
+ Numeric
- 11.12. Functions
+ Trigonometry
- 11.13. Equation Solving
+ Number Theory
- 11.14. Statistics
+ Matrix Manipulation
- 11.15. Polynomials
+ Linear Algebra
- 11.16. Set Theory
+ Combinatorics
- 11.17. Miscellaneous
+ Calculus
- 11.18. Symbolic Operations
+ Functions
- 11.19. Plotting
+ Equation Solving
- 12. Example Programs in GEL
+ Statistics
- 13. Settings
+ Polynomials
- 13.1. Output
+ Set Theory
- 13.2. Precision
+ Miscellaneous
- 13.3. Terminal
+ Symbolic Operations
- 13.4. Memory
+ Plotting
- 14. About Genius Mathematics Tool
+ Example Programs in GEL
- List of Figures
+ Settings
- 2-1. Genius Mathematics Tool Window
+ Output
- 4-1. Create Plot Window
+ Precision
- 4-2. Plot Window
+ Terminal
- 4-3. Parametric Plot Tab
+ Memory
- 4-4. Parametric Plot
-
- 4-5. Surface Plot
+ About Genius Mathematics Tool
----------------------------------------------------------------------
- Chapter 1. Introduction
+ Introduction
The Genius Mathematics Tool application is a general calculator for use as
a desktop calculator, an educational tool in mathematics, and is useful
@@ -291,9 +281,9 @@
----------------------------------------------------------------------
- Chapter 2. Getting Started
+ Getting Started
-2.1. To Start Genius Mathematics Tool
+To Start Genius Mathematics Tool
You can start Genius Mathematics Tool in the following ways:
@@ -324,12 +314,12 @@
----------------------------------------------------------------------
-2.2. When You Start Genius
+When You Start Genius
When you start the GNOME edition of Genius Mathematics Tool, the window
- pictured in Figure 2-1 is displayed.
+ pictured in Figure 1 is displayed.
- Figure 2-1. Genius Mathematics Tool Window
+ Figure 1. Genius Mathematics Tool Window
The Genius Mathematics Tool window contains the following elements:
@@ -373,9 +363,9 @@
----------------------------------------------------------------------
- Chapter 3. Basic Usage
+ Basic Usage
-3.1. Using the Work Area
+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 the console will be
@@ -388,39 +378,39 @@
GEL. The most simple GEL expression just looks like mathematics. For
example
- genius> 30*70 + 67^3.0 + ln(7) * (88.8/100)
+ genius> 30*70 + 67^3.0 + ln(7) * (88.8/100)
or
- genius> 62734 + 812634 + 77^4 mod 5
+ genius> 62734 + 812634 + 77^4 mod 5
or
- genius> | sin(37) - e^7 |
+ genius> | sin(37) - e^7 |
or
- genius> sum n=1 to 70 do 1/n
+ genius> sum n=1 to 70 do 1/n
(Last is the harmonic sum from 1 to 70)
To get a list of functions and commands, type:
- genius> help
+ genius> help
If you wish to get more help on a specific function, type:
- genius> help FunctionName
+ genius> help FunctionName
To view this manual, type:
- genius> manual
+ genius> manual
Suppose you have previously saved some GEL commands as a program to a file
and you now want to execute them. To load this program from the file
path/to/program.gel, type
- genius> load path/to/program.gel
+ genius> load path/to/program.gel
Genius Mathematics Tool keeps track of the current directory. To list
files in the current directory type ls, to change directory do cd
@@ -428,7 +418,7 @@
----------------------------------------------------------------------
-3.2. To Create a New Program
+To 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.
@@ -445,7 +435,7 @@
----------------------------------------------------------------------
-3.3. To Open and Run a Program
+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 file.
@@ -456,19 +446,19 @@
----------------------------------------------------------------------
- Chapter 4. Plotting
+ Plotting
Plotting support is only available in the graphical GNOME version. All
plotting accessible from the graphical interface is available from the
Create Plot window. You can access this 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 Chapter 5 to find out how to enter expressions
- that Genius understands.
+ of the GEL language. See the Chapter called GEL Basics to find out how to
+ enter expressions that Genius understands.
----------------------------------------------------------------------
-4.1. Line Plots
+Line Plots
To graph real valued functions of one variable open the Create Plot
window. You can also use the LinePlot function on the command line (see
@@ -476,9 +466,9 @@
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 4-1.
+ want to be on the Functions / Expressions notebook tab. See Figure 1.
- Figure 4-1. Create Plot Window
+ Figure 1. Create Plot Window
Into the text boxes just type in expressions where x is the independent
variable. You can also just give names of functions such as cos rather
@@ -487,9 +477,9 @@
warning icon on the right of the text input box where the error occurred,
as well as giving you an error dialog. You can change the ranges of the
dependent and independent variables in the bottom part of the dialog.
- Pressing the Plot button produces the graph shown in Figure 4-2.
+ Pressing the Plot button produces the graph shown in Figure 2.
- Figure 4-2. Plot Window
+ Figure 2. Plot Window
From here you can print out the plot, create encapsulated postscript or a
PNG version of the plot or change the zoom. If the dependent axis was not
@@ -501,25 +491,25 @@
----------------------------------------------------------------------
-4.2. Parametric Plots
+Parametric Plots
In the create plot window, you can also choose the Parametric notebook tab
to create two dimensional parametric plots. This way you can plot a single
parametric function. You can either specify the points as x and y, or
- giving a single complex number. See Figure 4-3.
+ giving a single complex number. See Figure 3.
- Figure 4-3. Parametric Plot Tab
+ Figure 3. Parametric Plot Tab
- An example of a parametric plot is given in Figure 4-3. Similar operations
+ An example of a parametric plot is given in Figure 3. 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.
- Figure 4-4. Parametric Plot
+ Figure 4. Parametric Plot
----------------------------------------------------------------------
-4.3. Slopefield Plots
+Slopefield Plots
In the create plot window, you can also choose the Slope field notebook
tab to create a two dimensional slope field plot. Similar operations can
@@ -544,7 +534,7 @@
----------------------------------------------------------------------
-4.4. Vectorfield Plots
+Vectorfield Plots
In the create plot window, you can also choose the Vector field notebook
tab to create a two dimensional vector field plot. Similar operations can
@@ -572,7 +562,7 @@
----------------------------------------------------------------------
-4.5. Surface Plots
+Surface Plots
Genius can also plot surfaces. Select the Surface plot tab in the main
notebook of the Create Plot window. Here you can specify a single
@@ -580,14 +570,14 @@
or z as a complex variable (where x 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 4-5. For plotting using the command line see
+ to |cos(x+1i*y)|. See Figure 5. For plotting using the command line see
the documentation of the SurfacePlot function.
- Figure 4-5. Surface Plot
+ Figure 5. Surface Plot
----------------------------------------------------------------------
- Chapter 5. GEL Basics
+ 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 an expression that
@@ -598,7 +588,7 @@
----------------------------------------------------------------------
-5.1. Values
+Values
Values in GEL can be numbers, Booleans or strings. Values can be used in
calculations, assigned to variables and returned from functions, among
@@ -606,46 +596,46 @@
----------------------------------------------------------------------
- 5.1.1. Numbers
+ Numbers
Integers are the first type of number in GEL. Integers are written in the
normal way.
- 1234
+ 1234
Hexidecimal and octal numbers can be written using C notation. For
example:
- 0x123ABC
- 01234
+ 0x123ABC
+ 01234
Or you can type numbers in an arbitrary base using <base>\<number>. Digits
higher than 10 use letters in a similar way to hexadecimal. For example, a
number in base 23 could be written:
- 23\1234ABCD
+ 23\1234ABCD
The second type of GEL number is rationals. Rationals are simply achieved
by dividing two integers. So one could write:
- 3/4
+ 3/4
to get three quarters. Rationals also accept mixed fraction notation. So
in order to get one and three tenths you could write:
- 1 3/10
+ 1 3/10
The next type if number is floating point. These are entered in a similar
fashion to C notation. You can use E, e or @ as the exponent delimiter.
Note that using the exponent delimiter gives a float even if there is no
decimal point in the number. Examples:
- 1.315
- 7.887e77
- 7.887e-77
- .3
- 0.3
- 77e5
+ 1.315
+ 7.887e77
+ 7.887e-77
+ .3
+ 0.3
+ 77e5
When Genius prints a floating point number it will always append a .0 even
if the number is whole. This is to indicate that floating point numbers
@@ -657,9 +647,9 @@
complex number as a sum of real and imaginary parts. The imaginary part
ends with an i. Here are examples of entering complex numbers:
- 1+2i
- 8.01i
- 77*e^(1.3i)
+ 1+2i
+ 8.01i
+ 77*e^(1.3i)
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
@@ -672,7 +662,7 @@
----------------------------------------------------------------------
- 5.1.2. Booleans
+ Booleans
Genius also supports native Boolean values. The two Boolean constants are
defined as true and false; these identifiers can be used like any other
@@ -686,59 +676,59 @@
In addition, you can do arithmetic with Boolean values. For example:
- ( (1 + true) - false ) * true
+ ( (1 + true) - false ) * true
is the same as:
- ( (true or true) or not false ) and true
+ ( (true or true) or not false ) and true
Only addition, subtraction and multiplication are supported. If you mix
numbers with Booleans in an expression then the numbers are converted to
Booleans as described above. This means that, for example:
- 1 == true
+ 1 == true
always evaluates to true since 1 will be converted to true before being
compared to true.
----------------------------------------------------------------------
- 5.1.3. Strings
+ Strings
Like numbers and Booleans, strings in GEL can be stored as values inside
variables and passed to functions. You can also concatenate a string with
another value using the plus operator. For example:
- a=2+3;"The result is: "+a
+ a=2+3;"The result is: "+a
will create the string:
- The result is: 5
+ The result is: 5
You can also use C-like escape sequences such as \n,\t,\b,\a and \r. To
get a \ or " into the string you can quote it with a \. For example:
- "Slash: \\ Quotes: \" Tabs: \t1\t2\t3"
+ "Slash: \\ Quotes: \" Tabs: \t1\t2\t3"
will make a string:
- Slash: \ Quotes: " Tabs: 1 2 3
+ Slash: \ Quotes: " Tabs: 1 2 3
In addition, you can use the library function string to convert anything
to a string. For example:
- string(22)
+ string(22)
will return
- "22"
+ "22"
Strings can also be compared with == (equal), != (not equal) and <=>
(comparison) operators
----------------------------------------------------------------------
- 5.1.4. Null
+ Null
There is a special value called null. No operations can be performed on
it, and nothing is printed when it is returned. Therefore, null is useful
@@ -749,8 +739,8 @@
Example:
- x=5;.
- x=5;
+ x=5;.
+ x=5;
Some functions return null when no value can be returned or an error
happened. Also null is used as an empty vector or matrix, or an empty
@@ -758,22 +748,22 @@
----------------------------------------------------------------------
-5.2. Using Variables
+Using Variables
Syntax:
- VariableName
+ VariableName
Example:
- genius> e
- = 2.71828182846
+ genius> e
+ = 2.71828182846
To evaluate a variable by itself, just enter the name of the 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 Section
- 5.3.1).
+ are necessary when defining functions that take arguments (see the Section
+ called Defining Functions).
Tip Using Tab completion
You can use Tab completion to get Genius to complete variable names
@@ -787,63 +777,66 @@
----------------------------------------------------------------------
- 5.2.1. Setting Variables
+ Setting Variables
Syntax:
- <identifier> = <value>
- <identifier> := <value>
+ <identifier> = <value>
+ <identifier> := <value>
Example:
- x = 3
- x := 3
+ x = 3
+ x := 3
To assign to a variable, use the = or := operators. These operators set
the value of the variable and return the number you set, so you can do
things like
- a = b = 5
+ a = b = 5
The = and := operators can both be used to set variables. The difference
between them is that the := operator always acts as an assignment
operator, whereas the = operator may be interpreted as testing for
equality when used in a context where a Boolean expression is expected.
- For issues regarding the scope of variables, see Section 6.5.
+ For issues regarding the scope of variables, see the Section called Global
+ Variables and Scope of Variables in the Chapter called Programming with
+ GEL.
----------------------------------------------------------------------
- 5.2.2. Built-in Variables
+ 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
- Section 11.4 for a full list.
+ the Section called Constants in the Chapter called List of GEL functions
+ for a full list.
----------------------------------------------------------------------
- 5.2.3. Previous Result Variable
+ 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 calculation, to add 389
to the result you could do:
- Ans+389
+ Ans+389
----------------------------------------------------------------------
-5.3. Using Functions
+Using Functions
Syntax:
- FunctionName(argument1, argument2, ...)
+ FunctionName(argument1, argument2, ...)
Example:
- Factorial(5)
- cos(2*pi)
- gcd(921,317)
+ Factorial(5)
+ cos(2*pi)
+ gcd(921,317)
To evaluate a function, enter the name of the function, followed by the
arguments (if any) to the function in parentheses. This will return the
@@ -852,7 +845,7 @@
There are many built-in functions, such as sin, cos and tan. You can use
the help built-in function to get a list of available functions, or see
- Chapter 11 for a full listing.
+ the Chapter called List of GEL functions for a full listing.
Tip Using Tab completion
You can use Tab completion to get Genius to complete function names
@@ -866,12 +859,12 @@
----------------------------------------------------------------------
- 5.3.1. Defining Functions
+ Defining Functions
Syntax:
- function <identifier>(<comma separated arguments>) = <function body>
- <identifier> = (`() = <function body>)
+ function <identifier>(<comma separated arguments>) = <function body>
+ <identifier> = (`() = <function body>)
The ` is the backquote character, and signifies an anonymous function. By
setting it to a variable name you effectively define a function.
@@ -882,13 +875,13 @@
defined in GEL files which Genius can load in order to make available.
Example:
- function addup(a,b,c) = a+b+c
+ function addup(a,b,c) = a+b+c
then addup(1,4,9) yields 14
----------------------------------------------------------------------
- 5.3.2. Variable Argument Lists
+ Variable Argument Lists
If you include ... after the last argument name in the function
declaration, then Genius will allow any number of arguments to be passed
@@ -896,13 +889,13 @@
will be set to null. Otherwise, it will be a horizontal vector containing
all the arguments. For example:
- function f(a,b...) = b
+ function f(a,b...) = b
Then f(1,2,3) yields [2,3], while f(1) yields a null.
----------------------------------------------------------------------
- 5.3.3. Passing Functions to Functions
+ 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 nodes' or anonymous
@@ -912,71 +905,71 @@
being evaluated, the function will instead be returned as a `function
node'. The function node can then be passed to another function. Example:
- function f(a,b) = a(b)+1;
- function b(x) = x*x;
- f(b,2)
+ function f(a,b) = a(b)+1;
+ function b(x) = x*x;
+ f(b,2)
If you want to pass a function that doesn't exist yet, you can use an
- anonymous function (see Section 5.3.1).
+ anonymous function (see the Section called Defining Functions).
Syntax:
- function(<comma separated arguments>) = <function body>
- `(<comma separated arguments>) = <function body>
+ function(<comma separated arguments>) = <function body>
+ `(<comma separated arguments>) = <function body>
Example:
- function f(a,b) = a(b)+1;
- f(`(x) = x*x,2)
+ function f(a,b) = a(b)+1;
+ f(`(x) = x*x,2)
----------------------------------------------------------------------
- 5.3.4. Operations on Functions
+ Operations on Functions
Some functions allow arithmetic operations, and some single argument
functions such as exp or ln, to operate on the function. For example,
- exp(sin*cos+4)
+ exp(sin*cos+4)
will return a function that does
- exp(sin(x)*cos(x)+4)
+ exp(sin(x)*cos(x)+4)
This can be useful when quickly defining functions. For example to create
a function to perform the above operation, you can just type:
- f = exp(sin*cos+4)
+ f = exp(sin*cos+4)
This can also be used in plotting. For example, to plot sin squared you
can enter:
- LinePlot(sin^2)
+ LinePlot(sin^2)
Warning Not all functions can be used in this way. In addition, when you
use a binary operation the functions must take the same arguments.
----------------------------------------------------------------------
-5.4. Absolute Value / Modulus
+Absolute Value / Modulus
You can make an absolute value of something by putting the |'s around it.
For example:
- |a-b|
+ |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.5. 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:
- 3 ; 5
+ 3 ; 5
This expression will yield 5.
@@ -994,26 +987,26 @@
----------------------------------------------------------------------
-5.6. Modular Evaluation
+Modular Evaluation
Sometimes when working with large numbers, it might be faster if results
are modded after each calculation. To use it you just add "mod <integer>"
after the expression. Example:
- 2^(5!) * 3^(6!) mod 5
+ 2^(5!) * 3^(6!) mod 5
You can calculate the inverses of numbers mod some integer by just using
rational numbers (of course the inverse has to exist). Examples:
- 10^-1 mod 101
- 1/10 mod 101
+ 10^-1 mod 101
+ 1/10 mod 101
You can also do modular evaluation with matrices including taking
inverses, powers and dividing. Example:
- A = [1,2;3,4]
- B = A^-1 mod 5
- A*B mod 5
+ A = [1,2;3,4]
+ B = A^-1 mod 5
+ A*B mod 5
This should yield the identity matrix as B will be the inverse of A mod 5.
@@ -1021,49 +1014,49 @@
mode. These will then work like their discrete versions working within the
ring of integers you selected. For example:
- genius> sqrt(4) mod 7
- =
- [2, 5]
- genius> 2*2 mod 7
- = 4
+ genius> sqrt(4) mod 7
+ =
+ [2, 5]
+ genius> 2*2 mod 7
+ = 4
sqrt will actually return all the possible square roots.
----------------------------------------------------------------------
-5.7. List of GEL Operators
+List of GEL Operators
As everything in gel is really just an expression, it is really just all
connected together with operators. Here is a list of the operators in GEL.
- a;b
+ a;b
The separator, just evaluates both a and b, but returns only the
result of b.
- a=b
+ a=b
The assignment operator. This assigns b to a (a must be a valid
lvalue) (note however that this operator may be translated to ==
if used in a place where boolean expression is expected)
- a:=b
+ a:=b
The assignment operator. Assigns b to a (a must be a valid
lvalue). This is different from = because it never gets translated
to a ==.
- |a|
+ |a|
Absolute value or modulus (if a is a complex number).
See Mathworld for more information.
- a^b
+ a^b
Exponentiation, raises a to the bth power.
- a.^b
+ a.^b
Element by element exponentiation. Raise each element of a matrix
a to the bth power. Or if b is a matrix of the same size as a,
@@ -1071,185 +1064,187 @@
is a matrix then it creates matrix of the same size as b with a
raised to all the different powers in b.
- a+b
+ a+b
Addition. Adds two numbers, matrices, functions or strings. If you
add a string to anything the result will just be a string.
- a-b
+ a-b
Subtraction. Subtract two numbers, matrices or functions.
- a*b
+ a*b
Multiplication. This is the normal matrix multiplication.
- a.*b
+ a.*b
Element by element multiplication if a and b are matrices.
- a/b
+ a/b
Division.
- a./b
+ a./b
Element by element division.
- a\b
+ a\b
Back division. That is this is the same as b/a.
- a.\b
+ a.\b
Element by element back division.
- a%b
+ a%b
The mod operator. This does not turn on the modular mode, but just
returns the remainder of a/b.
- a.%b
+ a.%b
Element by element the mod operator. Returns the remaineder after
element by element a./b.
- a mod b
+ a mod b
Modular evaluation operator. The expression a is evaluated modulo
- b. See Section 5.6. Some functions and operators behave
- differently modulo an integer.
+ b. See the Section called Modular Evaluation. Some functions and
+ operators behave differently modulo an integer.
- a!
+ a!
Factorial operator. This is like 1*...*(n-2)*(n-1)*n.
- a!!
+ a!!
Double factorial operator. This is like 1*...*(n-4)*(n-2)*n.
- a==b
+ a==b
Equality operator (returns true or false).
- a!=b
+ a!=b
Inequality operator, returns true if a does not equal b else
returns false.
- a<>b
+ a<>b
Alternative inequality operator, returns true if a does not equal
b else returns false.
- a<=b
+ a<=b
Less than or equal operator, returns true if a is less than or
equal to b else returns false.
- a>=b
+ a>=b
Greater than or equal operator, returns true if a is greater than
or equal to b else returns false.
- a<=>b
+ a<=>b
Comparison operator. If a is equal to b it returns 0, if a is less
than b it returns -1 and if a is greater than b it returns 1.
- a and b
+ a and b
Logical and.
- a or b
+ a or b
Logical or.
- a xor b
+ a xor b
Logical xor.
- not a
+ not a
Logical not.
- -a
+ -a
Negation operator.
- &a
+ &a
- Variable referencing (to pass a reference to something). See
- Section 6.7.
+ Variable referencing (to pass a reference to something). See the
+ Section called References in the Chapter called Programming with
+ GEL.
- *a
+ *a
- Variable dereferencing (to access a referenced varible). See
- Section 6.7.
+ Variable dereferencing (to access a referenced varible). See the
+ Section called References in the Chapter called Programming with
+ GEL.
- a'
+ a'
Matrix conjugate transpose.
- a.'
+ a.'
Matrix transpose, does not conjugate the entries.
- a@(b,c)
+ a@(b,c)
Get element of a matrix in row b and column c. If b, c are
vectors, then this gets the corresponding rows columns or
submatrices.
- a@(b,)
+ a@(b,)
Get row of a matrix (or rows if b is a vector).
- a@(b,:)
+ a@(b,:)
Same as above.
- a@(,c)
+ a@(,c)
Get column of a matrix (or columns if c is a vector).
- a@(:,c)
+ a@(:,c)
Same as above.
- a@(b)
+ a@(b)
Get an element from a matrix treating it as a vector. This will
traverse the matrix row-wise.
- a:b
+ a:b
Build a vector from a to b (or specify a row, column region for
the @ operator). For example to get rows 2 to 4 of mamtrix A we
could do
- A@(2:4,)
-
+ A@(2:4,)
+
as 2:4 will return a vector [2,3,4].
- a:b:c
+ a:b:c
Build a vector from a to c with b as a step. That is for example
- genius> 1:2:9
- =
- `[1, 3, 5, 7, 9]
+ genius> 1:2:9
+ =
+ `[1, 3, 5, 7, 9]
- (a)i
+ (a)i
Make a imaginary number (multiply a by the imaginary). Note that
normally the number i is written as 1i. So the above is equal to
- (a)*1i
-
+ (a)*1i
+
- `a
+ `a
Quote an identifier so that it doesn't get evaluated. Or quote a
matrix so that it doesn't get expanded.
@@ -1276,45 +1271,45 @@
----------------------------------------------------------------------
- Chapter 6. Programming with GEL
+ Programming with GEL
-6.1. Conditionals
+Conditionals
Syntax:
- if <expression1> then <expression2> [else <expression3>]
+ if <expression1> then <expression2> [else <expression3>]
If else is omitted, then if the expression1 yields false or 0, NULL is
returned.
Examples:
- if(a==5)then(a=a-1)
- if b<a then b=a
- if c>0 then c=c-1 else c=0
- a = ( if b>0 then b else 1 )
+ if(a==5)then(a=a-1)
+ if b<a then b=a
+ if c>0 then c=c-1 else c=0
+ a = ( if b>0 then b else 1 )
Note that = will be translated to == if used inside the expression for if,
so
- if a=5 then a=a-1
+ if a=5 then a=a-1
will be interpreted as:
- if a==5 then a:=a-1
+ if a==5 then a:=a-1
----------------------------------------------------------------------
-6.2. Loops
+Loops
- 6.2.1. While Loops
+ While Loops
Syntax:
- while <expression1> do <expression2>
- until <expression1> do <expression2>
- do <expression2> while <expression1>
- do <expression2> until <expression1>
+ while <expression1> do <expression2>
+ until <expression1> do <expression2>
+ do <expression2> while <expression1>
+ do <expression2> until <expression1>
These are similiar to other languages, however they return the result of
the last iteration or NULL if no iteration was done. In the boolean
@@ -1322,12 +1317,12 @@
----------------------------------------------------------------------
- 6.2.2. For Loops
+ For Loops
Syntax:
- for <identifier> = <from> to <to> do <body>
- for <identifier> = <from> to <to> by <increment> do <body>
+ for <identifier> = <from> to <to> do <body>
+ for <identifier> = <from> to <to> by <increment> do <body>
Loop with identifier being set to all values from <from> to <to>,
optionally using an increment other than 1. These are faster, nicer and
@@ -1339,55 +1334,55 @@
complex values. The <to> is not guaranteed to be hit, but will never be
overshot, for example the following prints out odd numbers from 1 to 19:
- for i = 1 to 20 by 2 do print(i)
+ for i = 1 to 20 by 2 do print(i)
----------------------------------------------------------------------
- 6.2.3. Foreach Loops
+ Foreach Loops
Syntax:
- for <identifier> in <matrix> do <body>
+ for <identifier> in <matrix> do <body>
For each element, going row by row from left to right do the body. To
print numbers 1,2,3 and 4 in this order you could do:
- for n in [1,2:3,4] do print(n)
+ for n in [1,2:3,4] do print(n)
If you wish to run through the rows and columns of a matrix, you can use
the RowsOf and ColumnsOf functions which return a vector of the rows or
columns of the matrix. So,
- for n in RowsOf ([1,2:3,4]) do print(n)
+ for n in RowsOf ([1,2:3,4]) do print(n)
will print out [1,2] and then [3,4].
----------------------------------------------------------------------
- 6.2.4. Break and Continue
+ 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 next iteration,
while the break command exits the current loop.
- while(<expression1>) do (
- if(<expression2>) break
- else if(<expression3>) continue;
- <expression4>
- )
+ while(<expression1>) do (
+ if(<expression2>) break
+ else if(<expression3>) continue;
+ <expression4>
+ )
----------------------------------------------------------------------
-6.3. Sums and Products
+Sums and Products
Syntax:
- sum <identifier> = <from> to <to> do <body>
- sum <identifier> = <from> to <to> by <increment> do <body>
- sum <identifier> in <matrix> do <body>
- prod <identifier> = <from> to <to> do <body>
- prod <identifier> = <from> to <to> by <increment> do <body>
- prod <identifier> in <matrix> do <body>
+ sum <identifier> = <from> to <to> do <body>
+ sum <identifier> = <from> to <to> by <increment> do <body>
+ sum <identifier> in <matrix> do <body>
+ prod <identifier> = <from> to <to> do <body>
+ prod <identifier> = <from> to <to> by <increment> do <body>
+ prod <identifier> in <matrix> do <body>
If you substitute for with sum or prod, then you will get a sum or a
product instead of a for loop. Instead of returning the last value, these
@@ -1398,7 +1393,7 @@
----------------------------------------------------------------------
-6.4. Comparison Operators
+Comparison Operators
The following standard comparison operators are supported in GEL and have
the obvious meaning: ==, >=, <=, !=, <>, <, >. They return true or false.
@@ -1409,8 +1404,8 @@
Normally = is translated to == if it happens to be somewhere where GEL is
expecing a condition such as in the if condition. For example
- if a=b then c
- if a==b then c
+ if a=b then c
+ if a==b then c
are the same thing in GEL. However you should really use == or := when you
want to compare or assign respectively if you want your code to be easy to
@@ -1429,30 +1424,33 @@
----------------------------------------------------------------------
-6.5. Global Variables and Scope of Variables
+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 dynamically scoped. The
+ exception are parameter variables, which are always global.
Like most programming languages, GEL has different types of variables.
Normally when a variable is defined in a function, it is visible from that
function and from all functions that are called (all higher contexts). For
example, suppose a function f defines a variable a and then calls function
g. Then function g can reference a. But once f returns, the variable a
- goes out of scope. This is where GEL differs from a language such as C.
- One could describe variables as being semi global in a sense For example,
- the following code will print out 5. The function g cannot be called on
- the top level (outside f as a will not be defined).
+ goes out of scope. For example, the following code will print out 5. The
+ function g cannot be called on the top level (outside f as a will not be
+ defined).
- function f() = (a:=5; g());
- function g() = print(a);
- f();
+ function f() = (a:=5; g());
+ function g() = print(a);
+ f();
If you define a variable inside a function it will override any variables
defined in calling functions. For example, we modify the above code and
write:
- function f() = (a:=5; g());
- function g() = print(a);
- a:=10;
- f();
+ function f() = (a:=5; g());
+ function g() = print(a);
+ a:=10;
+ f();
This code will still print out 5. But if you call g outside of f then you
will get a printout of 10. Note that setting a to 5 inside f does not
@@ -1469,33 +1467,33 @@
protected variables and functions. But locally you can do this. Consider
the following session:
- genius> function f(x) = sin(x)^2
- = (`(x)=(sin(x)^2))
- genius> function f(x) = sin(x)^2
- = (`(x)=(sin(x)^2))
- genius> function g(x) = ((function sin(x)=x^10);f(x))
- = (`(x)=((sin:=(`(x)=(x^10)));f(x)))
- genius> g(10)
- = 1e20
+ genius> function f(x) = sin(x)^2
+ = (`(x)=(sin(x)^2))
+ genius> function f(x) = sin(x)^2
+ = (`(x)=(sin(x)^2))
+ genius> function g(x) = ((function sin(x)=x^10);f(x))
+ = (`(x)=((sin:=(`(x)=(x^10)));f(x)))
+ genius> g(10)
+ = 1e20
Functions and variables defined at the top level are considered global.
They are visible from anywhere. As we said the following function f will
not change the value of a to 5.
- a=6;
- function f() = (a:=5);
- f();
+ a=6;
+ function f() = (a:=5);
+ f();
Sometimes, however, it is neccessary to set a global variable from inside
a function. When this behaviour is needed, use the set function. Passing a
string or a quoted identifier to this function sets the variable globally
(on the top level). For example, to set a to the value 3 you could call:
- set(`a,3)
+ set(`a,3)
or:
- set("a",3)
+ set("a",3)
The set function always sets the toplevel global. There is no way to set a
local variable in some function from a subroutine. If this is required,
@@ -1510,14 +1508,33 @@
new local variable in the current context number and this variable will
now be visible from all higher numbered contexts.
- There are also true local variables which are not seen from anywhere but
+ There are also true local variables, which are not seen from anywhere but
the current context. Also when returning functions by value it may
reference variables not visible from higher context and this may be a
problem. See the sections True Local Variables and Returning Functions.
----------------------------------------------------------------------
-6.6. Returning
+Parameter variables
+
+ As we said before, there exist special variables called parameters that
+ exist in all scopes. To declare a parameter called foo with the initial
+ value 1, we write
+
+ parameter foo = 1
+
+ From then on, foo is a strictly global variable. Setting foo inside any
+ function will modify the variable in all contexts, that is, functions do
+ not have a private copy of parameters.
+
+ When you undefine a parameter using the undefine function, it stops
+ being a parameter.
+
+ Some parameters are built-in and modify the behaviour of genius.
+
+ ----------------------------------------------------------------------
+
+Returning
Normally a function is one or several expressions separated by a
semicolon, and the value of the last expression is returned. This is fine
@@ -1528,18 +1545,18 @@
Example:
- function f(x) = (
- y=1;
- while true do (
- if x>50 then return y;
- y=y+1;
- x=x+1
- )
- )
+ function f(x) = (
+ y=1;
+ while true do (
+ if x>50 then return y;
+ y=y+1;
+ x=x+1
+ )
+ )
----------------------------------------------------------------------
-6.7. References
+References
It may be neccessary for some functions to return more than one value.
This may be accomplished by returning a vector of values, but many times
@@ -1548,13 +1565,13 @@
variable for you using a dereference. You do not have to use references
only for this purpose, but this is their main use.
- When using functions which return values through references in the
- argument list, just pass the variable name with an ampersand. For example
- the following code will compute an eigenvalue of a matrix A with initial
+ When using functions that return values through references in the argument
+ list, just pass the variable name with an ampersand. For example the
+ following code will compute an eigenvalue of a matrix A with initial
eigenvector guess x, and store the computed eigenvector into the variable
named v:
- RayleighQuotientIteration (A,x,0.001,100,&v)
+ RayleighQuotientIteration (A,x,0.001,100,&v)
The details of how references work and the syntax is similar to the C
language. The operator & references a variable and * dereferences a
@@ -1563,21 +1580,21 @@
References are best explained by an example:
- a=1;
- b=&a;
- *b=2;
+ a=1;
+ b=&a;
+ *b=2;
now a contains 2. You can also reference functions:
- function f(x) = x+1;
- t=&f;
- *t(3)
+ function f(x) = x+1;
+ t=&f;
+ *t(3)
gives us 4.
----------------------------------------------------------------------
-6.8. Lvalues
+Lvalues
An lvalue is the left hand side of an assignment. In other words, an
lvalue is what you assign something to. Valid lvalues are:
@@ -1599,10 +1616,10 @@
Examples:
- a:=4
- *tmp := 89
- a@(1,1) := 5
- a@(4:8,3) := [1,2,3,4,5]'
+ a:=4
+ *tmp := 89
+ a@(1,1) := 5
+ a@(4:8,3) := [1,2,3,4,5]'
Note that both := and = can be used interchangably. Except if the
assignment appears in a condition. It is thus always safer to just use :=
@@ -1610,9 +1627,9 @@
----------------------------------------------------------------------
- Chapter 7. Advanced Programming with GEL
+ Advanced Programming with GEL
-7.1. Error Handling
+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 can fail to compute
@@ -1623,17 +1640,17 @@
For example if you want to check for arguments in your function. You could
use the following code.
- function f(M) = (
- if not IsMatrix (M) then (
- error ("M not a matrix!");
- bailout
- );
- ...
- )
+ function f(M) = (
+ if not IsMatrix (M) then (
+ error ("M not a matrix!");
+ bailout
+ );
+ ...
+ )
----------------------------------------------------------------------
-7.2. Toplevel Syntax
+Toplevel Syntax
The synatax is slightly different if you enter statements on the top level
versus when they are inside parentheses or inside functions. On the top
@@ -1646,10 +1663,10 @@
The following code will produce an error when entered on the top level of
a program, while it will work just fine in a function.
- if Something() then
- DoSomething()
- else
- DoSomethingElse()
+ if Something() then
+ DoSomething()
+ else
+ DoSomethingElse()
The problem is that after Genius Mathematics Tool sees the end of line
after the second line, it will decide that we have whole statement and it
@@ -1658,47 +1675,47 @@
error. To fix this, use parentheses. Genius Mathematics Tool will not be
satisfied until it has found that all parenteses are closed.
- if Something() then (
- DoSomething()
- ) else (
- DoSomethingElse()
- )
+ if Something() then (
+ DoSomething()
+ ) else (
+ DoSomethingElse()
+ )
----------------------------------------------------------------------
-7.3. Returning Functions
+Returning Functions
It is possible to return functions as value. This way you can build
- functions which construct special purpose functions according to some
+ functions that construct special purpose functions according to some
parameters. The tricky bit is what variables does the function see. The
way this works in GEL is that when a function returns another function,
all identifiers referenced in the function body that went out of scope are
prepended a private dictionary of the returned function. So the function
- will see all variables that were in scope when it was defined. For example
- we define a function which returns a function which adds 5 to its
+ will see all variables that were in scope when it was defined. For
+ example, we define a function that returns a function that adds 5 to its
argument.
- function f() = (
- k = 5;
- `(x) = (x+k)
- )
+ function f() = (
+ k = 5;
+ `(x) = (x+k)
+ )
Notice that the function adds k to x. You could use this as follows.
- g = f();
- g(5)
+ g = f();
+ g(5)
And g(5) should return 10.
One thing to note is that the value of k that is used is the one that's in
effect when the f returns. For example:
- function f() = (
- k := 5;
- function r(x) = (x+k);
- k := 10;
- r
- )
+ function f() = (
+ k := 5;
+ function r(x) = (x+k);
+ k := 10;
+ r
+ )
will return a function that adds 10 to its argument rather than 5. This is
because the extra dictionary is created only when the context in which the
@@ -1725,12 +1742,12 @@
private dictionary at time of the function definition, and the private
dictionary is not touched afterwards. For example
- function f() = (
- k := 5;
- function r(x) [k] = (x+k);
- k := 10;
- r
- )
+ function f() = (
+ k := 5;
+ function r(x) [k] = (x+k);
+ k := 10;
+ r
+ )
will return a function that when called will add 5 to its argument. The
local copy of k was created when the function was defined.
@@ -1744,32 +1761,32 @@
despite there being a local variable of the same name during definition.
So the code
- function f() = (
- k := 5;
- function r(x) [] = (x+k);
- r
- );
- k := 10;
- g = f();
- g(10)
+ function f() = (
+ k := 5;
+ function r(x) [] = (x+k);
+ r
+ );
+ k := 10;
+ g = f();
+ g(10)
will return 20 and not 15, which would happen if k with a value of 5 was
added to the private dictionary.
----------------------------------------------------------------------
-7.4. True Local Variables
+True Local Variables
When passing functions into other functions, the normal scoping of
variables might be undesired. For example:
- k := 10;
- function r(x) = (x+k);
- function f(g,x) = (
- k := 5;
- g(x)
- );
- f(r,1)
+ k := 10;
+ function r(x) = (x+k);
+ function f(g,x) = (
+ k := 5;
+ g(x)
+ );
+ f(r,1)
you probably want the function r when passed as g into f to see k as 10
rather than 5, so that the code returns 11 and not 6. However, as written,
@@ -1785,11 +1802,11 @@
function). You can also make any arguments be local variables as well.
That is,
- function f(g,x) = (
- local g,x,k;
- k := 5;
- g(x)
- );
+ function f(g,x) = (
+ local g,x,k;
+ k := 5;
+ g(x)
+ );
Then the code will work as expected and prints out 11. Note that the local
statement initializes all the refereced variables (except for function
@@ -1800,11 +1817,11 @@
initialized until they are actually set of course. So the following
definition of f will also work:
- function f(g,x) = (
- local *;
- k := 5;
- g(x)
- );
+ function f(g,x) = (
+ local *;
+ k := 5;
+ g(x)
+ );
It is good practice that all functions that take other functions as
arguments use local variables. This way the passed function does not see
@@ -1812,7 +1829,7 @@
----------------------------------------------------------------------
-7.5. GEL Startup Procedure
+GEL Startup Procedure
First the program looks for the installed library file (the compiled
version lib.cgel) in the installed directory, then it looks into the
@@ -1824,7 +1841,7 @@
----------------------------------------------------------------------
-7.6. Loading Programs
+Loading Programs
Sometimes you have a larger program that you wrote into a file and want to
read in that file. In these situations, you have two options. You can keep
@@ -1838,26 +1855,26 @@
typed, if you use the "" quotes, special characters will be unescaped as
they are for strings. Example:
- load program1.gel program2.gel
- load "Weird File Name With SPACES.gel"
+ load program1.gel program2.gel
+ load "Weird File Name With SPACES.gel"
There are also cd, pwd and ls commands built in. cd will take one
- argument, ls will take an argument which is like the glob in the unix
- shell (i.e., you can use wildcards). pwd takes no arguments. For example:
+ argument, ls will take an argument that is like the glob in the unix shell
+ (i.e., you can use wildcards). pwd takes no arguments. For example:
- cd directory_with_gel_programs
- ls *.gel
+ cd directory_with_gel_programs
+ ls *.gel
----------------------------------------------------------------------
- Chapter 8. Matrices in GEL
+ Matrices in GEL
Genius has support for vectors and matrices and a sizable library of
matrix manipulation and linear algebra functions.
----------------------------------------------------------------------
-8.1. Entering Matrices
+Entering Matrices
To enter matrixes, you can use one of the following two syntaxes. You can
either enter the matrix on one line, separating values by commas and rows
@@ -1865,46 +1882,46 @@
commas. You can also just combine the two methods. So to enter a 3x3
matrix of numbers 1-9 you could do
- [1,2,3;4,5,6;7,8,9]
+ [1,2,3;4,5,6;7,8,9]
or
- [1, 2, 3
- 4, 5, 6
- 7, 8, 9]
+ [1, 2, 3
+ 4, 5, 6
+ 7, 8, 9]
Do not use both ';' and return at once on the same line though.
You can also use the matrix expansion functionality to enter matricies.
For example you can do:
- a = [ 1, 2, 3
- 4, 5, 6
- 7, 8, 9]
- b = [ a, 10
- 11, 12]
+ a = [ 1, 2, 3
+ 4, 5, 6
+ 7, 8, 9]
+ b = [ a, 10
+ 11, 12]
and you should get
- [1, 2, 3, 10
- 4, 5, 6, 10
- 7, 8, 9, 10
- 11, 11, 11, 12]
+ [1, 2, 3, 10
+ 4, 5, 6, 10
+ 7, 8, 9, 10
+ 11, 11, 11, 12]
similiarly you can build matricies out of vectors and other stuff like
that.
Another thing is that non-specified spots are initialized to 0, so
- [1, 2, 3
- 4, 5
- 6]
+ [1, 2, 3
+ 4, 5
+ 6]
will end up being
- [1, 2, 3
- 4, 5, 0
- 6, 0, 0]
+ [1, 2, 3
+ 4, 5, 0
+ 6, 0, 0]
When matrices are evaluated, they are evaluated and traversed row-wise.
This is just like the M@(j) operator which traverses the matrix row-wise.
@@ -1915,20 +1932,20 @@
----------------------------------------------------------------------
-8.2. Conjugate Transpose and Transpose Operator
+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 complex conjugate of
the entry in the jth column and the ith row of the original matrix. For
example:
- [1,2,3]*[4,5,6]'
+ [1,2,3]*[4,5,6]'
We transpose the second vector to make matrix multiplication possible. If
you just want to transpose a matrix without conjugating it, you would use
the .' operator. For example:
- [1,2,3]*[4,5,6i].'
+ [1,2,3]*[4,5,6i].'
Note that normal transpose, that is the .' operator, is much faster and
will not create a new copy of the matrix in memory. The conjugate
@@ -1937,7 +1954,7 @@
----------------------------------------------------------------------
-8.3. Linear Algebra
+Linear Algebra
Genius implements many useful linear algebra and matrix manipulation
routines. See the Linear Algebra and Matrix Manipulation sections of the
@@ -1966,13 +1983,13 @@
It should be noted that Genius can remember certain properties of a
matrix. For example, it will remember that a matrix is in row reduced
- form. If many calls are made to functions which internally use row reduced
+ form. If many calls are made to functions that internally use row reduced
form of the matrix, we can just row reduce the matrix beforehand once.
Successive calls to rref will be very fast.
----------------------------------------------------------------------
- Chapter 9. Polynomials in GEL
+ 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
@@ -1980,34 +1997,34 @@
----------------------------------------------------------------------
-9.1. Using Polynomials
+Using Polynomials
Currently polynomials in one variable are just horizontal vectors with
value only nodes. The power of the term is the position in the vector,
with the first position being 0. So,
- [1,2,3]
+ [1,2,3]
translates to a polynomial of
- 1 + 2*x + 3*x^2
+ 1 + 2*x + 3*x^2
You can add, subtract and multiply polynomials using the AddPoly,
SubtractPoly, and MultiplyPoly functions respectively. You can print a
polynomial using the PolyToString function. For example,
- PolyToString([1,2,3],"y")
+ PolyToString([1,2,3],"y")
gives
- 3*y^2 + 2*y + 1
+ 3*y^2 + 2*y + 1
You can also get a function representation of the polynomial so that you
can evaluate it. This is done by using PolyToFunction, which returns an
- anonymous function which you can assign to something.
+ anonymous function.
- f = PolyToFunction([0,1,1])
- f(2)
+ f = PolyToFunction([0,1,1])
+ f(2)
It is also possible to find roots of polynomials of degrees 1 through 4 by
using the function PolynomialRoots, which calls the appropriate formula
@@ -2015,12 +2032,13 @@
solved numerically using a function such as FindRootBisection,
FindRootFalsePosition, FindRootMullersMethod, or FindRootSecant.
- See Section 11.15 in the function list for the rest of functions acting on
+ 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.
----------------------------------------------------------------------
- Chapter 10. Set Theory in GEL
+ 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
@@ -2028,7 +2046,7 @@
----------------------------------------------------------------------
-10.1. Using Sets
+Using Sets
Just like vectors, objects in sets can include numbers, strings, null,
matrices and vectors. It is planned in the future to have a dedicated type
@@ -2040,14 +2058,14 @@
To build a set out of a vector, use the MakeSet function. Currently, it
will just return a new vector where every element is unique.
- genius> MakeSet([1,2,2,3])
- = [1, 2, 3]
+ genius> MakeSet([1,2,2,3])
+ = [1, 2, 3]
Similarly there are functions Union, Intersection, SetMinus, which are
rather self explanatory. For example:
- genius> Union([1,2,3], [1,2,4])
- = [1, 2, 4, 3]
+ genius> Union([1,2,3], [1,2,4])
+ = [1, 2, 4, 3]
Note that no order is guaranteed for the return values. If you wish to
sort the vector you should use the SortVector function.
@@ -2055,8 +2073,8 @@
For testing membership, there are functions IsIn and IsSubset, which
return a boolean value. For example:
- genius> IsIn (1, [0,1,2])
- = true
+ genius> IsIn (1, [0,1,2])
+ = true
The input IsIn(x,X) is of course equivalent to IsSubset([x],X). Note that
since the empty set is a subset of every set, IsSubset(null,X) is always
@@ -2064,65 +2082,79 @@
----------------------------------------------------------------------
- Chapter 11. List of GEL functions
+ List of GEL functions
To get help on a specific function from the console type:
- help FunctionName
+ help FunctionName
----------------------------------------------------------------------
-11.1. Commands
+Commands
help
- help
+ help
- help FunctionName
+ help FunctionName
Print help (or help on a function/command).
load
- load "file.gel"
+ load "file.gel"
Load a file into the interpretor. The file will execute as if it
were typed onto the command line.
cd
- cd /directory/name
+ cd /directory/name
Change working directory to /directory/name.
pwd
- pwd
+ pwd
Print the current working directory.
ls
- ls
+ ls
List files in the current directory.
plugin
- plugin plugin_name
+ plugin plugin_name
Load a plugin. Plugin of that name must be installed on the system
in the proper directory.
----------------------------------------------------------------------
-11.2. Basic
+Basic
+
+ AskButtons
+
+ AskButtons (query)
+
+ AskButtons (query, button1, ...)
+
+ Asks a question and presents a list of buttons to the user (or a
+ menu of options in text mode). Returns the 1-based index of the
+ button pressed. That is, returns 1 if the first button was
+ pressed, 2 if the second button was pressed, and so on. If the
+ user closes the window (or simply hits enter in text mode), then
+ null is returned. The execution of the program is blocked until
+ the user responds.
AskString
- AskString (query)
+ AskString (query)
- AskString (query, default)
+ AskString (query, default)
Asks a question and lets the user enter a string which it then
returns. If the user cancels or closes the window, then null is
@@ -2132,33 +2164,33 @@
Compose
- Compose (f,g)
+ Compose (f,g)
Compose two functions and return a function that is the
composition of f and g.
ComposePower
- ComposePower (f,n,x)
+ ComposePower (f,n,x)
Compose and execute a function with itself n times, passing x as
argument. Returning x if n equals 0. Example:
- genius> function f(x) = x^2 ;
- genius> ComposePower (f,3,7)
- = 5764801
- genius> f(f(f(7)))
- = 5764801
+ genius> function f(x) = x^2 ;
+ genius> ComposePower (f,3,7)
+ = 5764801
+ genius> f(f(f(7)))
+ = 5764801
Evaluate
- Evaluate (str)
+ Evaluate (str)
Parses and evaluates a string.
GetCurrentModulo
- GetCurrentModulo
+ GetCurrentModulo
Get current modulo from the context outside the function. That is,
if outside of the function was executed in modulo (using mod) then
@@ -2169,13 +2201,13 @@
Identity
- Identity (x)
+ Identity (x)
Identity function, returns its argument.
IntegerFromBoolean
- IntegerFromBoolean (bval)
+ IntegerFromBoolean (bval)
Make integer (0 for false or 1 for true) from a boolean value.
bval can also be a number in which case a non-zero value will be
@@ -2183,13 +2215,13 @@
IsBoolean
- IsBoolean (arg)
+ IsBoolean (arg)
Check if argument is a boolean (and not a number).
IsDefined
- IsDefined (id)
+ IsDefined (id)
Check if an id is defined. You should pass a string or and
identifier. If you pass a matrix, each entry will be evaluated
@@ -2197,26 +2229,26 @@
IsFunction
- IsFunction (arg)
+ IsFunction (arg)
Check if argument is a function.
IsFunctionOrIdentifier
- IsFunctionOrIdentifier (arg)
+ IsFunctionOrIdentifier (arg)
Check if argument is a function or an identifier.
IsFunctionRef
- IsFunctionRef (arg)
+ IsFunctionRef (arg)
Check if argument is a function reference. This includes variable
references.
IsMatrix
- IsMatrix (arg)
+ IsMatrix (arg)
Check if argument is a matrix. Even though null is sometimes
considered an empty matrix, the function IsMatrix does not
@@ -2224,32 +2256,32 @@
IsNull
- IsNull (arg)
+ IsNull (arg)
Check if argument is a null.
IsString
- IsString (arg)
+ IsString (arg)
Check if argument is a text string.
IsValue
- IsValue (arg)
+ IsValue (arg)
Check if argument is a number.
Parse
- Parse (str)
+ Parse (str)
Parses but does not evaluate a string. Note that certain
precomputation is done during the parsing stage.
SetFunctionFlags
- SetFunctionFlags (id,flags...)
+ SetFunctionFlags (id,flags...)
Set flags for a function, currently "PropagateMod" and
"NoModuloArguments". If "PropagateMod" is set, then the body of
@@ -2260,37 +2292,37 @@
SetHelp
- SetHelp (id,category,desc)
+ SetHelp (id,category,desc)
Set the category and help description line for a function.
SetHelpAlias
- SetHelpAlias (id,alias)
+ SetHelpAlias (id,alias)
Sets up a help alias.
chdir
- chdir (dir)
+ chdir (dir)
Changes current directory, same as the cd.
display
- display (str,expr)
+ display (str,expr)
Display a string and an expression with a colon to separate them.
error
- error (str)
+ error (str)
Prints a string to the error stream (onto the console).
exit
- exit
+ exit
Aliases: quit
@@ -2298,7 +2330,7 @@
false
- false
+ false
Aliases: False FALSE
@@ -2306,13 +2338,13 @@
manual
- manual
+ manual
Displays the user manual.
print
- print (str)
+ print (str)
Prints an expression and then print a newline. The argument str
can be any expression. It is made into a string before being
@@ -2320,7 +2352,7 @@
printn
- printn (str)
+ printn (str)
Prints an expression without a trailing newline. The argument str
can be any expression. It is made into a string before being
@@ -2328,7 +2360,7 @@
protect
- protect (id)
+ protect (id)
Protect a variable from being modified. This is used on the
internal GEL functions to avoid them being accidentally
@@ -2336,7 +2368,7 @@
ProtectAll
- ProtectAll ()
+ ProtectAll ()
Protect all currently defined variables, parameters and functions
from being modified. This is used on the internal GEL functions to
@@ -2345,25 +2377,25 @@
set
- set (id,val)
+ set (id,val)
Set a global variable. The id can be either a string or a quoted
identifier as follows. For example:
- set(`x,1)
-
+ set(`x,1)
+
will set the global variable x to the value 1.
string
- string (s)
+ string (s)
Make a string. This will make a string out of any argument.
true
- true
+ true
Aliases: True TRUE
@@ -2371,7 +2403,7 @@
undefine
- undefine (id)
+ undefine (id)
Alias: Undefine
@@ -2382,7 +2414,7 @@
UndefineAll
- UndefineAll ()
+ UndefineAll ()
Undefine all unprotected global variables (including functions and
parameters). Normally Genius Mathematics Tool considers protected
@@ -2393,20 +2425,20 @@
unprotect
- unprotect (id)
+ unprotect (id)
Unprotect a variable from being modified.
UserVariables
- UserVariables ()
+ UserVariables ()
Return a vector of identifiers of user defined (unprotected)
global variables.
wait
- wait (secs)
+ wait (secs)
Waits a specified number of seconds. secs must be nonnegative.
Zero is accepted and nothing happens in this case, except possibly
@@ -2414,150 +2446,157 @@
version
- version
+ version
Returns the version of Genius as a horizontal 3-vector with major
version first, then minor version and finally patchlevel.
warranty
- warranty
+ warranty
Gives the warranty information.
----------------------------------------------------------------------
-11.3. Parameters
+Parameters
ChopTolerance
- ChopTolerance = number
+ ChopTolerance = number
Tolerance of the Chop function.
ContinuousNumberOfTries
- ContinuousNumberOfTries = number
+ ContinuousNumberOfTries = number
How many iterations to try to find the limit for continuity and
limits.
ContinuousSFS
- ContinuousSFS = number
+ ContinuousSFS = number
How many successive steps to be within tolerance for calculation
of continuity.
ContinuousTolerance
- ContinuousTolerance = number
+ ContinuousTolerance = number
Tolerance for continuity of functions and for calculating the
limit.
DerivativeNumberOfTries
- DerivativeNumberOfTries = number
+ DerivativeNumberOfTries = number
How many iterations to try to find the limit for derivative.
DerivativeSFS
- DerivativeSFS = number
+ DerivativeSFS = number
How many successive steps to be within tolerance for calculation
of derivative.
DerivativeTolerance
- DerivativeTolerance = number
+ DerivativeTolerance = number
Tolerance for calculating the derivatives of functions.
ErrorFunctionTolerance
- ErrorFunctionTolerance = number
+ ErrorFunctionTolerance = number
Tolerance of the ErrorFunction.
FloatPrecision
- FloatPrecision = number
+ FloatPrecision = number
Floating point precision.
FullExpressions
- FullExpressions = boolean
+ FullExpressions = boolean
Print full expressions, even if more than a line.
GaussDistributionTolerance
- GaussDistributionTolerance = number
+ GaussDistributionTolerance = number
Tolerance of the GaussDistribution function.
IntegerOutputBase
- IntegerOutputBase = number
+ IntegerOutputBase = number
Integer output base.
IsPrimeMillerRabinReps
- IsPrimeMillerRabinReps = number
+ IsPrimeMillerRabinReps = number
Number of extra Miller-Rabin tests to run on a number before
declaring it a prime in IsPrime.
- LinePlotWindow
-
- LinePlotWindow = [x1,x2,y1,y2]
-
- Sets the limits for line plotting functions such as LinePlot.
-
LinePlotDrawLegends
- LinePlotDrawLegends = true
+ LinePlotDrawLegends = true
Tells genius to draw the legends for line plotting functions such
as LinePlot.
+ LinePlotVariableNames
+
+ LinePlotVariableNames = ["x","y","z","t"]
+
+ Tells genius which variable names are used as default names for
+ line plotting functions such as LinePlot and friends.
+
+ LinePlotWindow
+
+ LinePlotWindow = [x1,x2,y1,y2]
+
+ Sets the limits for line plotting functions such as LinePlot.
+
MaxDigits
- MaxDigits = number
+ MaxDigits = number
Maximum digits to display.
MaxErrors
- MaxErrors = number
+ MaxErrors = number
Maximum errors to display.
MixedFractions
- MixedFractions = boolean
+ MixedFractions = boolean
If true, mixed fractions are printed.
NumericalIntegralFunction
- NumericalIntegralFunction = function
+ NumericalIntegralFunction = function
The function used for numerical integration in NumericalIntegral.
NumericalIntegralSteps
- NumericalIntegralSteps = number
+ NumericalIntegralSteps = number
Steps to perform in NumericalIntegral.
OutputChopExponent
- OutputChopExponent = number
+ OutputChopExponent = number
When another number in the object being printed (a matrix or a
value) is greater than 10-OutputChopWhenExponent, and the number
@@ -2573,13 +2612,13 @@
OutputChopWhenExponent
- OutputChopWhenExponent = number
+ OutputChopWhenExponent = number
When to chop output. See OutputChopExponent.
OutputStyle
- OutputStyle = string
+ OutputStyle = string
Output style, this can be normal, latex, mathml or troff.
@@ -2587,60 +2626,83 @@
is useful for pasting into documents. For example you can set this
to the latex by:
- OutputStyle = "latex"
+ OutputStyle = "latex"
ResultsAsFloats
- ResultsAsFloats = boolean
+ ResultsAsFloats = boolean
Convert all results to floats before printing.
ScientificNotation
- ScientificNotation = boolean
+ ScientificNotation = boolean
Use scientific notation.
+ SlopefieldTicks
+
+ SlopefieldTicks = [vertical,horizontal]
+
+ Sets the number of vertical and horizontal ticks in a slopefield
+ plot. (See SlopefieldPlot).
+
SumProductNumberOfTries
- SumProductNumberOfTries = number
+ SumProductNumberOfTries = number
How many iterations to try for InfiniteSum and InfiniteProduct.
SumProductSFS
- SumProductSFS = number
+ SumProductSFS = number
How many successive steps to be within tolerance for InfiniteSum
and InfiniteProduct.
SumProductTolerance
- SumProductTolerance = number
+ SumProductTolerance = number
Tolerance for InfiniteSum and InfiniteProduct.
+ SurfacePlotVariableNames
+
+ SurfacePlotVariableNames = ["x","y","z"]
+
+ Tells genius which variable names are used as default names for
+ surface plotting functions using SurfacePlot. Note that the z does
+ not refer to the dependent (vertical) axis, but to the indepent
+ complex variable z=x+iy.
+
SurfacePlotWindow
- SurfacePlotWindow = [x1,x2,y1,y2,z1,z2]
+ SurfacePlotWindow = [x1,x2,y1,y2,z1,z2]
Sets the limits for surface plotting (See SurfacePlot).
VectorfieldNormalized
- VectorfieldNormalized = true
+ VectorfieldNormalized = true
Should the vectorfield plotting have normalized arrow length. If
true, vector fields will only show direction and not magnitude.
(See VectorfieldPlot).
+ VectorfieldTicks
+
+ VectorfieldTicks = [vertical,horizontal]
+
+ Sets the number of vertical and horizontal ticks in a vectorfield
+ plot. (See VectorfieldPlot).
+
----------------------------------------------------------------------
-11.4. Constants
+Constants
CatalanConstant
- CatalanConstant
+ CatalanConstant
Catalan's Constant, approximately 0.915... It is defined to be the
series where terms are (-1^k)/((2*k+1)^2), where k ranges from 0
@@ -2650,7 +2712,7 @@
EulerConstant
- EulerConstant
+ EulerConstant
Aliases: gamma
@@ -2661,7 +2723,7 @@
GoldenRatio
- GoldenRatio
+ GoldenRatio
The Golden Ratio.
@@ -2669,7 +2731,7 @@
Gravity
- Gravity
+ Gravity
Free fall acceleration at sea level.
@@ -2677,7 +2739,7 @@
e
- e
+ e
The base of the natural logarithm. e^x is the exponential function
exp. This is the number approximately 2.71828182846...
@@ -2686,7 +2748,7 @@
pi
- pi
+ pi
The number pi, that is the ratio of a circle's circumference to
its diameter. This is approximately 3.14159265359...
@@ -2695,11 +2757,11 @@
----------------------------------------------------------------------
-11.5. Numeric
+Numeric
AbsoluteValue
- AbsoluteValue (x)
+ AbsoluteValue (x)
Aliases: abs
@@ -2712,13 +2774,13 @@
Chop
- Chop (x)
+ Chop (x)
Replace very small number with zero.
ComplexConjugate
- ComplexConjugate (z)
+ ComplexConjugate (z)
Aliases: conj Conj
@@ -2729,7 +2791,7 @@
Denominator
- Denominator (x)
+ Denominator (x)
Get the denominator of a rational number.
@@ -2737,7 +2799,7 @@
FractionalPart
- FractionalPart (x)
+ FractionalPart (x)
Return the fractional part of a number.
@@ -2745,7 +2807,7 @@
Im
- Im (z)
+ Im (z)
Aliases: ImaginaryPart
@@ -2755,31 +2817,34 @@
IntegerQuotient
- IntegerQuotient (m,n)
+ IntegerQuotient (m,n)
Division without remainder.
IsComplex
- IsComplex (num)
+ IsComplex (num)
Check if argument is a complex (non-real) number.
IsComplexRational
- IsComplexRational (num)
+ IsComplexRational (num)
- Check if argument is a possibly complex rational number.
+ Check if argument is a possibly complex rational number. That is,
+ if both real and imaginary parts are given as rational numbers. Of
+ course rational simply means "not stored as a floating point
+ number."
IsFloat
- IsFloat (num)
+ IsFloat (num)
Check if argument is a floating point number (non-complex).
IsGaussInteger
- IsGaussInteger (num)
+ IsGaussInteger (num)
Aliases: IsComplexInteger
@@ -2787,19 +2852,19 @@
IsInteger
- IsInteger (num)
+ IsInteger (num)
Check if argument is an integer (non-complex).
IsNonNegativeInteger
- IsNonNegativeInteger (num)
+ IsNonNegativeInteger (num)
Check if argument is a non-negative real integer.
IsPositiveInteger
- IsPositiveInteger (num)
+ IsPositiveInteger (num)
Aliases: IsNaturalNumber
@@ -2808,19 +2873,20 @@
IsRational
- IsRational (num)
+ IsRational (num)
- Check if argument is a rational number (non-complex).
+ Check if argument is a rational number (non-complex). Of course
+ rational simply means "not stored as a floating point number."
IsReal
- IsReal (num)
+ IsReal (num)
Check if argument is a real number.
Numerator
- Numerator (x)
+ Numerator (x)
Get the numerator of a rational number.
@@ -2828,7 +2894,7 @@
Re
- Re (z)
+ Re (z)
Aliases: RealPart
@@ -2838,7 +2904,7 @@
Sign
- Sign (x)
+ Sign (x)
Aliases: sign
@@ -2848,7 +2914,7 @@
ceil
- ceil (x)
+ ceil (x)
Aliases: Ceiling
@@ -2856,7 +2922,7 @@
exp
- exp (x)
+ exp (x)
The exponential function. This is the function e^x where e is the
base of the natural logarithm.
@@ -2865,14 +2931,14 @@
float
- float (x)
+ float (x)
Make number a floating point value. That is returns the floating
point representation of the number x.
floor
- floor (x)
+ floor (x)
Aliases: Floor
@@ -2880,28 +2946,28 @@
ln
- ln (x)
+ ln (x)
The natural logarithm, the logarithm to base e.
log
- log (x)
+ log (x)
- log (x,b)
+ log (x,b)
Logarithm of x base b (calls DiscreteLog if in modulo mode), if
base is not given, e is used.
log10
- log10 (x)
+ log10 (x)
Logarithm of x base 10.
log2
- log2 (x)
+ log2 (x)
Aliases: lg
@@ -2909,7 +2975,7 @@
max
- max (a,args...)
+ max (a,args...)
Aliases: Max Maximum
@@ -2917,7 +2983,7 @@
min
- min (a,args...)
+ min (a,args...)
Aliases: Min Minimum
@@ -2925,7 +2991,7 @@
rand
- rand (size...)
+ rand (size...)
Generate random float in the range [0,1). If size is given then a
matrix (if two numbers are specified) or vector (if one number is
@@ -2933,25 +2999,25 @@
randint
- randint (max,size...)
+ randint (max,size...)
Generate random integer in the range [0,max). If size is given
then a matrix (if two numbers are specified) or vector (if one
number is specified) of the given size returned. For example
- genius> randint(4)
- = 3
- genius> randint(4,2)
- =
- [0 1]
- genius> randint(4,2,3)
- =
- [2 2 1
- 0 0 3]
+ genius> randint(4)
+ = 3
+ genius> randint(4,2)
+ =
+ [0 1]
+ genius> randint(4,2,3)
+ =
+ [2 2 1
+ 0 0 3]
round
- round (x)
+ round (x)
Aliases: Round
@@ -2959,28 +3025,28 @@
sqrt
- sqrt (x)
+ sqrt (x)
Aliases: SquareRoot
The square root. When operating modulo some integer will return
either a null or a vector of the square roots. Examples:
- genius> sqrt(2)
- = 1.41421356237
- genius> sqrt(-1)
- = 1i
- genius> sqrt(4) mod 7
- =
- [2 5]
- genius> 2*2 mod 7
- = 4
+ genius> sqrt(2)
+ = 1.41421356237
+ genius> sqrt(-1)
+ = 1i
+ genius> sqrt(4) mod 7
+ =
+ [2 5]
+ genius> 2*2 mod 7
+ = 4
See Planetmath for more information.
trunc
- trunc (x)
+ trunc (x)
Aliases: Truncate IntegerPart
@@ -2988,11 +3054,11 @@
----------------------------------------------------------------------
-11.6. Trigonometry
+Trigonometry
acos
- acos (x)
+ acos (x)
Aliases: arccos
@@ -3000,7 +3066,7 @@
acosh
- acosh (x)
+ acosh (x)
Aliases: arccosh
@@ -3008,7 +3074,7 @@
acot
- acot (x)
+ acot (x)
Aliases: arccot
@@ -3016,7 +3082,7 @@
acoth
- acoth (x)
+ acoth (x)
Aliases: arccoth
@@ -3024,7 +3090,7 @@
acsc
- acsc (x)
+ acsc (x)
Aliases: arccsc
@@ -3032,7 +3098,7 @@
acsch
- acsch (x)
+ acsch (x)
Aliases: arccsch
@@ -3040,7 +3106,7 @@
asec
- asec (x)
+ asec (x)
Aliases: arcsec
@@ -3048,7 +3114,7 @@
asech
- asech (x)
+ asech (x)
Aliases: arcsech
@@ -3056,7 +3122,7 @@
asin
- asin (x)
+ asin (x)
Aliases: arcsin
@@ -3064,7 +3130,7 @@
asinh
- asinh (x)
+ asinh (x)
Aliases: arcsinh
@@ -3072,7 +3138,7 @@
atan
- atan (x)
+ atan (x)
Aliases: arctan
@@ -3082,7 +3148,7 @@
atanh
- atanh (x)
+ atanh (x)
Aliases: arctanh
@@ -3090,7 +3156,7 @@
atan2
- atan2 (y, x)
+ atan2 (y, x)
Aliases: arctan2
@@ -3102,7 +3168,7 @@
cos
- cos (x)
+ cos (x)
Calculates the cosine function.
@@ -3110,7 +3176,7 @@
cosh
- cosh (x)
+ cosh (x)
Calculates the hyperbolic cosine function.
@@ -3118,7 +3184,7 @@
cot
- cot (x)
+ cot (x)
The cotangent function.
@@ -3126,7 +3192,7 @@
coth
- coth (x)
+ coth (x)
The hyperbolic cotangent function.
@@ -3134,7 +3200,7 @@
csc
- csc (x)
+ csc (x)
The cosecant function.
@@ -3142,7 +3208,7 @@
csch
- csch (x)
+ csch (x)
The hyperbolic cosecant function.
@@ -3150,7 +3216,7 @@
sec
- sec (x)
+ sec (x)
The secant function.
@@ -3158,7 +3224,7 @@
sech
- sech (x)
+ sech (x)
The hyperbolic secant function.
@@ -3166,7 +3232,7 @@
sin
- sin (x)
+ sin (x)
Calculates the sine function.
@@ -3174,7 +3240,7 @@
sinh
- sinh (x)
+ sinh (x)
Calculates the hyperbolic sine function.
@@ -3182,7 +3248,7 @@
tan
- tan (x)
+ tan (x)
Calculates the tan function.
@@ -3190,7 +3256,7 @@
tanh
- tanh (x)
+ tanh (x)
The hyperbolic tangent function.
@@ -3198,11 +3264,11 @@
----------------------------------------------------------------------
-11.7. Number Theory
+Number Theory
AreRelativelyPrime
- AreRelativelyPrime (a,b)
+ AreRelativelyPrime (a,b)
Are the real integers a and b relatively prime? Returns true or
false.
@@ -3211,7 +3277,7 @@
BernoulliNumber
- BernoulliNumber (n)
+ BernoulliNumber (n)
Return the nth Bernoulli number.
@@ -3219,7 +3285,7 @@
ChineseRemainder
- ChineseRemainder (a,m)
+ ChineseRemainder (a,m)
Aliases: CRT
@@ -3230,7 +3296,7 @@
CombineFactorizations
- CombineFactorizations (a,b)
+ CombineFactorizations (a,b)
Given two factorizations, give the factorization of the product.
@@ -3238,19 +3304,19 @@
ConvertFromBase
- ConvertFromBase (v,b)
+ ConvertFromBase (v,b)
Convert a vector of values indicating powers of b to a number.
ConvertToBase
- ConvertToBase (n,b)
+ ConvertToBase (n,b)
Convert a number to a vector of powers for elements in base b.
DiscreteLog
- DiscreteLog (n,b,q)
+ DiscreteLog (n,b,q)
Find discrete log of n base b in Fq, the finite field of order q,
where q is a prime, using the Silver-Pohlig-Hellman algoritm.
@@ -3259,13 +3325,13 @@
Divides
- Divides (m,n)
+ Divides (m,n)
Checks divisibility (if m divides n).
EulerPhi
- EulerPhi (n)
+ EulerPhi (n)
Compute the Euler phi function for n, that is the number of
integers between 1 and n relatively prime to n.
@@ -3274,7 +3340,7 @@
ExactDivision
- ExactDivision (n,d)
+ ExactDivision (n,d)
Return n/d but only if d divides n. If d does not divide n then
this function returns garbage. This is a lot faster for very large
@@ -3283,22 +3349,22 @@
Factorize
- Factorize (n)
+ Factorize (n)
Return factorization of a number as a matrix. The first row is the
primes in the factorization (including 1) and the second row are
the powers. So for example:
- genius> Factorize(11*11*13)
- =
- [1 11 13
- 1 2 1]
+ genius> Factorize(11*11*13)
+ =
+ [1 11 13
+ 1 2 1]
See Wikipedia for more information.
Factors
- Factors (n)
+ Factors (n)
Return all factors of n in a vector. This includes all the
non-prime factors as well. It includes 1 and the number itself. So
@@ -3306,14 +3372,14 @@
of their factors) up to the number 1000 you could do (this is of
course very inefficent)
- for n=1 to 1000 do (
- if MatrixSum (Factors(n)) == 2*n then
- print(n)
- )
+ for n=1 to 1000 do (
+ if MatrixSum (Factors(n)) == 2*n then
+ print(n)
+ )
FermatFactorization
- FermatFactorization (n,tries)
+ FermatFactorization (n,tries)
Attempt fermat factorization of n into (t-s)*(t+s), returns t and
s as a vector if possible, null otherwise. tries specifies the
@@ -3326,21 +3392,21 @@
FindPrimitiveElementMod
- FindPrimitiveElementMod (q)
+ FindPrimitiveElementMod (q)
Find the first primitive element in Fq, the finite group of order
q. Of course q must be a prime.
FindRandomPrimitiveElementMod
- FindRandomPrimitiveElementMod (q)
+ FindRandomPrimitiveElementMod (q)
Find a random primitive element in Fq, the finite group of order q
(q must be a prime).
IndexCalculus
- IndexCalculus (n,b,q,S)
+ IndexCalculus (n,b,q,S)
Compute discrete log base b of n in Fq, the finite group of order
q (q a prime), using the factor base S. S should be a column of
@@ -3349,7 +3415,7 @@
IndexCalculusPrecalculation
- IndexCalculusPrecalculation (b,q,S)
+ IndexCalculusPrecalculation (b,q,S)
Run the precalculation step of IndexCalculus for logarithms base b
in Fq, the finite group of order q (q a prime), for the factor
@@ -3358,13 +3424,13 @@
IsEven
- IsEven (n)
+ IsEven (n)
Tests if an integer is even.
IsMersennePrimeExponent
- IsMersennePrimeExponent (p)
+ IsMersennePrimeExponent (p)
Tests if a positive integer p is a Mersenne prime exponent. That
is if 2p-1 is a prime. It does this by looking it up in a table of
@@ -3376,26 +3442,26 @@
IsNthPower
- IsNthPower (m,n)
+ IsNthPower (m,n)
Tests if a rational number m is a perfect nth power. See also
IsPerfectPower and IsPerfectSquare.
IsOdd
- IsOdd (n)
+ IsOdd (n)
Tests if an integer is odd.
IsPerfectPower
- IsPerfectPower (n)
+ IsPerfectPower (n)
Check an integer is any perfect power, ab.
IsPerfectSquare
- IsPerfectSquare (n)
+ IsPerfectSquare (n)
Check an integer for being a perfect square of an integer. The
number must be a real integer. Negative integers are of course
@@ -3403,7 +3469,7 @@
IsPrime
- IsPrime (n)
+ IsPrime (n)
Tests primality of integers, for numbers less than 2.5e10 the
answer is deterministic (if Riemann hypothesis is true). For
@@ -3420,14 +3486,14 @@
IsPrimitiveMod
- IsPrimitiveMod (g,q)
+ IsPrimitiveMod (g,q)
Check if g is primitive in Fq, the finite group of order q, where
q is a prime. If q is not prime results are bogus.
IsPrimitiveModWithPrimeFactors
- IsPrimitiveModWithPrimeFactors (g,q,f)
+ IsPrimitiveModWithPrimeFactors (g,q,f)
Check if g is primitive in Fq, the finite group of order q, where
q is a prime and f is a vector of prime factors of q-1. If q is
@@ -3435,20 +3501,20 @@
IsPseudoprime
- IsPseudoprime (n,b)
+ IsPseudoprime (n,b)
If n is a pseudoprime base b but not a prime, that is if b^(n-1)
== 1 mod n. This calles the PseudoprimeTest
IsStrongPseudoprime
- IsStrongPseudoprime (n,b)
+ IsStrongPseudoprime (n,b)
Test if n is a strong pseudoprime to base b but not a prime.
Jacobi
- Jacobi (a,b)
+ Jacobi (a,b)
Aliases: JacobiSymbol
@@ -3456,7 +3522,7 @@
JacobiKronecker
- JacobiKronecker (a,b)
+ JacobiKronecker (a,b)
Aliases: JacobiKroneckerSymbol
@@ -3465,14 +3531,14 @@
LeastAbsoluteResidue
- LeastAbsoluteResidue (a,n)
+ LeastAbsoluteResidue (a,n)
Return the residue of a mod n with the least absolute value (in
the interval -n/2 to n/2).
Legendre
- Legendre (a,p)
+ Legendre (a,p)
Aliases: LegendreSymbol
@@ -3482,7 +3548,7 @@
LucasLehmer
- LucasLehmer (p)
+ LucasLehmer (p)
Test if 2p-1 is a Mersenne prime using the Lucas-Lehmer test. See
also MersennePrimeExponents and IsMersennePrimeExponent.
@@ -3491,7 +3557,7 @@
LucasNumber
- LucasNumber (n)
+ LucasNumber (n)
Returns the nth Lucas number.
@@ -3499,13 +3565,13 @@
MaximalPrimePowerFactors
- MaximalPrimePowerFactors (n)
+ MaximalPrimePowerFactors (n)
Return all maximal prime power factors of a number.
MersennePrimeExponents
- MersennePrimeExponents
+ MersennePrimeExponents
A vector of known Mersenne prime exponents, that is a list of
positive integers p such that 2p-1 is a prime. See also
@@ -3516,7 +3582,7 @@
MillerRabinTest
- MillerRabinTest (n,reps)
+ MillerRabinTest (n,reps)
Use the Miller-Rabin primality test on n, reps number of times.
The probability of false positive is (1/4)^reps. It is probably
@@ -3527,7 +3593,7 @@
MillerRabinTestSure
- MillerRabinTestSure (n)
+ MillerRabinTestSure (n)
Use the Miller-Rabin primality test on n with enough bases that
assuming the Generalized Reimann Hypothesis the result is
@@ -3537,7 +3603,7 @@
ModInvert
- ModInvert (n,m)
+ ModInvert (n,m)
Returns inverse of n mod m.
@@ -3545,7 +3611,7 @@
MoebiusMu
- MoebiusMu (n)
+ MoebiusMu (n)
Return the Moebius mu function evaluated in n. That is, it returns
0 if n is not a product of distinct primes and (-1)^k if it is a
@@ -3555,7 +3621,7 @@
NextPrime
- NextPrime (n)
+ NextPrime (n)
Returns the least prime greater than n. Negatives of primes are
considered prime and so to get the previous prime you can use
@@ -3570,7 +3636,7 @@
PadicValuation
- PadicValuation (n,p)
+ PadicValuation (n,p)
Returns the padic valuation (number of trailing zeros in base p).
@@ -3578,7 +3644,7 @@
PowerMod
- PowerMod (a,b,m)
+ PowerMod (a,b,m)
Compute a^b mod m. The b's power of a modulo m. It is not
neccessary to use this function as it is automatically used in
@@ -3586,7 +3652,7 @@
Prime
- Prime (n)
+ Prime (n)
Aliases: prime
@@ -3596,7 +3662,7 @@
PrimeFactors
- PrimeFactors (n)
+ PrimeFactors (n)
Return all prime factors of a number as a vector.
@@ -3604,7 +3670,7 @@
PseudoprimeTest
- PseudoprimeTest (n,b)
+ PseudoprimeTest (n,b)
Pseudoprime test, returns true if and only if b^(n-1) == 1 mod n
@@ -3612,7 +3678,7 @@
RemoveFactor
- RemoveFactor (n,m)
+ RemoveFactor (n,m)
Removes all instances of the factor m from the number n. That is
divides by the largest power of m, that divides n.
@@ -3621,7 +3687,7 @@
SilverPohligHellmanWithFactorization
- SilverPohligHellmanWithFactorization (n,b,q,f)
+ SilverPohligHellmanWithFactorization (n,b,q,f)
Find discrete log of n base b in Fq, the finite group of order q,
where q is a prime using the Silver-Pohlig-Hellman algoritm, given
@@ -3629,7 +3695,7 @@
SqrtModPrime
- SqrtModPrime (n,p)
+ SqrtModPrime (n,p)
Find square root of n modulo p (where p is a prime). Null is
returned if not a quadratic residue.
@@ -3638,7 +3704,7 @@
StrongPseudoprimeTest
- StrongPseudoprimeTest (n,b)
+ StrongPseudoprimeTest (n,b)
Run the strong pseudoprime test base b on n.
@@ -3646,7 +3712,7 @@
gcd
- gcd (a,args...)
+ gcd (a,args...)
Aliases: GCD
@@ -3659,7 +3725,7 @@
lcm
- lcm (a,args...)
+ lcm (a,args...)
Aliases: LCM
@@ -3672,43 +3738,43 @@
----------------------------------------------------------------------
-11.8. Matrix Manipulation
+Matrix Manipulation
ApplyOverMatrix
- ApplyOverMatrix (a,func)
+ ApplyOverMatrix (a,func)
Apply a function over all entries of a matrix and return a matrix
of the results.
ApplyOverMatrix2
- ApplyOverMatrix2 (a,b,func)
+ ApplyOverMatrix2 (a,b,func)
Apply a function over all entries of 2 matrices (or 1 value and 1
matrix) and return a matrix of the results.
ColumnsOf
- ColumnsOf (M)
+ ColumnsOf (M)
Gets the columns of a matrix as a horizontal vector.
ComplementSubmatrix
- ComplementSubmatrix (m,r,c)
+ ComplementSubmatrix (m,r,c)
Remove column(s) and row(s) from a matrix.
CompoundMatrix
- CompoundMatrix (k,A)
+ CompoundMatrix (k,A)
Calculate the kth compund matrix of A.
CountZeroColumns
- CountZeroColumns (M)
+ CountZeroColumns (M)
Count the number of zero columns in a matrix. For example Once you
column reduce a matrix you can use this to find the nullity. See
@@ -3716,19 +3782,19 @@
DeleteColumn
- DeleteColumn (M,col)
+ DeleteColumn (M,col)
Delete a column of a matrix.
DeleteRow
- DeleteRow (M,row)
+ DeleteRow (M,row)
Delete a row of a matrix.
DiagonalOf
- DiagonalOf (M)
+ DiagonalOf (M)
Gets the diagonal entries of a matrix as a column vector.
@@ -3736,7 +3802,7 @@
DotProduct
- DotProduct (u,v)
+ DotProduct (u,v)
Get the dot product of two vectors. The vectors must be of the
same size. No conjugates are taken so this is a bilinear form even
@@ -3746,7 +3812,7 @@
ExpandMatrix
- ExpandMatrix (M)
+ ExpandMatrix (M)
Expands a matrix just like we do on unquoted matrix input. That is
we expand any internal matrices as blocks. This is a way to
@@ -3755,7 +3821,7 @@
HermitianProduct
- HermitianProduct (u,v)
+ HermitianProduct (u,v)
Aliases: InnerProduct
@@ -3767,7 +3833,7 @@
I
- I (n)
+ I (n)
Aliases: eye
@@ -3778,7 +3844,7 @@
IndexComplement
- IndexComplement (vec,msize)
+ IndexComplement (vec,msize)
Return the index complement of a vector of indexes. Everything is
one based. For example for vector [2,3] and size 5, we return
@@ -3786,7 +3852,7 @@
IsDiagonal
- IsDiagonal (M)
+ IsDiagonal (M)
Is a matrix diagonal.
@@ -3794,7 +3860,7 @@
IsIdentity
- IsIdentity (x)
+ IsIdentity (x)
Check if a matrix is the identity matrix. Automatically returns
false if the matrix is not square. Also works on numbers, in which
@@ -3804,20 +3870,20 @@
IsLowerTriangular
- IsLowerTriangular (M)
+ IsLowerTriangular (M)
Is a matrix lower triangular. That is, are all the entries below
the diagonal zero.
IsMatrixInteger
- IsMatrixInteger (M)
+ IsMatrixInteger (M)
Check if a matrix is a matrix of an integers (non-complex).
IsMatrixNonnegative
- IsMatrixNonnegative (M)
+ IsMatrixNonnegative (M)
Check if a matrix is nonnegative, that is if each element is
nonnegative. Do not confuse positive matrices with positive
@@ -3827,7 +3893,7 @@
IsMatrixPositive
- IsMatrixPositive (M)
+ IsMatrixPositive (M)
Check if a matrix is positive, that is if each element is positive
(and hence real). In particular, no element is 0. Do not confuse
@@ -3837,33 +3903,33 @@
IsMatrixRational
- IsMatrixRational (M)
+ IsMatrixRational (M)
Check if a matrix is a matrix of rational (non-complex) numbers.
IsMatrixReal
- IsMatrixReal (M)
+ IsMatrixReal (M)
Check if a matrix is a matrix of real (non-complex) numbers.
IsMatrixSquare
- IsMatrixSquare (M)
+ IsMatrixSquare (M)
Check if a matrix is square, that is its width is equal to its
height.
IsUpperTriangular
- IsUpperTriangular (M)
+ IsUpperTriangular (M)
Is a matrix upper triangular? That is, a matrix is upper
triangular if all all the entries below the diagonal are zero.
IsValueOnly
- IsValueOnly (M)
+ IsValueOnly (M)
Check if a matrix is a matrix of numbers only. Many internal
functions make this check. Values can be any number including
@@ -3871,7 +3937,7 @@
IsVector
- IsVector (v)
+ IsVector (v)
Is argument a horizontal or a vertical vector. Genius does not
distinguish between a matrix and a vector and a vector is just a 1
@@ -3879,7 +3945,7 @@
IsZero
- IsZero (x)
+ IsZero (x)
Check if a matrix is composed of all zeros. Also works on numbers,
in which case it is equivalent to x==0. When x is null (we could
@@ -3888,14 +3954,14 @@
LowerTriangular
- LowerTriangular (M)
+ LowerTriangular (M)
Returns a copy of the matrix M with all the entries above the
diagonal set to zero.
MakeDiagonal
- MakeDiagonal (v,arg...)
+ MakeDiagonal (v,arg...)
Aliases: diag
@@ -3905,14 +3971,14 @@
MakeVector
- MakeVector (A)
+ MakeVector (A)
Make column vector out of matrix by putting columns above each
other. Returns null when given null.
MatrixProduct
- MatrixProduct (A)
+ MatrixProduct (A)
Calculate the product of all elements in a matrix or vector. That
is we multiply all the elements and return a number that is the
@@ -3920,7 +3986,7 @@
MatrixSum
- MatrixSum (A)
+ MatrixSum (A)
Calculate the sum of all elements in a matrix or vecgtor. That is
we add all the elements and return a number that is the sum of all
@@ -3928,40 +3994,40 @@
MatrixSumSquares
- MatrixSumSquares (A)
+ MatrixSumSquares (A)
Calculate the sum of squares of all elements in a matrix or
vector.
OuterProduct
- OuterProduct (u,v)
+ OuterProduct (u,v)
Get the outer product of two vectors. That is, suppose that u and
v are vertical vectors, then the outer product is v * u.'.
ReverseVector
- ReverseVector (v)
+ ReverseVector (v)
Reverse elements in a vector.
RowSum
- RowSum (m)
+ RowSum (m)
Calculate sum of each row in a matrix and return a vertical vector
with the result.
RowSumSquares
- RowSumSquares (m)
+ RowSumSquares (m)
Calculate sum of squares of each row in a matrix.
RowsOf
- RowsOf (M)
+ RowsOf (M)
Gets the rows of a matrix as a vertical vector. Each element of
the vector is a horizontal vector which is the corresponding row
@@ -3970,7 +4036,7 @@
SetMatrixSize
- SetMatrixSize (M,rows,columns)
+ SetMatrixSize (M,rows,columns)
Make new matrix of given size from old one. That is, a new matrix
will be returned to which the old one is copied. Entries that
@@ -3979,25 +4045,25 @@
SortVector
- SortVector (v)
+ SortVector (v)
Sort vector elements in an increasing order.
StripZeroColumns
- StripZeroColumns (M)
+ StripZeroColumns (M)
Removes any all-zero columns of M.
StripZeroRows
- StripZeroRows (M)
+ StripZeroRows (M)
Removes any all-zero rows of M.
Submatrix
- Submatrix (m,r,c)
+ Submatrix (m,r,c)
Return column(s) and row(s) from a matrix. This is just equivalent
to m@(r,c). r and c should be vectors of rows and columns (or
@@ -4005,57 +4071,57 @@
SwapRows
- SwapRows (m,row1,row2)
+ SwapRows (m,row1,row2)
Swap two rows in a matrix.
UpperTriangular
- UpperTriangular (M)
+ UpperTriangular (M)
Returns a copy of the matrix M with all the entries below the
diagonal set to zero.
columns
- columns (M)
+ columns (M)
Get the number of columns of a matrix.
elements
- elements (M)
+ elements (M)
Get the total number of elements of a matrix. This is the number
of columns times the number of rows.
ones
- ones (rows,columns...)
+ ones (rows,columns...)
Make an matrix of all ones (or a row vector if only one argument
is given). Returns null if either rows or columns are zero.
rows
- rows (M)
+ rows (M)
Get the number of rows of a matrix.
zeros
- zeros (rows,columns...)
+ zeros (rows,columns...)
Make a matrix of all zeros (or a row vector if only one argument
is given). Returns null if either rows or columns are zero.
----------------------------------------------------------------------
-11.9. Linear Algebra
+Linear Algebra
AuxilliaryUnitMatrix
- AuxilliaryUnitMatrix (n)
+ AuxilliaryUnitMatrix (n)
Get the auxilliary unit matrix of size n. This is a square matrix
matrix with that is all zero except the superdiagonal being all
@@ -4066,21 +4132,21 @@
BilinearForm
- BilinearForm (v,A,w)
+ BilinearForm (v,A,w)
Evaluate (v,w) with respect to the bilinear form given by the
matrix A.
BilinearFormFunction
- BilinearFormFunction (A)
+ BilinearFormFunction (A)
Return a function that evaluates two vectors with respect to the
bilinear form given by A.
CharacteristicPolynomial
- CharacteristicPolynomial (M)
+ CharacteristicPolynomial (M)
Aliases: CharPoly
@@ -4094,7 +4160,7 @@
CharacteristicPolynomialFunction
- CharacteristicPolynomialFunction (M)
+ CharacteristicPolynomialFunction (M)
Get the characteristic polynomial as a function. This is the
polynomial defined by det(M-xI). The roots of this polynomial are
@@ -4104,7 +4170,7 @@
ColumnSpace
- ColumnSpace (M)
+ ColumnSpace (M)
Get a basis matrix for the columnspace of a matrix. That is,
return a matrix whose columns are the basis for the column space
@@ -4112,7 +4178,7 @@
CommutationMatrix
- CommutationMatrix (m, n)
+ CommutationMatrix (m, n)
Return the commutation matrix K(m,n) which is the unique m*n by
m*n matrix such that K(m,n) * MakeVector(A) = MakeVector(A.') for
@@ -4120,13 +4186,13 @@
CompanionMatrix
- CompanionMatrix (p)
+ CompanionMatrix (p)
Companion matrix of a polynomial (as vector).
ConjugateTranspose
- ConjugateTranspose (M)
+ ConjugateTranspose (M)
Conjugate transpose of a matrix (adjoint). This is the same as the
' operator.
@@ -4135,7 +4201,7 @@
Convolution
- Convolution (a,b)
+ Convolution (a,b)
Aliases: convol
@@ -4143,39 +4209,39 @@
ConvolutionVector
- ConvolutionVector (a,b)
+ ConvolutionVector (a,b)
Calculate convolution of two horizontal vectors. Return result as
a vector and not added together.
CrossProduct
- CrossProduct (v,w)
+ CrossProduct (v,w)
CrossProduct of two vectors in R3.
DeterminantalDivisorsInteger
- DeterminantalDivisorsInteger (M)
+ DeterminantalDivisorsInteger (M)
Get the determinantal divisors of an integer matrix (not its
characteristic).
DirectSum
- DirectSum (M,N...)
+ DirectSum (M,N...)
Direct sum of matrices.
DirectSumMatrixVector
- DirectSumMatrixVector (v)
+ DirectSumMatrixVector (v)
Direct sum of a vector of matrices.
Eigenvalues
- Eigenvalues (M)
+ Eigenvalues (M)
Aliases: eig
@@ -4187,11 +4253,11 @@
Eigenvectors
- Eigenvectors (M)
+ Eigenvectors (M)
- Eigenvectors (M, &eigenvalues)
+ Eigenvectors (M, &eigenvalues)
- Eigenvectors (M, &eigenvalues, &multiplicities)
+ Eigenvectors (M, &eigenvalues, &multiplicities)
Get the eigenvectors of a square matrix. Optionally get also the
eigenvalues and their algebraic multiplicities. Currently only
@@ -4201,7 +4267,7 @@
GramSchmidt
- GramSchmidt (v,B...)
+ GramSchmidt (v,B...)
Apply the Gram-Schmidt process (to the columns) with respect to
inner product given by B. If B is not given then the standard
@@ -4213,13 +4279,13 @@
HankelMatrix
- HankelMatrix (c,r)
+ HankelMatrix (c,r)
Hankel matrix.
HilbertMatrix
- HilbertMatrix (n)
+ HilbertMatrix (n)
Hilbert matrix of order n.
@@ -4227,27 +4293,27 @@
Image
- Image (T)
+ Image (T)
Get the image (columnspace) of a linear transform.
InfNorm
- InfNorm (v)
+ InfNorm (v)
Get the Inf Norm of a vector, sometimes called the sup norm or the
max norm.
InvariantFactorsInteger
- InvariantFactorsInteger (M)
+ InvariantFactorsInteger (M)
Get the invariant factors of a square integer matrix (not its
characteristic).
InverseHilbertMatrix
- InverseHilbertMatrix (n)
+ InverseHilbertMatrix (n)
Inverse Hilbert matrix of order n.
@@ -4255,7 +4321,7 @@
IsHermitian
- IsHermitian (M)
+ IsHermitian (M)
Is a matrix hermitian. That is, is it equal to its conjugate
transpose.
@@ -4264,26 +4330,26 @@
IsInSubspace
- IsInSubspace (v,W)
+ IsInSubspace (v,W)
Test if a vector is in a subspace.
IsInvertible
- IsInvertible (n)
+ IsInvertible (n)
Is a matrix (or number) invertible (Integer matrix is invertible
iff it's invertible over the integers).
IsInvertibleField
- IsInvertibleField (n)
+ IsInvertibleField (n)
Is a matrix (or number) invertible over a field.
IsNormal
- IsNormal (M)
+ IsNormal (M)
Is M a normal matrix. That is, does M*M' == M'*M.
@@ -4291,7 +4357,7 @@
IsPositiveDefinite
- IsPositiveDefinite (M)
+ IsPositiveDefinite (M)
Is M a hermitian positive definite matrix. That is if
HermitianProduct(M*v,v) is always strictly positive for any vector
@@ -4309,7 +4375,7 @@
IsPositiveSemidefinite
- IsPositiveSemidefinite (M)
+ IsPositiveSemidefinite (M)
Is M a hermitian positive semidefinite matrix. That is if
HermitianProduct(M*v,v) is always nonnegative for any vector v. M
@@ -4327,7 +4393,7 @@
IsSkewHermitian
- IsSkewHermitian (M)
+ IsSkewHermitian (M)
Is a matrix skew-hermitian. That is, is the conjugate transpose
equal to negative of the matrix.
@@ -4336,7 +4402,7 @@
IsUnitary
- IsUnitary (M)
+ IsUnitary (M)
Is a matrix unitary? That is, does M'*M and M*M' equal the
identity.
@@ -4345,7 +4411,7 @@
JordanBlock
- JordanBlock (n,lambda)
+ JordanBlock (n,lambda)
Aliases: J
@@ -4356,7 +4422,7 @@
Kernel
- Kernel (T)
+ Kernel (T)
Get the kernel (nullspace) of a linear transform.
@@ -4364,13 +4430,13 @@
LUDecomposition
- LUDecomposition (A, L, U)
+ LUDecomposition (A, L, U)
Get the LU decomposition of A and store the result in the L and U
which should be references. It returns true if successful. For
example suppose that A is a square matrix, then after running:
- genius> LUDecomposition(A,&L,&U)
+ genius> LUDecomposition(A,&L,&U)
You will have the lower matrix stored in a variable called L and
the upper matrix in a variable called U.
@@ -4389,7 +4455,7 @@
Minor
- Minor (M,i,j)
+ Minor (M,i,j)
Get the i-j minor of a matrix.
@@ -4397,13 +4463,13 @@
NonPivotColumns
- NonPivotColumns (M)
+ NonPivotColumns (M)
Return the columns that are not the pivot columns of a matrix.
Norm
- Norm (v,p...)
+ Norm (v,p...)
Aliases: norm
@@ -4411,7 +4477,7 @@
NullSpace
- NullSpace (T)
+ NullSpace (T)
Get the nullspace of a matrix. That is the kernel of the linear
mapping that the matrix represents. This is returned as a matrix
@@ -4421,7 +4487,7 @@
Nullity
- Nullity (M)
+ Nullity (M)
Aliases: nullity
@@ -4432,13 +4498,13 @@
OrthogonalComplement
- OrthogonalComplement (M)
+ OrthogonalComplement (M)
Get the orthogonal complement of the columnspace.
PivotColumns
- PivotColumns (M)
+ PivotColumns (M)
Return pivot columns of a matrix, that is columns which have a
leading 1 in row reduced form. Also returns the row where they
@@ -4446,7 +4512,7 @@
Projection
- Projection (v,W,B...)
+ Projection (v,W,B...)
Projection of vector v onto subspace W with respect to inner
product given by B. If B is not given then the standard hermitian
@@ -4455,14 +4521,14 @@
QRDecomposition
- QRDecomposition (A, Q)
+ QRDecomposition (A, Q)
Get the QR decomposition of a square matrix A, returns the upper
triangular matrix R and sets Q to the orthogonal (unitary) matrix.
Q should be a reference or null if you don't want any return. For
example:
- genius> R = QRDecomposition(A,&Q)
+ genius> R = QRDecomposition(A,&Q)
You will have the upper triangular matrix stored in a variable
called R and the orthogonal (unitary) matrix stored in Q.
@@ -4471,7 +4537,7 @@
RayleighQuotient
- RayleighQuotient (A,x)
+ RayleighQuotient (A,x)
Return the Rayleigh quotient (also called the Rayleigh-Ritz
quotient or ratio) of a matrix and a vector.
@@ -4480,7 +4546,7 @@
RayleighQuotientIteration
- RayleighQuotientIteration (A,x,epsilon,maxiter,vecref)
+ RayleighQuotientIteration (A,x,epsilon,maxiter,vecref)
Find eigenvalues of A using the Rayleigh quotient iteration
method. x is a guess at a eigenvector and could be random. It
@@ -4494,7 +4560,7 @@
Rank
- Rank (M)
+ Rank (M)
Aliases: rank
@@ -4504,13 +4570,13 @@
RosserMatrix
- RosserMatrix ()
+ RosserMatrix ()
Rosser matrix, a classic symmetric eigenvalue test problem.
Rotation2D
- Rotation2D (angle)
+ Rotation2D (angle)
Aliases: RotationMatrix
@@ -4518,62 +4584,62 @@
Rotation3DX
- Rotation3DX (angle)
+ Rotation3DX (angle)
Return the matrix corresponding to rotation around origin in R3
about the x-axis.
Rotation3DY
- Rotation3DY (angle)
+ Rotation3DY (angle)
Return the matrix corresponding to rotation around origin in R3
about the y-axis.
Rotation3DZ
- Rotation3DZ (angle)
+ Rotation3DZ (angle)
Return the matrix corresponding to rotation around origin in R3
about the z-axis.
RowSpace
- RowSpace (M)
+ RowSpace (M)
Get a basis matrix for the rowspace of a matrix.
SesquilinearForm
- SesquilinearForm (v,A,w)
+ SesquilinearForm (v,A,w)
Evaluate (v,w) with respect to the sesquilinear form given by the
matrix A.
SesquilinearFormFunction
- SesquilinearFormFunction (A)
+ SesquilinearFormFunction (A)
Return a function that evaluates two vectors with respect to the
sesquilinear form given by A.
SmithNormalFormField
- SmithNormalFormField (A)
+ SmithNormalFormField (A)
Smith Normal Form for fields (will end up with 1's on the
diagonal).
SmithNormalFormInteger
- SmithNormalFormInteger (M)
+ SmithNormalFormInteger (M)
Smith Normal Form for square integer matrices (not its
characteristic).
SolveLinearSystem
- SolveLinearSystem (M,V,args...)
+ SolveLinearSystem (M,V,args...)
Solve linear system Mx=V, return solution V if there is a unique
solution, null otherwise. Extra two reference parameters can
@@ -4581,7 +4647,7 @@
ToeplitzMatrix
- ToeplitzMatrix (c, r...)
+ ToeplitzMatrix (c, r...)
Return the Toeplitz matrix constructed given the first column c
and (optionally) the first row r. If only the column c is given
@@ -4593,7 +4659,7 @@
Trace
- Trace (M)
+ Trace (M)
Aliases: trace
@@ -4604,7 +4670,7 @@
Transpose
- Transpose (M)
+ Transpose (M)
Transpose of a matrix. This is the same as the .' operator.
@@ -4612,7 +4678,7 @@
VandermondeMatrix
- VandermondeMatrix (v)
+ VandermondeMatrix (v)
Aliases: vander
@@ -4620,7 +4686,7 @@
VectorAngle
- VectorAngle (v,w,B...)
+ VectorAngle (v,w,B...)
The angle of two vectors with respect to inner product given by B.
If B is not given then the standard hermitian product is used. B
@@ -4629,26 +4695,26 @@
VectorSpaceDirectSum
- VectorSpaceDirectSum (M,N)
+ VectorSpaceDirectSum (M,N)
The direct sum of the vector spaces M and N.
VectorSubspaceIntersection
- VectorSubspaceIntersection (M,N)
+ VectorSubspaceIntersection (M,N)
Intersection of the subspaces given by M and N.
VectorSubspaceSum
- VectorSubspaceSum (M,N)
+ VectorSubspaceSum (M,N)
The sum of the vector spaces M and N, that is {w | w=m+n, m in M,
n in N}.
adj
- adj (m)
+ adj (m)
Aliases: Adjugate
@@ -4656,7 +4722,7 @@
cref
- cref (M)
+ cref (M)
Aliases: CREF ColumnReducedEchelonForm
@@ -4664,7 +4730,7 @@
det
- det (M)
+ det (M)
Aliases: Determinant
@@ -4674,7 +4740,7 @@
ref
- ref (M)
+ ref (M)
Aliases: REF RowEchelonForm
@@ -4686,7 +4752,7 @@
rref
- rref (M)
+ rref (M)
Aliases: RREF ReducedRowEchelonForm
@@ -4697,11 +4763,11 @@
----------------------------------------------------------------------
-11.10. Combinatorics
+Combinatorics
Catalan
- Catalan (n)
+ Catalan (n)
Get n'th catalan number.
@@ -4709,14 +4775,14 @@
Combinations
- Combinations (k,n)
+ Combinations (k,n)
Get all combinations of k numbers from 1 to n as a vector of
vectors. (See also NextCombination)
DoubleFactorial
- DoubleFactorial (n)
+ DoubleFactorial (n)
Double factorial: n(n-2)(n-4)...
@@ -4724,7 +4790,7 @@
Factorial
- Factorial (n)
+ Factorial (n)
Factorial: n(n-1)(n-2)...
@@ -4732,7 +4798,7 @@
FallingFactorial
- FallingFactorial (n,k)
+ FallingFactorial (n,k)
Falling factorial: (n)_k = n(n-1)...(n-(k-1))
@@ -4740,7 +4806,7 @@
Fibonacci
- Fibonacci (x)
+ Fibonacci (x)
Aliases: fib
@@ -4752,7 +4818,7 @@
FrobeniusNumber
- FrobeniusNumber (v,arg...)
+ FrobeniusNumber (v,arg...)
Calculate the Frobenius number. That is calculate smallest number
that cannot be given as a nonnegative integer linear combination
@@ -4764,14 +4830,14 @@
GaloisMatrix
- GaloisMatrix (combining_rule)
+ GaloisMatrix (combining_rule)
Galois matrix given a linear combining rule
(a_1*x_+...+a_n*x_n=x_(n+1)).
GreedyAlgorithm
- FrobeniusNumber (n,v)
+ FrobeniusNumber (n,v)
Find the vector c of nonnegative integers such that taking the dot
product with v is equal to n. If not possible returns null. v
@@ -4782,7 +4848,7 @@
HarmonicNumber
- HarmonicNumber (n,r)
+ HarmonicNumber (n,r)
Aliases: HarmonicH
@@ -4790,20 +4856,20 @@
Hofstadter
- Hofstadter (n)
+ Hofstadter (n)
Hofstadter's function q(n) defined by q(1)=1, q(2)=1,
q(n)=q(n-q(n-1))+q(n-q(n-2)).
LinearRecursiveSequence
- LinearRecursiveSequence (seed_values,combining_rule,n)
+ LinearRecursiveSequence (seed_values,combining_rule,n)
Compute linear recursive sequence using galois stepping.
Multinomial
- Multinomial (v,arg...)
+ Multinomial (v,arg...)
Calculate multinomial coefficients. Takes a vector of k
nonnegative integers and computes the multinomial coefficient.
@@ -4812,7 +4878,7 @@
The formula for Multinomial(a,b,c) can be written as:
- (a+b+c)! / (a!b!c!)
+ (a+b+c)! / (a!b!c!)
In other words, if we would have only two elements, then
Multinomial(a,b) is the same thing as Binomial(a+b,a) or
@@ -4822,7 +4888,7 @@
NextCombination
- NextCombination (v,n)
+ NextCombination (v,n)
Get combination that would come after v in call to combinations,
first combination should be [1:k]. This function is useful if you
@@ -4831,22 +4897,22 @@
For example with Combination you would normally write a loop like:
- for n in Combinations (4,6) do (
- SomeFunction (n)
- );
+ for n in Combinations (4,6) do (
+ SomeFunction (n)
+ );
But with NextCombination you would write something like:
- n:=[1:4];
- do (
- SomeFunction (n)
- ) while not IsNull(n:=NextCombination(n,6));
+ n:=[1:4];
+ do (
+ SomeFunction (n)
+ ) while not IsNull(n:=NextCombination(n,6));
See also Combinations.
Pascal
- Pascal (i)
+ Pascal (i)
Get the Pascal's triangle as a matrix. This will return an i+1 by
i+1 lower diagonal matrix which is the Pascal's triangle after i
@@ -4856,7 +4922,7 @@
Permutations
- Permutations (k,n)
+ Permutations (k,n)
Get all permutations of k numbers from 1 to n as a vector of
vectors.
@@ -4865,7 +4931,7 @@
RisingFactorial
- RisingFactorial (n,k)
+ RisingFactorial (n,k)
Aliases: Pochhammer
@@ -4875,7 +4941,7 @@
StirlingNumberFirst
- StirlingNumberFirst (n,m)
+ StirlingNumberFirst (n,m)
Aliases: StirlingS1
@@ -4885,7 +4951,7 @@
StirlingNumberSecond
- StirlingNumberSecond (n,m)
+ StirlingNumberSecond (n,m)
Aliases: StirlingS2
@@ -4895,13 +4961,13 @@
Subfactorial
- Subfactorial (n)
+ Subfactorial (n)
Subfactorial: n! times sum_{k=1}^n (-1)^k/k!.
Triangular
- Triangular (nth)
+ Triangular (nth)
Calculate the n'th triangular number.
@@ -4909,7 +4975,7 @@
nCr
- nCr (n,r)
+ nCr (n,r)
Aliases: Binomial
@@ -4920,7 +4986,7 @@
nPr
- nPr (n,r)
+ nPr (n,r)
Calculate the number of permutations of size rof numbers from 1 to
n.
@@ -4929,11 +4995,11 @@
----------------------------------------------------------------------
-11.11. Calculus
+Calculus
CompositeSimpsonsRule
- CompositeSimpsonsRule (f,a,b,n)
+ CompositeSimpsonsRule (f,a,b,n)
Integration of f by Composite Simpson's Rule on the interval [a,b]
with n subintervals with error of max(f'''')*h^4*(b-a)/180, note
@@ -4943,7 +5009,7 @@
CompositeSimpsonsRuleTolerance
- CompositeSimpsonsRuleTolerance (f,a,b,FourthDerivativeBound,Tolerance)
+ CompositeSimpsonsRuleTolerance (f,a,b,FourthDerivativeBound,Tolerance)
Integration of f by Composite Simpson's Rule on the interval [a,b]
with the number of steps calculated by the fourth derivative bound
@@ -4953,14 +5019,14 @@
Derivative
- Derivative (f,x0)
+ Derivative (f,x0)
Attempt to calculate derivative by trying first symbolically and
then numerically.
EvenPeriodicExtension
- EvenPeriodicExtension (f,L)
+ EvenPeriodicExtension (f,L)
Return a function which is even periodic extension of f with half
period L. That is a function defined on the interval [0,L]
@@ -4971,7 +5037,7 @@
FourierSeriesFunction
- FourierSeriesFunction (a,b,L)
+ FourierSeriesFunction (a,b,L)
Return a function which is a Fourier series with the coefficients
given by the vectors a (sines) and b (cosines). Note that a@(1) is
@@ -4983,67 +5049,67 @@
InfiniteProduct
- InfiniteProduct (func,start,inc)
+ InfiniteProduct (func,start,inc)
Try to calculate an infinite product for a single parameter
function.
InfiniteProduct2
- InfiniteProduct2 (func,arg,start,inc)
+ InfiniteProduct2 (func,arg,start,inc)
Try to calculate an infinite product for a double parameter
function with func(arg,n).
InfiniteSum
- InfiniteSum (func,start,inc)
+ InfiniteSum (func,start,inc)
Try to calculate an infinite sum for a single parameter function.
InfiniteSum2
- InfiniteSum2 (func,arg,start,inc)
+ InfiniteSum2 (func,arg,start,inc)
Try to calculate an infinite sum for a double parameter function
with func(arg,n).
IsContinuous
- IsContinuous (f,x0)
+ IsContinuous (f,x0)
Try and see if a real-valued function is continuous at x0 by
calculating the limit there.
IsDifferentiable
- IsDifferentiable (f,x0)
+ IsDifferentiable (f,x0)
Test for differentiability by approximating the left and right
limits and comparing.
LeftLimit
- LeftLimit (f,x0)
+ LeftLimit (f,x0)
Calculate the left limit of a real-valued function at x0.
Limit
- Limit (f,x0)
+ Limit (f,x0)
Calculate the limit of a real-valued function at x0. Tries to
calculate both left and right limits.
MidpointRule
- MidpointRule (f,a,b,n)
+ MidpointRule (f,a,b,n)
Integration by midpoint rule.
NumericalDerivative
- NumericalDerivative (f,x0)
+ NumericalDerivative (f,x0)
Aliases: NDerivative
@@ -5051,7 +5117,7 @@
NumericalFourierSeriesCoefficients
- NumericalFourierSeriesCoefficients (f,L,N)
+ NumericalFourierSeriesCoefficients (f,L,N)
Return a vector of vectors [a,b] where a are the cosine
coefficients and b are the sine coefficients of the Fourier series
@@ -5064,7 +5130,7 @@
NumericalFourierSeriesFunction
- NumericalFourierSeriesFunction (f,L,N)
+ NumericalFourierSeriesFunction (f,L,N)
Return a function which is the Fourier series of f with
half-period L (that is defined on [-L,L] and extended
@@ -5077,7 +5143,7 @@
NumericalFourierCosineSeriesCoefficients
- NumericalFourierCosineSeriesCoefficients (f,L,N)
+ NumericalFourierCosineSeriesCoefficients (f,L,N)
Return a vector of coefficients of the the cosine Fourier series
of f with half-period L. That is, we take f defined on [0,L] take
@@ -5091,7 +5157,7 @@
NumericalFourierCosineSeriesFunction
- NumericalFourierCosineSeriesFunction (f,L,N)
+ NumericalFourierCosineSeriesFunction (f,L,N)
Return a function which is the cosine Fourier series of f with
half-period L. That is, we take f defined on [0,L] take the even
@@ -5104,7 +5170,7 @@
NumericalFourierSineSeriesCoefficients
- NumericalFourierSineSeriesCoefficients (f,L,N)
+ NumericalFourierSineSeriesCoefficients (f,L,N)
Return a vector of coefficients of the the sine Fourier series of
f with half-period L. That is, we take f defined on [0,L] take the
@@ -5117,7 +5183,7 @@
NumericalFourierSineSeriesFunction
- NumericalFourierSineSeriesFunction (f,L,N)
+ NumericalFourierSineSeriesFunction (f,L,N)
Return a function which is the sine Fourier series of f with
half-period L. That is, we take f defined on [0,L] take the odd
@@ -5130,33 +5196,33 @@
NumericalIntegral
- NumericalIntegral (f,a,b)
+ NumericalIntegral (f,a,b)
Integration by rule set in NumericalIntegralFunction of f from a
to b using NumericalIntegralSteps steps.
NumericalLeftDerivative
- NumericalLeftDerivative (f,x0)
+ NumericalLeftDerivative (f,x0)
Attempt to calculate numerical left derivative.
NumericalLimitAtInfinity
- NumericalLimitAtInfinity (_f,step_fun,tolerance,successive_for_success,N)
+ NumericalLimitAtInfinity (_f,step_fun,tolerance,successive_for_success,N)
Attempt to calculate the limit of f(step_fun(i)) as i goes from 1
to N.
NumericalRightDerivative
- NumericalRightDerivative (f,x0)
+ NumericalRightDerivative (f,x0)
Attempt to calculate numerical right derivative.
OddPeriodicExtension
- OddPeriodicExtension (f,L)
+ OddPeriodicExtension (f,L)
Return a function which is odd periodic extension of f with half
period L. That is a function defined on the interval [0,L]
@@ -5167,19 +5233,19 @@
OneSidedFivePointFormula
- OneSidedFivePointFormula (f,x0,h)
+ OneSidedFivePointFormula (f,x0,h)
Compute one-sided derivative using five point formula.
OneSidedThreePointFormula
- OneSidedThreePointFormula (f,x0,h)
+ OneSidedThreePointFormula (f,x0,h)
Compute one-sided derivative using three-point formula.
PeriodicExtension
- PeriodicExtension (f,a,b)
+ PeriodicExtension (f,a,b)
Return a function which is the periodic extension of f defined on
the interval [a,b] and has period b-a.
@@ -5188,29 +5254,29 @@
RightLimit
- RightLimit (f,x0)
+ RightLimit (f,x0)
Calculate the right limit of a real-valued function at x0.
TwoSidedFivePointFormula
- TwoSidedFivePointFormula (f,x0,h)
+ TwoSidedFivePointFormula (f,x0,h)
Compute two-sided derivative using five-point formula.
TwoSidedThreePointFormula
- TwoSidedThreePointFormula (f,x0,h)
+ TwoSidedThreePointFormula (f,x0,h)
Compute two-sided derivative using three-point formula.
----------------------------------------------------------------------
-11.12. Functions
+Functions
Argument
- Argument (z)
+ Argument (z)
Aliases: Arg arg
@@ -5218,19 +5284,19 @@
DirichletKernel
- DirichletKernel (n,t)
+ DirichletKernel (n,t)
Dirichlet kernel of order n.
DiscreteDelta
- DiscreteDelta (v)
+ DiscreteDelta (v)
Returns 1 iff all elements are zero.
ErrorFunction
- ErrorFunction (x)
+ ErrorFunction (x)
Aliases: erf
@@ -5240,7 +5306,7 @@
FejerKernel
- FejerKernel (n,t)
+ FejerKernel (n,t)
Fejer kernel of order n evaluated at t
@@ -5248,7 +5314,7 @@
GammaFunction
- GammaFunction (x)
+ GammaFunction (x)
Aliases: Gamma
@@ -5258,19 +5324,19 @@
KroneckerDelta
- KroneckerDelta (v)
+ KroneckerDelta (v)
Returns 1 iff all elements are equal.
MinimizeFunction
- MinimizeFunction (func,x,incr)
+ MinimizeFunction (func,x,incr)
Find the first value where f(x)=0.
MoebiusDiskMapping
- MoebiusDiskMapping (a,z)
+ MoebiusDiskMapping (a,z)
Moebius mapping of the disk to itself mapping a to 0.
@@ -5278,7 +5344,7 @@
MoebiusMapping
- MoebiusMapping (z,z2,z3,z4)
+ MoebiusMapping (z,z2,z3,z4)
Moebius mapping using the cross ratio taking z2,z3,z4 to 1,0, and
infinity respectively.
@@ -5287,7 +5353,7 @@
MoebiusMappingInftyToInfty
- MoebiusMappingInftyToInfty (z,z2,z3)
+ MoebiusMappingInftyToInfty (z,z2,z3)
Moebius mapping using the cross ratio taking infinity to infinity
and z2,z3 to 1 and 0 respectively.
@@ -5296,7 +5362,7 @@
MoebiusMappingInftyToOne
- MoebiusMappingInftyToOne (z,z3,z4)
+ MoebiusMappingInftyToOne (z,z3,z4)
Moebius mapping using the cross ratio taking infinity to 1 and
z3,z4 to 0 and infinity respectively.
@@ -5305,7 +5371,7 @@
MoebiusMappingInftyToZero
- MoebiusMappingInftyToZero (z,z2,z4)
+ MoebiusMappingInftyToZero (z,z2,z4)
Moebius mapping using the cross ratio taking infinity to 0 and
z2,z4 to 1 and infinity respectively.
@@ -5314,20 +5380,20 @@
PoissonKernel
- PoissonKernel (r,sigma)
+ PoissonKernel (r,sigma)
Poisson kernel on D(0,1) (not normalized to 1, that is integral of
this is 2pi).
PoissonKernelRadius
- PoissonKernelRadius (r,sigma)
+ PoissonKernelRadius (r,sigma)
Poisson kernel on D(0,R) (not normalized to 1).
RiemannZeta
- RiemannZeta (x)
+ RiemannZeta (x)
Aliases: zeta
@@ -5338,7 +5404,7 @@
UnitStep
- UnitStep (x)
+ UnitStep (x)
The unit step function is 0 for x<0, 1 otherwise. This is the
integral of the Dirac Delta function. Also called the Heaviside
@@ -5348,29 +5414,29 @@
cis
- cis (x)
+ cis (x)
The cis function, that is the same as cos(x)+1i*sin(x)
deg2rad
- deg2rad (x)
+ deg2rad (x)
Convert degrees to radians.
rad2deg
- rad2deg (x)
+ rad2deg (x)
Convert radians to degrees.
----------------------------------------------------------------------
-11.13. Equation Solving
+Equation Solving
CubicFormula
- CubicFormula (p)
+ CubicFormula (p)
Compute roots of a cubic (degree 3) polynomial using the cubic
formula. The polynomial should be given as a vector of
@@ -5383,7 +5449,7 @@
EulersMethod
- EulersMethod (f,x0,y0,x1,n)
+ EulersMethod (f,x0,y0,x1,n)
Use classical Euler's method to numerically solve y'=f(x,y) for
initial x0, y0 going to x1 with n increments, returns y at x1.
@@ -5397,7 +5463,7 @@
FindRootBisection
- FindRootBisection (f,a,b,TOL,N)
+ FindRootBisection (f,a,b,TOL,N)
Find root of a function using the bisection method. TOL is the
desired tolerance and N is the limit on the number of iterations
@@ -5408,7 +5474,7 @@
FindRootFalsePosition
- FindRootFalsePosition (f,a,b,TOL,N)
+ FindRootFalsePosition (f,a,b,TOL,N)
Find root of a function using the method of false position. TOL is
the desired tolerance and N is the limit on the number of
@@ -5419,7 +5485,7 @@
FindRootMullersMethod
- FindRootMullersMethod (f,x1,x2,x3,TOL,N)
+ FindRootMullersMethod (f,x1,x2,x3,TOL,N)
Find root of a function using the Muller's method. TOL is the
desired tolerance and N is the limit on the number of iterations
@@ -5430,7 +5496,7 @@
FindRootSecant
- FindRootSecant (f,a,b,TOL,N)
+ FindRootSecant (f,a,b,TOL,N)
Find root of a function using the secant method. TOL is the
desired tolerance and N is the limit on the number of iterations
@@ -5441,7 +5507,7 @@
PolynomialRoots
- PolynomialRoots (p)
+ PolynomialRoots (p)
Compute roots of a polynomial (degrees 1 through 4) using one of
the formulas for such polynomials. The polynomial should be given
@@ -5453,7 +5519,7 @@
QuadraticFormula
- QuadraticFormula (p)
+ QuadraticFormula (p)
Compute roots of a quadratic (degree 2) polynomial using the
quadratic formula. The polynomial should be given as a vector of
@@ -5464,7 +5530,7 @@
QuarticFormula
- QuarticFormula (p)
+ QuarticFormula (p)
Compute roots of a quartic (degree 4) polynomial using the quartic
formula. The polynomial should be given as a vector of
@@ -5475,7 +5541,7 @@
RungeKutta
- RungeKutta (f,x0,y0,x1,n)
+ RungeKutta (f,x0,y0,x1,n)
Use classical non-adaptive fourth order Runge-Kutta method to
numerically solve y'=f(x,y) for initial x0, y0 going to x1 with n
@@ -5490,11 +5556,11 @@
----------------------------------------------------------------------
-11.14. Statistics
+Statistics
Average
- Average (m)
+ Average (m)
Aliases: average Mean mean
@@ -5504,7 +5570,7 @@
GaussDistribution
- GaussDistribution (x,sigma)
+ GaussDistribution (x,sigma)
Integral of the GaussFunction from 0 to x (area under the normal
curve).
@@ -5513,7 +5579,7 @@
GaussFunction
- GaussFunction (x,sigma)
+ GaussFunction (x,sigma)
The normalized Gauss distribution function (the normal curve).
@@ -5521,7 +5587,7 @@
Median
- Median (m)
+ Median (m)
Aliases: median
@@ -5531,7 +5597,7 @@
PopulationStandardDeviation
- PopulationStandardDeviation (m)
+ PopulationStandardDeviation (m)
Aliases: stdevp
@@ -5539,7 +5605,7 @@
RowAverage
- RowAverage (m)
+ RowAverage (m)
Aliases: RowMean
@@ -5549,7 +5615,7 @@
RowMedian
- RowMedian (m)
+ RowMedian (m)
Calculate median of each row in a matrix and return a column
vector of the medians.
@@ -5558,7 +5624,7 @@
RowPopulationStandardDeviation
- RowPopulationStandardDeviation (m)
+ RowPopulationStandardDeviation (m)
Aliases: rowstdevp
@@ -5567,7 +5633,7 @@
RowStandardDeviation
- RowStandardDeviation (m)
+ RowStandardDeviation (m)
Aliases: rowstdev
@@ -5576,7 +5642,7 @@
StandardDeviation
- StandardDeviation (m)
+ StandardDeviation (m)
Aliases: stdev
@@ -5584,17 +5650,17 @@
----------------------------------------------------------------------
-11.15. Polynomials
+Polynomials
AddPoly
- AddPoly (p1,p2)
+ AddPoly (p1,p2)
Add two polynomials (vectors).
DividePoly
- DividePoly (p,q,&r)
+ DividePoly (p,q,&r)
Divide two polynomials (as vectors) using long division. Returns
the quotient of the two polynomials. The optional argument r is
@@ -5605,19 +5671,19 @@
IsPoly
- IsPoly (p)
+ IsPoly (p)
Check if a vector is usable as a polynomial.
MultiplyPoly
- MultiplyPoly (p1,p2)
+ MultiplyPoly (p1,p2)
Multiply two polynomials (as vectors).
NewtonsMethodPoly
- NewtonsMethodPoly (poly,guess,epsilon,maxn)
+ NewtonsMethodPoly (poly,guess,epsilon,maxn)
Run newton's method on a polynomial to attempt to find a root,
returns after two successive values are within epsilon or after
@@ -5625,136 +5691,136 @@
Poly2ndDerivative
- Poly2ndDerivative (p)
+ Poly2ndDerivative (p)
Take second polynomial (as vector) derivative.
PolyDerivative
- PolyDerivative (p)
+ PolyDerivative (p)
Take polynomial (as vector) derivative.
PolyToFunction
- PolyToFunction (p)
+ PolyToFunction (p)
Make function out of a polynomial (as vector).
PolyToString
- PolyToString (p,var...)
+ PolyToString (p,var...)
Make string out of a polynomial (as vector).
SubtractPoly
- SubtractPoly (p1,p2)
+ SubtractPoly (p1,p2)
Subtract two polynomials (as vectors).
TrimPoly
- TrimPoly (p)
+ TrimPoly (p)
Trim zeros from a polynomial (as vector).
----------------------------------------------------------------------
-11.16. Set Theory
+Set Theory
Intersection
- Intersection (X,Y)
+ Intersection (X,Y)
Returns a set theoretic intersection of X and Y (X and Y are
vectors pretending to be sets).
IsIn
- IsIn (x,X)
+ IsIn (x,X)
Returns true if the element x is in the set X (where X is a vector
pretending to be a set).
IsSubset
- IsSubset (X, Y)
+ IsSubset (X, Y)
Returns true if X is a subset of Y (X and Y are vectors pretending
to be sets).
MakeSet
- MakeSet (X)
+ MakeSet (X)
Returns a vector where every element of X appears only once.
SetMinus
- SetMinus (X,Y)
+ SetMinus (X,Y)
Returns a set theoretic difference X-Y (X and Y are vectors
pretending to be sets).
Union
- Union (X,Y)
+ Union (X,Y)
Returns a set theoretic union of X and Y (X and Y are vectors
pretending to be sets).
----------------------------------------------------------------------
-11.17. Miscellaneous
+Miscellaneous
ASCIIToString
- ASCIIToString (vec)
+ ASCIIToString (vec)
Convert a vector of ASCII values to a string.
AlphabetToString
- AlphabetToString (vec,alphabet)
+ AlphabetToString (vec,alphabet)
Convert a vector of 0-based alphabet values (positions in the
alphabet string) to a string.
StringToASCII
- StringToASCII (str)
+ StringToASCII (str)
Convert a string to a vector of ASCII values.
StringToAlphabet
- StringToAlphabet (str,alphabet)
+ StringToAlphabet (str,alphabet)
Convert a string to a vector of 0-based alphabet values (positions
in the alphabet string), -1's for unknown letters.
----------------------------------------------------------------------
-11.18. Symbolic Operations
+Symbolic Operations
SymbolicDerivative
- SymbolicDerivative (f)
+ SymbolicDerivative (f)
Attempt to symbolically differentiate the function f, where f is a
function of one variable.
Examples:
- genius> SymbolicDerivative(sin)
- = (`(x)=cos(x))
- genius> SymbolicDerivative(`(x)=7*x^2)
- = (`(x)=(7*(2*x)))
+ genius> SymbolicDerivative(sin)
+ = (`(x)=cos(x))
+ genius> SymbolicDerivative(`(x)=7*x^2)
+ = (`(x)=(7*(2*x)))
SymbolicDerivativeTry
- SymbolicDerivativeTry (f)
+ SymbolicDerivativeTry (f)
Attempt to symbolically differentiate the function f, where f is a
function of one variable, returns null if unsuccessful but is
@@ -5762,34 +5828,34 @@
SymbolicNthDerivative
- SymbolicNthDerivative (f,n)
+ SymbolicNthDerivative (f,n)
Attempt to symbolically differentiate a function n times. (See
SymbolicDerivative)
SymbolicNthDerivativeTry
- SymbolicNthDerivativeTry (f,n)
+ SymbolicNthDerivativeTry (f,n)
Attempt to symbolically differentiate a function n times quietly
and return null on failure (See SymbolicNthDerivative)
SymbolicTaylorApproximationFunction
- SymbolicTaylorApproximationFunction (f,x0,n)
+ SymbolicTaylorApproximationFunction (f,x0,n)
Attempt to construct the taylor approximation function around x0
to the nth degree. (See SymbolicDerivative)
----------------------------------------------------------------------
-11.19. Plotting
+Plotting
LinePlot
- LinePlot (func1,func2,func3,...)
+ LinePlot (func1,func2,func3,...)
- LinePlot (func1,func2,func3,x1,x2,y1,y2)
+ LinePlot (func1,func2,func3,x1,x2,y1,y2)
Plot a function (or several functions) with a line. First up to 10
arguments are functions, then optionally you can specify the
@@ -5802,21 +5868,21 @@
Examples:
- genius> LinePlot(sin,cos)
- genius> LinePlot(`(x)=x^2,-1,1,0,1)
+ genius> LinePlot(sin,cos)
+ genius> LinePlot(`(x)=x^2,-1,1,0,1)
LinePlotClear
- LinePlotClear ()
+ LinePlotClear ()
Show the line plot window and clear out functions and any other
lines that were drawn.
LinePlotDrawLine
- LinePlotDrawLine (x1,y1,x2,y2,...)
+ LinePlotDrawLine (x1,y1,x2,y2,...)
- LinePlotDrawLine (v,...)
+ LinePlotDrawLine (v,...)
Draw a line from x1,y1 to x2,y2. x1,y1, x2,y2 can be replaced by
an n by 2 matrix for a longer line.
@@ -5832,17 +5898,17 @@
Examples:
- genius> LinePlotDrawLine(0,0,1,1,"color","blue","thickness",3)
- genius> LinePlotDrawLine([0,0;1,-1;-1,-1])
- genius> LinePlotDrawLine([0,0;1,1],"arrow","end")
+ genius> LinePlotDrawLine(0,0,1,1,"color","blue","thickness",3)
+ genius> LinePlotDrawLine([0,0;1,-1;-1,-1])
+ genius> LinePlotDrawLine([0,0;1,1],"arrow","end")
LinePlotParametric
- LinePlotParametric (xfunc,yfunc,...)
+ LinePlotParametric (xfunc,yfunc,...)
- LinePlotParametric (xfunc,yfunc,t1,t2,tinc)
+ LinePlotParametric (xfunc,yfunc,t1,t2,tinc)
- LinePlotParametric (xfunc,yfunc,t1,t2,tinc,x1,x2,y1,y2)
+ LinePlotParametric (xfunc,yfunc,t1,t2,tinc,x1,x2,y1,y2)
Plot a parametric function with a line. First come the functions
for x and y then optionally the t limits as t1,t2,tinc, then
@@ -5856,11 +5922,11 @@
LinePlotCParametric
- LinePlotCParametric (func,...)
+ LinePlotCParametric (func,...)
- LinePlotCParametric (func,t1,t2,tinc)
+ LinePlotCParametric (func,t1,t2,tinc)
- LinePlotCParametric (func,t1,t2,tinc,x1,x2,y1,y2)
+ LinePlotCParametric (func,t1,t2,tinc,x1,x2,y1,y2)
Plot a parametric complex valued function with a line. First comes
the function that returns x+iy, then optionally the t limits as
@@ -5874,13 +5940,13 @@
SlopefieldClearSolutions
- SlopefieldClearSolutions ()
+ SlopefieldClearSolutions ()
Clears the solutions drawn by the SlopefieldDrawSolution function.
SlopefieldDrawSolution
- SlopefieldDrawSolution (x, y, dx)
+ SlopefieldDrawSolution (x, y, dx)
When a slope field plot is active, draw a solution with the
specified initial condition. The standard Runge-Kutta method is
@@ -5891,9 +5957,9 @@
SlopefieldPlot
- SlopefieldPlot (func)
+ SlopefieldPlot (func)
- SlopefieldPlot (func,x1,x2,y1,y2)
+ SlopefieldPlot (func,x1,x2,y1,y2)
Plot a slope field. The function func should take two real numbers
x and y, or a single complex number. Optionally you can specify
@@ -5906,13 +5972,13 @@
Examples:
- genius> Slopefield(`(x,y)=sin(x-y),-5,5,-5,5)
+ genius> Slopefield(`(x,y)=sin(x-y),-5,5,-5,5)
SurfacePlot
- SurfacePlot (func)
+ SurfacePlot (func)
- SurfacePlot (func,x1,x2,y1,y2,z1,z2)
+ SurfacePlot (func,x1,x2,y1,y2,z1,z2)
Plot a surface function which takes either two arguments or a
complex number. First comes the function then optionally limits as
@@ -5922,20 +5988,20 @@
Examples:
- genius> SurfacePlot(|sin|,-1,1,-1,1,0,1.5)
- genius> SurfacePlot(`(x,y)=x^2+y,-1,1,-1,1,-2,2)
- genius> SurfacePlot(`(z)=|z|^2,-1,1,-1,1,0,2)
+ genius> SurfacePlot(|sin|,-1,1,-1,1,0,1.5)
+ genius> SurfacePlot(`(x,y)=x^2+y,-1,1,-1,1,-2,2)
+ genius> SurfacePlot(`(z)=|z|^2,-1,1,-1,1,0,2)
VectorfieldClearSolutions
- VectorfieldClearSolutions ()
+ VectorfieldClearSolutions ()
Clears the solutions drawn by the VectorfieldDrawSolution
function.
VectorfieldDrawSolution
- VectorfieldDrawSolution (x, y, dt, tlen)
+ VectorfieldDrawSolution (x, y, dt, tlen)
When a vector field plot is active, draw a solution with the
specified initial condition. The standard Runge-Kutta method is
@@ -5947,9 +6013,9 @@
VectorfieldPlot
- VectorfieldPlot (funcx, funcy)
+ VectorfieldPlot (funcx, funcy)
- VectorfieldPlot (funcx, funcy, x1, x2, y1, y2)
+ VectorfieldPlot (funcx, funcy, x1, x2, y1, y2)
Plot a two dimensional vector field. The function funcx should be
the dx/dt of the vectorfield and the function funcy should be the
@@ -5968,91 +6034,91 @@
Examples:
- genius> VectorfieldPlot(`(x,y)=x^2-y, `(x,y)=y^2-x, -1, 1, -1, 1)
+ genius> VectorfieldPlot(`(x,y)=x^2-y, `(x,y)=y^2-x, -1, 1, -1, 1)
----------------------------------------------------------------------
- Chapter 12. Example Programs in GEL
+ Example Programs in GEL
Here is a function that calculates factorials:
- function f(x) = if x <= 1 then 1 else (f(x-1)*x)
+ function f(x) = if x <= 1 then 1 else (f(x-1)*x)
With indentation it becomes:
- function f(x) = (
- if x <= 1 then
- 1
- else
- (f(x-1)*x)
- )
+ function f(x) = (
+ if x <= 1 then
+ 1
+ else
+ (f(x-1)*x)
+ )
This is a direct port of the factorial function from the bc manpage. The
syntax seems similar to bc, but different in that in GEL, the last
expression is the one that is returned. Using the return function instead,
it would be:
- function f(x) = (
- if (x <= 1) then return (1);
- return (f(x-1) * x)
- )
+ function f(x) = (
+ if (x <= 1) then return (1);
+ return (f(x-1) * x)
+ )
By far the easiest way to define a factorial function would be using the
product loop as follows. This is not only the shortest and fastest, but
also probably the most readable version.
- function f(x) = prod k=1 to x do k
+ function f(x) = prod k=1 to x do k
Here is a larger example, this basically redefines the internal ref
function to calculate the row echelon form of a matrix. The function ref
is built in and much faster, but this example demonstrates some of the
more complex features of GEL.
- # Calculate the row-echelon form of a matrix
- function MyOwnREF(m) = (
- if not IsMatrix(m) or not IsValueOnly(m) then
- (error("ref: argument not a value only matrix");bailout);
- s := min(rows(m), columns(m));
- i := 1;
- d := 1;
- while d <= s and i <= columns(m) do (
-
- # This just makes the anchor element non-zero if at
- # all possible
- if m@(d,i) == 0 then (
- j := d+1;
- while j <= rows(m) do (
- if m@(j,i) == 0 then
- (j=j+1;continue);
- a := m@(j,);
- m@(j,) := m@(d,);
- m@(d,) := a;
- j := j+1;
- break
- )
- );
- if m@(d,i) == 0 then
- (i:=i+1;continue);
-
- # Here comes the actual zeroing of all but the anchor
- # element rows
- j := d+1;
- while j <= rows(m)) do (
- if m@(j,i) != 0 then (
- m@(j,) := m@(j,)-(m@(j,i)/m@(d,i))*m@(d,)
- );
- j := j+1
- );
- m@(d,) := m@(d,) * (1/m@(d,i));
- d := d+1;
- i := i+1
- );
- m
- )
+ # Calculate the row-echelon form of a matrix
+ function MyOwnREF(m) = (
+ if not IsMatrix(m) or not IsValueOnly(m) then
+ (error("ref: argument not a value only matrix");bailout);
+ s := min(rows(m), columns(m));
+ i := 1;
+ d := 1;
+ while d <= s and i <= columns(m) do (
+
+ # This just makes the anchor element non-zero if at
+ # all possible
+ if m@(d,i) == 0 then (
+ j := d+1;
+ while j <= rows(m) do (
+ if m@(j,i) == 0 then
+ (j=j+1;continue);
+ a := m@(j,);
+ m@(j,) := m@(d,);
+ m@(d,) := a;
+ j := j+1;
+ break
+ )
+ );
+ if m@(d,i) == 0 then
+ (i:=i+1;continue);
+
+ # Here comes the actual zeroing of all but the anchor
+ # element rows
+ j := d+1;
+ while j <= rows(m)) do (
+ if m@(j,i) != 0 then (
+ m@(j,) := m@(j,)-(m@(j,i)/m@(d,i))*m@(d,)
+ );
+ j := j+1
+ );
+ m@(d,) := m@(d,) * (1/m@(d,i));
+ d := d+1;
+ i := i+1
+ );
+ m
+ )
----------------------------------------------------------------------
- Chapter 13. Settings
+ Settings
To configure Genius Mathematics Tool, choose Settings->Preferences. There
are several basic parameters provided by the calculator in addition to the
@@ -6062,8 +6128,10 @@
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
- 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.
+ 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.
As an example, you can set the maximum number of digits in a result
to 12 by typing:
@@ -6072,7 +6140,7 @@
----------------------------------------------------------------------
-13.1. Output
+Output
Maximum digits to output
@@ -6142,7 +6210,8 @@
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 Section 11.3.
+ affect the output see the Section called Parameters in the Chapter called
+ List of GEL functions.
IntegerOutputBase
@@ -6159,7 +6228,7 @@
----------------------------------------------------------------------
-13.2. Precision
+Precision
Floating point precision
@@ -6179,7 +6248,7 @@
----------------------------------------------------------------------
-13.3. Terminal
+Terminal
Terminal refers to the console in the work area.
@@ -6203,7 +6272,7 @@
----------------------------------------------------------------------
-13.4. Memory
+Memory
Maximum number of nodes to allocate
@@ -6226,7 +6295,7 @@
----------------------------------------------------------------------
- Chapter 14. About Genius Mathematics Tool
+ About Genius Mathematics Tool
Genius Mathematics Tool was written by Jiri (George) Lebl
(<jirka 5z com>). The history of Genius Mathematics Tool goes back to late
diff --git a/help/C/genius.xml b/help/C/genius.xml
index 296f41c..5563ca8 100644
--- a/help/C/genius.xml
+++ b/help/C/genius.xml
@@ -4,8 +4,7 @@
<!ENTITY app "<application>Genius Mathematics Tool</application>">
<!ENTITY appname "Genius">
<!ENTITY appversion "1.0.10">
- <!ENTITY manrevision "0.2.4">
- <!ENTITY date "January 2010">
+ <!ENTITY date "June 2010">
<!ENTITY legal SYSTEM "legal.xml">
@@ -1950,11 +1949,11 @@ or:
<para>
As we said before, there exist special variables called parameters
that exist in all scopes. To declare a parameter called
- <variable>foo</variable> with the initial value 1, we write
+ <varname>foo</varname> with the initial value 1, we write
<programlisting><![CDATA[parameter foo = 1
]]></programlisting>
- From then on, <variable>foo</variable> is a strictly global variable.
- Setting <variable>foo</variable> inside any function will modify the
+ From then on, <varname>foo</varname> is a strictly global variable.
+ Setting <varname>foo</varname> inside any function will modify the
variable in all contexts, that is, functions do not have a private
copy of parameters.
</para>
diff --git a/src/graphing.c b/src/graphing.c
index c7bed5d..4ee7432 100644
--- a/src/graphing.c
+++ b/src/graphing.c
@@ -3002,6 +3002,8 @@ make_matrix_from_lp_varnames (void)
n->mat.quoted = FALSE;
gel_matrixw_set_size (m, 4, 1);
+ init_var_names ();
+
gel_matrixw_set_index (m, 0, 0) = gel_makenum_string (lp_x_name);
gel_matrixw_set_index (m, 1, 0) = gel_makenum_string (lp_y_name);
gel_matrixw_set_index (m, 2, 0) = gel_makenum_string (lp_z_name);
@@ -3010,6 +3012,27 @@ make_matrix_from_lp_varnames (void)
return n;
}
+static GelETree *
+make_matrix_from_sp_varnames (void)
+{
+ GelETree *n;
+ GelMatrixW *m;
+ /*make us a new empty node*/
+ GEL_GET_NEW_NODE (n);
+ n->type = GEL_MATRIX_NODE;
+ m = n->mat.matrix = gel_matrixw_new ();
+ n->mat.quoted = FALSE;
+ gel_matrixw_set_size (m, 3, 1);
+
+ init_var_names ();
+
+ gel_matrixw_set_index (m, 0, 0) = gel_makenum_string (sp_x_name);
+ gel_matrixw_set_index (m, 1, 0) = gel_makenum_string (sp_y_name);
+ gel_matrixw_set_index (m, 2, 0) = gel_makenum_string (sp_z_name);
+
+ return n;
+}
+
static gboolean
get_limits_from_matrix_surf (GelETree *m, double *x1, double *x2, double *y1, double *y2, double *z1, double *z2)
{
@@ -3912,6 +3935,8 @@ plot_functions (gboolean do_window_present,
static void
plot_surface_functions (gboolean do_window_present)
{
+ init_var_names ();
+
ensure_window (do_window_present);
clear_graph ();
@@ -4401,7 +4426,6 @@ static void
set_surface_labels (void)
{
char *s;
- /* XXX */
if (surface_info_label != NULL) {
s = g_strdup_printf
@@ -4960,6 +4984,8 @@ create_surface_box (void)
GtkWidget *mainbox, *frame;
GtkWidget *hbox, *box, *b, *w;
+ init_var_names ();
+
mainbox = gtk_vbox_new (FALSE, GENIUS_PAD);
gtk_container_set_border_width (GTK_CONTAINER (mainbox), GENIUS_PAD);
@@ -7475,6 +7501,10 @@ set_LinePlotVariableNames (GelETree * a)
return NULL;
}
+ g_free (lp_x_name);
+ g_free (lp_y_name);
+ g_free (lp_z_name);
+ g_free (lp_t_name);
lp_x_name = g_strdup (sx);
lp_y_name = g_strdup (sy);
lp_z_name = g_strdup (sz);
@@ -7492,6 +7522,82 @@ get_LinePlotVariableNames (void)
}
static GelETree *
+set_SurfacePlotVariableNames (GelETree * a)
+{
+ GelETree *t;
+ char *sx, *sy, *sz;
+
+ if G_UNLIKELY (plot_in_progress != 0) {
+ gel_errorout (_("%s: Plotting in progress, cannot call %s"),
+ "set_SurfacePlotVariableNames", "set_SurfacePlotVariableNames");
+ return NULL;
+ }
+
+ if (a->type != GEL_MATRIX_NODE ||
+ gel_matrixw_elements (a->mat.matrix) != 3) {
+ gel_errorout (_("Variable names not given in a 3-vector"));
+ return NULL;
+ }
+
+ t = gel_matrixw_vindex (a->mat.matrix, 0);
+ if (t->type == GEL_IDENTIFIER_NODE) {
+ sx = t->id.id->token;
+ } else if (t->type == GEL_STRING_NODE) {
+ sx = t->str.str;
+ } else {
+ gel_errorout (_("Variable names should be strings"));
+ return NULL;
+ }
+ t = gel_matrixw_vindex (a->mat.matrix, 1);
+ if (t->type == GEL_IDENTIFIER_NODE) {
+ sy = t->id.id->token;
+ } else if (t->type == GEL_STRING_NODE) {
+ sy = t->str.str;
+ } else {
+ gel_errorout (_("Variable names should be strings"));
+ return NULL;
+ }
+ t = gel_matrixw_vindex (a->mat.matrix, 2);
+ if (t->type == GEL_IDENTIFIER_NODE) {
+ sz = t->id.id->token;
+ } else if (t->type == GEL_STRING_NODE) {
+ sz = t->str.str;
+ } else {
+ gel_errorout (_("Variable names should be strings"));
+ return NULL;
+ }
+ if ( ! is_identifier (sx) ||
+ ! is_identifier (sy) ||
+ ! is_identifier (sz)) {
+ gel_errorout (_("Variable names must be valid identifiers"));
+ return NULL;
+ }
+ if (strcmp (sx, sy) == 0 ||
+ strcmp (sx, sz) == 0 ||
+ strcmp (sy, sz) == 0) {
+ gel_errorout (_("Variable names must be mutually distinct"));
+ return NULL;
+ }
+
+ g_free (sp_x_name);
+ g_free (sp_y_name);
+ g_free (sp_z_name);
+ sp_x_name = g_strdup (sx);
+ sp_y_name = g_strdup (sy);
+ sp_z_name = g_strdup (sz);
+
+ set_surface_labels ();
+
+ return make_matrix_from_sp_varnames ();
+}
+
+static GelETree *
+get_SurfacePlotVariableNames (void)
+{
+ return make_matrix_from_sp_varnames ();
+}
+
+static GelETree *
set_VectorfieldNormalized (GelETree * a)
{
if G_UNLIKELY (plot_in_progress != 0) {
@@ -7579,6 +7685,7 @@ gel_add_graph_functions (void)
PARAMETER (SlopefieldTicks, N_("Number of slopefield ticks as a vector [vertical,horizontal]."));
PARAMETER (VectorfieldTicks, N_("Number of vectorfield ticks as a vector [vertical,horizontal]."));
PARAMETER (LinePlotVariableNames, N_("Default names used by all 2D plot functions. Should be a 4 vector of strings or identifiers [x,y,z,t]."));
+ PARAMETER (SurfacePlotVariableNames, N_("Default names used by surface plot functions. Should be a 3 vector of strings or identifiers [x,y,z] (where z=x+iy and not the dependent axis)."));
PARAMETER (VectorfieldNormalized, N_("Normalize vectorfields if true. That is, only show direction and not magnitude."));
PARAMETER (LinePlotDrawLegends, N_("If to draw legends or not on line plots."));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]