To get help on a specific function from the console type:

    help FunctionName

# Commands

help

      help

      help FunctionName

  Print help (or help on a function/command).

load

      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

  Change working directory to `/directory/name`.

pwd

      pwd

  Print the current working directory.

ls

      ls

  List files in the current directory.

plugin

      plugin plugin_name

  Load a plugin. Plugin of that name must be installed on the system in the proper directory.

# 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, 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 returned. The execution of the program is blocked until the user responds. If `default` is given, then it is pre-typed in for the user to just press enter on.

Compose

      Compose (f,g)

  Compose two functions and return a function that is the composition of `f` and `g`.

ComposePower

      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

Evaluate

      Evaluate (str)

  Parses and evaluates a string.

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 this returns what this modulo was. Normally the body of the function called is not executed in modular arithmetic, and this builtin function makes it possible to make GEL functions aware of modular arithmetic.

Identity

      Identity (x)

  Identity function, returns its argument.

IntegerFromBoolean

      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 interpreted as `true` and zero will be interpreted as `false`.

IsBoolean

      IsBoolean (arg)

  Check if argument is a boolean (and not a number).

IsDefined

      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 separately and the matrix should contain strings or identifiers.

IsFunction

      IsFunction (arg)

  Check if argument is a function.

IsFunctionOrIdentifier

      IsFunctionOrIdentifier (arg)

  Check if argument is a function or an identifier.

IsFunctionRef

      IsFunctionRef (arg)

  Check if argument is a function reference. This includes variable references.

IsMatrix

      IsMatrix (arg)

  Check if argument is a matrix. Even though `null` is sometimes considered an empty matrix, the function `IsMatrix` does not consider `null` a matrix.

IsNull

      IsNull (arg)

  Check if argument is a `null`.

IsString

      IsString (arg)

  Check if argument is a text string.

IsValue

      IsValue (arg)

  Check if argument is a number.

Parse

      Parse (str)

  Parses but does not evaluate a string. Note that certain pre-computation is done during the parsing stage.

SetFunctionFlags

      SetFunctionFlags (id,flags...)

  Set flags for a function, currently `"PropagateMod"` and `"NoModuloArguments"`. If `"PropagateMod"` is set, then the body of the function is evaluated in modular arithmetic when the function is called inside a block that was evaluated using modular arithmetic (using `mod`). If `"NoModuloArguments"`, then the arguments of the function are never evaluated using modular arithmetic.

SetHelp

      SetHelp (id,category,desc)

  Set the category and help description line for a function.

SetHelpAlias

      SetHelpAlias (id,alias)

  Sets up a help alias.

chdir

      chdir (dir)

  Changes current directory, same as the `cd`.

display

      display (str,expr)

  Display a string and an expression with a colon to separate them.

error

      error (str)

  Prints a string to the error stream (onto the console).

exit

      exit

  Aliases: `quit`

  Exits the program.

false

      false

  Aliases: `False` `FALSE`

  The `false` boolean value.

manual

      manual

  Displays the user manual.

print

      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 printed.

printn

      printn (str)

  Prints an expression without a trailing newline. The argument `str` can be any expression. It is made into a string before being printed.

protect

      protect (id)

  Protect a variable from being modified. This is used on the internal GEL functions to avoid them being accidentally overridden.

ProtectAll

      ProtectAll ()

  Protect all currently defined variables, parameters and functions from being modified. This is used on the internal GEL functions to avoid them being accidentally overridden. Normally &app; considers unprotected variables as user defined.

set

      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)

  will set the global variable `x` to the value 1.
string

      string (s)

  Make a string. This will make a string out of any argument.

true

      true

  Aliases: `True` `TRUE`

  The `true` boolean value.

undefine

      undefine (id)

  Alias: `Undefine`

  Undefine a variable. This includes locals and globals, every value on all context levels is wiped. This function should really not be used on local variables. A vector of identifiers can also be passed to undefine several variables.

UndefineAll

      UndefineAll ()

  Undefine all unprotected global variables (including functions and parameters). Normally &app; considers protected variables as system defined functions and variables. Note that `UndefineAll` only removes the global definition of symbols not local ones, so that it may be run from inside other functions safely.

unprotect

      unprotect (id)

  Unprotect a variable from being modified.

UserVariables

      UserVariables ()

  Return a vector of identifiers of user defined (unprotected) global variables.

wait

      wait (secs)

  Waits a specified number of seconds. `secs` must be non-negative. Zero is accepted and nothing happens in this case, except possibly user interface events are processed.

version

      version

  Returns the version of Genius as a horizontal 3-vector with major version first, then minor version and finally the patch level.

warranty

      warranty

  Gives the warranty information.

# Parameters

ChopTolerance

      ChopTolerance = number

  Tolerance of the `Chop` function.

ContinuousNumberOfTries

      ContinuousNumberOfTries = number

  How many iterations to try to find the limit for continuity and limits.

ContinuousSFS

      ContinuousSFS = number

  How many successive steps to be within tolerance for calculation of continuity.

ContinuousTolerance

      ContinuousTolerance = number

  Tolerance for continuity of functions and for calculating the limit.

DerivativeNumberOfTries

      DerivativeNumberOfTries = number

  How many iterations to try to find the limit for derivative.

DerivativeSFS

      DerivativeSFS = number

  How many successive steps to be within tolerance for calculation of derivative.

DerivativeTolerance

      DerivativeTolerance = number

  Tolerance for calculating the derivatives of functions.

ErrorFunctionTolerance

      ErrorFunctionTolerance = number

  Tolerance of the `ErrorFunction`.

FloatPrecision

      FloatPrecision = number

  Floating point precision.

FullExpressions

      FullExpressions = boolean

  Print full expressions, even if more than a line.

GaussDistributionTolerance

      GaussDistributionTolerance = number

  Tolerance of the `GaussDistribution` function.

IntegerOutputBase

      IntegerOutputBase = number

  Integer output base.

IsPrimeMillerRabinReps

      IsPrimeMillerRabinReps = number

  Number of extra Miller-Rabin tests to run on a number before declaring it a prime in `IsPrime`.

LinePlotDrawLegends

      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

  Maximum digits to display.

MaxErrors

      MaxErrors = number

  Maximum errors to display.

MixedFractions

      MixedFractions = boolean

  If true, mixed fractions are printed.

NumericalIntegralFunction

      NumericalIntegralFunction = function

  The function used for numerical integration in `NumericalIntegral`.

NumericalIntegralSteps

      NumericalIntegralSteps = number

  Steps to perform in `NumericalIntegral`.

OutputChopExponent

      OutputChopExponent = number

  When another number in the object being printed (a matrix or a value) is greater than 10-OutputChopWhenExponent, and the number being printed is less than 10-OutputChopExponent, then display `0.0` instead of the number.

  Output is never chopped if `OutputChopExponent` is zero. It must be a non-negative integer.

  If you want output always chopped according to `OutputChopExponent`, then set `OutputChopWhenExponent`, to something greater than or equal to `OutputChopExponent`.

OutputChopWhenExponent

      OutputChopWhenExponent = number

  When to chop output. See `OutputChopExponent`.

OutputStyle

      OutputStyle = string

  Output style, this can be `normal`, `latex`, `mathml` or `troff`.

  This affects mostly how matrices and fractions are printed out and is useful for pasting into documents. For example you can set this to the latex by:

      OutputStyle = "latex"

ResultsAsFloats

      ResultsAsFloats = boolean

  Convert all results to floats before printing.

ScientificNotation

      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

  How many iterations to try for `InfiniteSum` and `InfiniteProduct`.

SumProductSFS

      SumProductSFS = number

  How many successive steps to be within tolerance for `InfiniteSum` and `InfiniteProduct`.

SumProductTolerance

      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]

  Sets the limits for surface plotting (See `SurfacePlot`).

VectorfieldNormalized

      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`).

# Constants

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 to infinity.

  See Mathworld for more information.

EulerConstant

      EulerConstant

  Aliases: `gamma`

  Euler's Constant gamma. Sometimes called the Euler-Mascheroni constant.

  See Wikipedia or Planetmath or Mathworld for more information.

GoldenRatio

      GoldenRatio

  The Golden Ratio.

  See Wikipedia or Planetmath or Mathworld for more information.

Gravity

      Gravity

  Free fall acceleration at sea level.

  See Wikipedia for more information.

e

      e

  The base of the natural logarithm. `e^x` is the exponential function `exp`. This is the number approximately 2.71828182846...

  See Wikipedia or Planetmath or Mathworld for more information.

pi

      pi

  The number pi, that is the ratio of a circle's circumference to its diameter. This is approximately 3.14159265359...

  See Wikipedia or Planetmath or Mathworld for more information.

# Numeric

AbsoluteValue

      AbsoluteValue (x)

  Aliases: `abs`

  Absolute value of a number and if `x` is a complex value the modulus of `x`. I.e. this the distance of `x` to the origin.

  See Wikipedia, Planetmath (absolute value), Planetmath (modulus), Mathworld (absolute value) or Mathworld (complex modulus) for more information.

Chop

      Chop (x)

  Replace very small number with zero.

ComplexConjugate

      ComplexConjugate (z)

  Aliases: `conj` `Conj`

  Calculates the complex conjugate of the complex number `z`. If `z` is a vector or matrix, all its elements are conjugated.

  See Wikipedia for more information.

Denominator

      Denominator (x)

  Get the denominator of a rational number.

  See Wikipedia for more information.

FractionalPart

      FractionalPart (x)

  Return the fractional part of a number.

  See Wikipedia for more information.

Im

      Im (z)

  Aliases: `ImaginaryPart`

  Get the imaginary part of a complex number.

  See Wikipedia for more information.

IntegerQuotient

      IntegerQuotient (m,n)

  Division without remainder.

IsComplex

      IsComplex (num)

  Check if argument is a complex (non-real) number.

IsComplexRational

      IsComplexRational (num)

  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)

  Check if argument is a floating point number (non-complex).

IsGaussInteger

      IsGaussInteger (num)

  Aliases: `IsComplexInteger`

  Check if argument is a possibly complex integer.

IsInteger

      IsInteger (num)

  Check if argument is an integer (non-complex).

IsNonNegativeInteger

      IsNonNegativeInteger (num)

  Check if argument is a non-negative real integer.

IsPositiveInteger

      IsPositiveInteger (num)

  Aliases: `IsNaturalNumber`

  Check if argument is a positive real integer. Note that we accept the convention that 0 is not a natural number.

IsRational

      IsRational (num)

  Check if argument is a rational number (non-complex). Of course rational simply means "not stored as a floating point number."

IsReal

      IsReal (num)

  Check if argument is a real number.

Numerator

      Numerator (x)

  Get the numerator of a rational number.

  See Wikipedia for more information.

Re

      Re (z)

  Aliases: `RealPart`

  Get the real part of a complex number.

  See Wikipedia for more information.

Sign

      Sign (x)

  Aliases: `sign`

  Return the sign of a number. That is returns `-1` if value is negative, `0` if value is zero and `1` if value is positive. If `x` is a complex value then `Sign` returns the direction or 0.

ceil

      ceil (x)

  Aliases: `Ceiling`

  Get the lowest integer more than or equal to n.

exp

      exp (x)

  The exponential function. This is the function `e^x` where `e` is the base of the natural logarithm.

  See Wikipedia or Planetmath or Mathworld for more information.

float

      float (x)

  Make number a floating point value. That is returns the floating point representation of the number `x`.

floor

      floor (x)

  Aliases: `Floor`

  Get the highest integer less than or equal to `n`.

ln

      ln (x)

  The natural logarithm, the logarithm to base `e`.

log

      log (x)

      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)

  Logarithm of `x` base 10.

log2

      log2 (x)

  Aliases: `lg`

  Logarithm of `x` base 2.

max

      max (a,args...)

  Aliases: `Max` `Maximum`

  Returns the maximum of arguments or matrix.

min

      min (a,args...)

  Aliases: `Min` `Minimum`

  Returns the minimum of arguments or matrix.

rand

      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 specified) of the given size returned.

randint

      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]

round

      round (x)

  Aliases: `Round`

  Round a number.

sqrt

      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

  See Planetmath for more information.

trunc

      trunc (x)

  Aliases: `Truncate` `IntegerPart`

  Truncate number to an integer (return the integer part).

# Trigonometry

acos

      acos (x)

  Aliases: `arccos`

  The arccos (inverse cos) function.

acosh

      acosh (x)

  Aliases: `arccosh`

  The arccosh (inverse cosh) function.

acot

      acot (x)

  Aliases: `arccot`

  The arccot (inverse cot) function.

acoth

      acoth (x)

  Aliases: `arccoth`

  The arccoth (inverse coth) function.

acsc

      acsc (x)

  Aliases: `arccsc`

  The inverse cosecant function.

acsch

      acsch (x)

  Aliases: `arccsch`

  The inverse hyperbolic cosecant function.

asec

      asec (x)

  Aliases: `arcsec`

  The inverse secant function.

asech

      asech (x)

  Aliases: `arcsech`

  The inverse hyperbolic secant function.

asin

      asin (x)

  Aliases: `arcsin`

  The arcsin (inverse sin) function.

asinh

      asinh (x)

  Aliases: `arcsinh`

  The arcsinh (inverse sinh) function.

atan

      atan (x)

  Aliases: `arctan`

  Calculates the arctan (inverse tan) function.

  See Wikipedia or Mathworld for more information.

atanh

      atanh (x)

  Aliases: `arctanh`

  The arctanh (inverse tanh) function.

atan2

      atan2 (y, x)

  Aliases: `arctan2`

  Calculates the arctan2 function. If `x>0` then it returns `atan(y/x)`. If `x<0` then it returns `sign(y) * (pi - atan(|y/x|)`. When `x=0` it returns `sign(y) * pi/2`. `atan2(0,0)` returns 0 rather then failing.

  See Wikipedia or Mathworld for more information.

cos

      cos (x)

  Calculates the cosine function.

  See Planetmath for more information.

cosh

      cosh (x)

  Calculates the hyperbolic cosine function.

  See Planetmath for more information.

cot

      cot (x)

  The cotangent function.

  See Planetmath for more information.

coth

      coth (x)

  The hyperbolic cotangent function.

  See Planetmath for more information.

csc

      csc (x)

  The cosecant function.

  See Planetmath for more information.

csch

      csch (x)

  The hyperbolic cosecant function.

  See Planetmath for more information.

sec

      sec (x)

  The secant function.

  See Planetmath for more information.

sech

      sech (x)

  The hyperbolic secant function.

  See Planetmath for more information.

sin

      sin (x)

  Calculates the sine function.

  See Planetmath for more information.

sinh

      sinh (x)

  Calculates the hyperbolic sine function.

  See Planetmath for more information.

tan

      tan (x)

  Calculates the tan function.

  See Planetmath for more information.

tanh

      tanh (x)

  The hyperbolic tangent function.

  See Planetmath for more information.

# Number Theory

AreRelativelyPrime

      AreRelativelyPrime (a,b)

  Are the real integers `a` and `b` relatively prime? Returns `true` or `false`.

  See Planetmath or Mathworld for more information.

BernoulliNumber

      BernoulliNumber (n)

  Return the `n`th Bernoulli number.

  See Wikipedia or Mathworld for more information.

ChineseRemainder

      ChineseRemainder (a,m)

  Aliases: `CRT`

  Find the `x` that solves the system given by the vector `a` and modulo the elements of `m`, using the Chinese Remainder Theorem.

  See Wikipedia or Planetmath or Mathworld for more information.

CombineFactorizations

      CombineFactorizations (a,b)

  Given two factorizations, give the factorization of the product.

  See Factorize.

ConvertFromBase

      ConvertFromBase (v,b)

  Convert a vector of values indicating powers of b to a number.

ConvertToBase

      ConvertToBase (n,b)

  Convert a number to a vector of powers for elements in base `b`.

DiscreteLog

      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 algorithm.

  See Wikipedia or Planetmath or Mathworld for more information.

Divides

      Divides (m,n)

  Checks divisibility (if `m` divides `n`).

EulerPhi

      EulerPhi (n)

  Compute the Euler phi function for `n`, that is the number of integers between 1 and `n` relatively prime to `n`.

  See Wikipedia or Planetmath or Mathworld for more information.

ExactDivision

      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 numbers than the operation `n/d`, but of course only useful if you know that the division is exact.

Factorize

      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]

  See Wikipedia for more information.

Factors

      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 for example to print all the perfect numbers (those that are sums of their factors) up to the number 1000 you could do (this is of course very inefficient)

      for n=1 to 1000 do (
          if MatrixSum (Factors(n)) == 2*n then
              print(n)
      )

FermatFactorization

      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 number of tries before giving up.

  This is a fairly good factorization if your number is the product of two factors that are very close to each other.

  See Wikipedia for more information.

FindPrimitiveElementMod

      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)

  Find a random primitive element in Fq, the finite group of order `q` (q must be a prime).

IndexCalculus

      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 primes possibly with second column precalculated by `IndexCalculusPrecalculation`.

IndexCalculusPrecalculation

      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 base `S` (where `S` is a column vector of primes). The logs will be precalculated and returned in the second column.

IsEven

      IsEven (n)

  Tests if an integer is even.

IsMersennePrimeExponent

      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 known values which is relatively short. See also MersennePrimeExponents and LucasLehmer.

  See Wikipedia, Planetmath, Mathworld or GIMPS for more information.

IsNthPower

      IsNthPower (m,n)

  Tests if a rational number `m` is a perfect `n`th power. See also IsPerfectPower and IsPerfectSquare.

IsOdd

      IsOdd (n)

  Tests if an integer is odd.

IsPerfectPower

      IsPerfectPower (n)

  Check an integer is any perfect power, ab.

IsPerfectSquare

      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 never perfect squares of real integers.

IsPrime

      IsPrime (n)

  Tests primality of integers, for numbers less than 2.5e10 the answer is deterministic (if Riemann hypothesis is true). For numbers larger, the probability of a false positive depends on `IsPrimeMillerRabinReps`. That is the probability of false positive is 1/4 to the power `IsPrimeMillerRabinReps`. The default value of 22 yields a probability of about 5.7e-14.

  If `false` is returned, you can be sure that the number is a composite. If you want to be absolutely sure that you have a prime you can use `MillerRabinTestSure` but it may take a lot longer.

  See Planetmath or Mathworld for more information.

IsPrimitiveMod

      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)

  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 not prime results are bogus.

IsPseudoprime

      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)

  Test if `n` is a strong pseudoprime to base `b` but not a prime.

Jacobi

      Jacobi (a,b)

  Aliases: `JacobiSymbol`

  Calculate the Jacobi symbol (a/b) (b should be odd).

JacobiKronecker

      JacobiKronecker (a,b)

  Aliases: `JacobiKroneckerSymbol`

  Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2)=(2/a) when a odd, or (a/2)=0 when a even.

LeastAbsoluteResidue

      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)

  Aliases: `LegendreSymbol`

  Calculate the Legendre symbol (a/p).

  See Planetmath or Mathworld for more information.

LucasLehmer

      LucasLehmer (p)

  Test if 2p-1 is a Mersenne prime using the Lucas-Lehmer test. See also MersennePrimeExponents and IsMersennePrimeExponent.

  See Wikipedia or Planetmath or Mathworld for more information.

LucasNumber

      LucasNumber (n)

  Returns the `n`th Lucas number.

  See Wikipedia or Planetmath or Mathworld for more information.

MaximalPrimePowerFactors

      MaximalPrimePowerFactors (n)

  Return all maximal prime power factors of a number.

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 IsMersennePrimeExponent and LucasLehmer.

  See Wikipedia, Planetmath, Mathworld or GIMPS for more information.

MillerRabinTest

      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 usually better to use `IsPrime` since that is faster and better on smaller integers.

  See Wikipedia or Planetmath or Mathworld for more information.

MillerRabinTestSure

      MillerRabinTestSure (n)

  Use the Miller-Rabin primality test on `n` with enough bases that assuming the Generalized Reimann Hypothesis the result is deterministic.

  See Wikipedia or Planetmath or Mathworld for more information.

ModInvert

      ModInvert (n,m)

  Returns inverse of n mod m.

  See Mathworld for more information.

MoebiusMu

      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 product of `k` distinct primes.

  See Planetmath or Mathworld for more information.

NextPrime

      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 `-NextPrime(-n)`.

  This function uses the GMP's `mpz_nextprime` which in turn uses the probabilistic Miller-Rabin test (See also MillerRabinTest). The probability of false positive is not tunable, but is low enough for all practical purposes.

  See Planetmath or Mathworld for more information.

PadicValuation

      PadicValuation (n,p)

  Returns the p-adic valuation (number of trailing zeros in base `p`).

  See Planetmath for more information.

PowerMod

      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 modulo mode. Hence `a^b mod m` is just as fast.

Prime

      Prime (n)

  Aliases: `prime`

  Return the `n`th prime (up to a limit).

  See Planetmath or Mathworld for more information.

PrimeFactors

      PrimeFactors (n)

  Return all prime factors of a number as a vector.

  See Mathworld for more information.

PseudoprimeTest

      PseudoprimeTest (n,b)

  Pseudoprime test, returns `true` if and only if `b^(n-1) == 1 mod n`

  See Planetmath or Mathworld for more information.

RemoveFactor

      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`.

  See Planetmath or Mathworld for more information.

SilverPohligHellmanWithFactorization

      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 algorithm, given `f` being the factorization of `q`-1.

SqrtModPrime

      SqrtModPrime (n,p)

  Find square root of `n` modulo `p` (where `p` is a prime). Null is returned if not a quadratic residue.

  See Planetmath or Mathworld for more information.

StrongPseudoprimeTest

      StrongPseudoprimeTest (n,b)

  Run the strong pseudoprime test base `b` on `n`.

  See Planetmath or Mathworld for more information.

gcd

      gcd (a,args...)

  Aliases: `GCD`

  Greatest common divisor of integers. You can enter as many integers in the argument list, or you can give a vector or a matrix of integers. If you give more than one matrix of the same size then GCD is done element by element.

  See Planetmath or Mathworld for more information.

lcm

      lcm (a,args...)

  Aliases: `LCM`

  Least common multiplier of integers. You can enter as many integers in the argument list, or you can give a vector or a matrix of integers. If you give more than one matrix of the same size then LCM is done element by element.

  See Planetmath or Mathworld for more information.

# Matrix Manipulation

ApplyOverMatrix

      ApplyOverMatrix (a,func)

  Apply a function over all entries of a matrix and return a matrix of the results.

ApplyOverMatrix2

      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)

  Gets the columns of a matrix as a horizontal vector.

ComplementSubmatrix

      ComplementSubmatrix (m,r,c)

  Remove column(s) and row(s) from a matrix.

CompoundMatrix

      CompoundMatrix (k,A)

  Calculate the kth compound matrix of A.

CountZeroColumns

      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 `cref` and `Nullity`.

DeleteColumn

      DeleteColumn (M,col)

  Delete a column of a matrix.

DeleteRow

      DeleteRow (M,row)

  Delete a row of a matrix.

DiagonalOf

      DiagonalOf (M)

  Gets the diagonal entries of a matrix as a column vector.

  See Wikipedia for more information.

DotProduct

      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 if working over the complex numbers.

  See Planetmath for more information.

ExpandMatrix

      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 construct matrices out of smaller ones and this is normally done automatically on input unless the matrix is quoted.

HermitianProduct

      HermitianProduct (u,v)

  Aliases: `InnerProduct`

  Get the Hermitian product of two vectors. The vectors must be of the same size. This is a sesquilinear form using the identity matrix.

  See Mathworld for more information.

I

      I (n)

  Aliases: `eye`

  Return an identity matrix of a given size, that is `n` by `n`. If `n` is zero, returns `null`.

  See Planetmath for more information.

IndexComplement

      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 `[1,4,5]`. If `msize` is 0, we always return `null`.

IsDiagonal

      IsDiagonal (M)

  Is a matrix diagonal.

  See Wikipedia or Planetmath for more information.

IsIdentity

      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 case it is equivalent to `x==1`. When `x` is `null` (we could think of that as a 0 by 0 matrix), no error is generated and `false` is returned.

IsLowerTriangular

      IsLowerTriangular (M)

  Is a matrix lower triangular. That is, are all the entries above the diagonal zero.

IsMatrixInteger

      IsMatrixInteger (M)

  Check if a matrix is a matrix of an integers (non-complex).

IsMatrixNonnegative

      IsMatrixNonnegative (M)

  Check if a matrix is non-negative, that is if each element is non-negative. Do not confuse positive matrices with positive semi-definite matrices.

  See Wikipedia for more information.

IsMatrixPositive

      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 positive matrices with positive definite matrices.

  See Wikipedia for more information.

IsMatrixRational

      IsMatrixRational (M)

  Check if a matrix is a matrix of rational (non-complex) numbers.

IsMatrixReal

      IsMatrixReal (M)

  Check if a matrix is a matrix of real (non-complex) numbers.

IsMatrixSquare

      IsMatrixSquare (M)

  Check if a matrix is square, that is its width is equal to its height.

IsUpperTriangular

      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)

  Check if a matrix is a matrix of numbers only. Many internal functions make this check. Values can be any number including complex numbers.

IsVector

      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 by `n` or `n` by 1 matrix.

IsZero

      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 think of that as a 0 by 0 matrix), no error is generated and `true` is returned as the condition is vacuous.

LowerTriangular

      LowerTriangular (M)

  Returns a copy of the matrix `M` with all the entries above the diagonal set to zero.

MakeDiagonal

      MakeDiagonal (v,arg...)

  Aliases: `diag`

  Make diagonal matrix from a vector.

  See Wikipedia or Planetmath for more information.

MakeVector

      MakeVector (A)

  Make column vector out of matrix by putting columns above each other. Returns `null` when given `null`.

MatrixProduct

      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 product of all the elements.

MatrixSum

      MatrixSum (A)

  Calculate the sum of all elements in a matrix or vector. That is we add all the elements and return a number that is the sum of all the elements.

MatrixSumSquares

      MatrixSumSquares (A)

  Calculate the sum of squares of all elements in a matrix or vector.

OuterProduct

      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)

  Reverse elements in a vector. Return `null` if given `null`

RowSum

      RowSum (m)

  Calculate sum of each row in a matrix and return a vertical vector with the result.

RowSumSquares

      RowSumSquares (m)

  Calculate sum of squares of each row in a matrix.

RowsOf

      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 of `M`. This function is useful if you wish to loop over the rows of a matrix. For example, as `for r in RowsOf(M) do something(r)`.

SetMatrixSize

      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 don't fit are clipped and extra space is filled with zeros. if `rows` or `columns` are zero then `null` is returned.

ShuffleVector

      ShuffleVector (v)

  Shuffle elements in a vector. Return `null` if given `null`

SortVector

      SortVector (v)

  Sort vector elements in an increasing order.

StripZeroColumns

      StripZeroColumns (M)

  Removes any all-zero columns of `M`.

StripZeroRows

      StripZeroRows (M)

  Removes any all-zero rows of `M`.

Submatrix

      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 single numbers if only one row or column is needed).

SwapRows

      SwapRows (m,row1,row2)

  Swap two rows in a matrix.

UpperTriangular

      UpperTriangular (M)

  Returns a copy of the matrix `M` with all the entries below the diagonal set to zero.

columns

      columns (M)

  Get the number of columns of a matrix.

elements

      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...)

  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)

  Get the number of rows of a matrix.

zeros

      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.

# Linear Algebra

AuxiliaryUnitMatrix

      AuxiliaryUnitMatrix (n)

  Get the auxiliary unit matrix of size `n`. This is a square matrix matrix with that is all zero except the superdiagonal being all ones. It is the Jordan block matrix of one zero eigenvalue.

  See Planetmath or Mathworld for more information on Jordan Cannonical Form.

BilinearForm

      BilinearForm (v,A,w)

  Evaluate (v,w) with respect to the bilinear form given by the matrix A.

BilinearFormFunction

      BilinearFormFunction (A)

  Return a function that evaluates two vectors with respect to the bilinear form given by A.

CharacteristicPolynomial

      CharacteristicPolynomial (M)

  Aliases: `CharPoly`

  Get the characteristic polynomial as a vector. That is, return the coefficients of the polynomial starting with the constant term. This is the polynomial defined by `det(M-xI)`. The roots of this polynomial are the eigenvalues of `M`. See also CharacteristicPolynomialFunction.

  See Planetmath for more information.

CharacteristicPolynomialFunction

      CharacteristicPolynomialFunction (M)

  Get the characteristic polynomial as a function. This is the polynomial defined by `det(M-xI)`. The roots of this polynomial are the eigenvalues of `M`. See also CharacteristicPolynomial.

  See Planetmath for more information.

ColumnSpace

      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 of `M`. That is the space spanned by the columns of `M`.

CommutationMatrix

      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 all m by n matrices A.

CompanionMatrix

      CompanionMatrix (p)

  Companion matrix of a polynomial (as vector).

ConjugateTranspose

      ConjugateTranspose (M)

  Conjugate transpose of a matrix (adjoint). This is the same as the `'` operator.

  See Planetmath for more information.

Convolution

      Convolution (a,b)

  Aliases: `convol`

  Calculate convolution of two horizontal vectors.

ConvolutionVector

      ConvolutionVector (a,b)

  Calculate convolution of two horizontal vectors. Return result as a vector and not added together.

CrossProduct

      CrossProduct (v,w)

  CrossProduct of two vectors in R3 as a column vector.

DeterminantalDivisorsInteger

      DeterminantalDivisorsInteger (M)

  Get the determinantal divisors of an integer matrix (not its characteristic).

DirectSum

      DirectSum (M,N...)

  Direct sum of matrices.

DirectSumMatrixVector

      DirectSumMatrixVector (v)

  Direct sum of a vector of matrices.

Eigenvalues

      Eigenvalues (M)

  Aliases: `eig`

  Get the eigenvalues of a square matrix. Currently only works for matrices of size up to 4 by 4, or for triangular matrices (for which the eigenvalues are on the diagonal).

  See Wikipedia or Planetmath or Mathworld for more information.

Eigenvectors

      Eigenvectors (M)

      Eigenvectors (M, &eigenvalues)

      Eigenvectors (M, &eigenvalues, &multiplicities)

  Get the eigenvectors of a square matrix. Optionally get also the eigenvalues and their algebraic multiplicities. Currently only works for matrices of size up to 2 by 2.

  See Wikipedia or Planetmath or Mathworld for more information.

GramSchmidt

      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 Hermitian product is used. `B` can either be a sesquilinear function of two arguments or it can be a matrix giving a sesquilinear form. The vectors will be made orthonormal with respect to `B`.

  See Planetmath for more information.

HankelMatrix

      HankelMatrix (c,r)

  Hankel matrix.

HilbertMatrix

      HilbertMatrix (n)

  Hilbert matrix of order `n`.

  See Planetmath for more information.

Image

      Image (T)

  Get the image (columnspace) of a linear transform.

InfNorm

      InfNorm (v)

  Get the Inf Norm of a vector, sometimes called the sup norm or the max norm.

InvariantFactorsInteger

      InvariantFactorsInteger (M)

  Get the invariant factors of a square integer matrix (not its characteristic).

InverseHilbertMatrix

      InverseHilbertMatrix (n)

  Inverse Hilbert matrix of order `n`.

  See Planetmath for more information.

IsHermitian

      IsHermitian (M)

  Is a matrix Hermitian. That is, is it equal to its conjugate transpose.

  See Planetmath for more information.

IsInSubspace

      IsInSubspace (v,W)

  Test if a vector is in a subspace.

IsInvertible

      IsInvertible (n)

  Is a matrix (or number) invertible (Integer matrix is invertible iff it's invertible over the integers).

IsInvertibleField

      IsInvertibleField (n)

  Is a matrix (or number) invertible over a field.

IsNormal

      IsNormal (M)

  Is `M` a normal matrix. That is, does `M*M' == M'*M`.

  See Planetmath or Mathworld for more information.

IsPositiveDefinite

      IsPositiveDefinite (M)

  Is `M` a Hermitian positive definite matrix. That is if `HermitianProduct(M*v,v)` is always strictly positive for any vector `v`. `M` must be square and Hermitian to be positive definite. The check that is performed is that every principal submatrix has a non-negative determinant. (See HermitianProduct)

  Note that some authors (for example Mathworld) do not require that `M` be Hermitian, and then the condition is on the real part of the inner product, but we do not take this view. If you wish to perform this check, just check the Hermitian part of the matrix `M` as follows: `IsPositiveDefinite(M+M')`.

  See Planetmath or Mathworld for more information.

IsPositiveSemidefinite

      IsPositiveSemidefinite (M)

  Is `M` a Hermitian positive semidefinite matrix. That is if `HermitianProduct(M*v,v)` is always non-negative for any vector `v`. `M` must be square and Hermitian to be positive semidefinite. The check that is performed is that every principal submatrix has a non-negative determinant. (See HermitianProduct)

  Note that some authors do not require that `M` be Hermitian, and then the condition is on the real part of the inner product, but we do not take this view. If you wish to perform this check, just check the Hermitian part of the matrix `M` as follows: `IsPositiveSemidefinite(M+M')`.

  See Planetmath or Mathworld for more information.

IsSkewHermitian

      IsSkewHermitian (M)

  Is a matrix skew-Hermitian. That is, is the conjugate transpose equal to negative of the matrix.

  See Planetmath for more information.

IsUnitary

      IsUnitary (M)

  Is a matrix unitary? That is, does `M'*M` and `M*M'` equal the identity.

  See Planetmath or Mathworld for more information.

JordanBlock

      JordanBlock (n,lambda)

  Aliases: `J`

  Get the Jordan block corresponding to the eigenvalue `lambda` with multiplicity `n`.

  See Planetmath or Mathworld for more information.

Kernel

      Kernel (T)

  Get the kernel (nullspace) of a linear transform.

  (See NullSpace)

LUDecomposition

      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)

  You will have the lower matrix stored in a variable called `L` and the upper matrix in a variable called `U`.

  This is the LU decomposition of a matrix aka Crout and/or Cholesky reduction. (ISBN 0-201-11577-8 pp.99-103) The upper triangular matrix features a diagonal of values 1 (one). This is not Doolittle's Method which features the 1's diagonal on the lower matrix.

  Not all matrices have LU decompositions, for example `[0,1;1,0]` does not and this function returns `false` in this case and sets `L` and `U` to `null`.

  See Planetmath or Mathworld for more information.

Minor

      Minor (M,i,j)

  Get the `i`-`j` minor of a matrix.

  See Planetmath for more information.

NonPivotColumns

      NonPivotColumns (M)

  Return the columns that are not the pivot columns of a matrix.

Norm

      Norm (v,p...)

  Aliases: `norm`

  Get the p Norm (or 2 Norm if no p is supplied) of a vector.

NullSpace

      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 whose column space is the nullspace of `T`.

  See Planetmath for more information.

Nullity

      Nullity (M)

  Aliases: `nullity`

  Get the nullity of a matrix. That is, return the dimension of the nullspace; the dimension of the kernel of `M`.

  See Planetmath for more information.

OrthogonalComplement

      OrthogonalComplement (M)

  Get the orthogonal complement of the columnspace.

PivotColumns

      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 occur.

Projection

      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 product is used. `B` can either be a sesquilinear function of two arguments or it can be a matrix giving a sesquilinear form.

QRDecomposition

      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)

  You will have the upper triangular matrix stored in a variable called `R` and the orthogonal (unitary) matrix stored in `Q`.

  See Planetmath or Mathworld for more information.

RayleighQuotient

      RayleighQuotient (A,x)

  Return the Rayleigh quotient (also called the Rayleigh-Ritz quotient or ratio) of a matrix and a vector.

  See Planetmath for more information.

RayleighQuotientIteration

      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 should have nonzero imaginary part if it will have any chance at finding complex eigenvalues. The code will run at most `maxiter` iterations and return `null` if we cannot get within an error of `epsilon`. `vecref` should either be `null` or a reference to a variable where the eigenvector should be stored.

  See Planetmath for more information on Rayleigh quotient.

Rank

      Rank (M)

  Aliases: `rank`

  Get the rank of a matrix.

  See Planetmath for more information.

RosserMatrix

      RosserMatrix ()

  Rosser matrix, a classic symmetric eigenvalue test problem.

Rotation2D

      Rotation2D (angle)

  Aliases: `RotationMatrix`

  Return the matrix corresponding to rotation around origin in R2.

Rotation3DX

      Rotation3DX (angle)

  Return the matrix corresponding to rotation around origin in R3 about the x-axis.

Rotation3DY

      Rotation3DY (angle)

  Return the matrix corresponding to rotation around origin in R3 about the y-axis.

Rotation3DZ

      Rotation3DZ (angle)

  Return the matrix corresponding to rotation around origin in R3 about the z-axis.

RowSpace

      RowSpace (M)

  Get a basis matrix for the rowspace of a matrix.

SesquilinearForm

      SesquilinearForm (v,A,w)

  Evaluate (v,w) with respect to the sesquilinear form given by the matrix A.

SesquilinearFormFunction

      SesquilinearFormFunction (A)

  Return a function that evaluates two vectors with respect to the sesquilinear form given by A.

SmithNormalFormField

      SmithNormalFormField (A)

  Smith Normal Form for fields (will end up with 1's on the diagonal).

SmithNormalFormInteger

      SmithNormalFormInteger (M)

  Smith Normal Form for square integer matrices (not its characteristic).

SolveLinearSystem

      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 optionally be used to get the reduced M and V.

ToeplitzMatrix

      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 then it is conjugated and the nonconjugated version is used for the first row to give a Hermitian matrix (if the first element is real of course).

  See Planetmath for more information.

Trace

      Trace (M)

  Aliases: `trace`

  Calculate the trace of a matrix. That is the sum of the diagonal elements.

  See Planetmath for more information.

Transpose

      Transpose (M)

  Transpose of a matrix. This is the same as the `.'` operator.

  See Planetmath for more information.

VandermondeMatrix

      VandermondeMatrix (v)

  Aliases: `vander`

  Return the Vandermonde matrix.

VectorAngle

      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` can either be a sesquilinear function of two arguments or it can be a matrix giving a sesquilinear form.

VectorSpaceDirectSum

      VectorSpaceDirectSum (M,N)

  The direct sum of the vector spaces M and N.

VectorSubspaceIntersection

      VectorSubspaceIntersection (M,N)

  Intersection of the subspaces given by M and N.

VectorSubspaceSum

      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)

  Aliases: `Adjugate`

  Get the classical adjoint (adjugate) of a matrix.

cref

      cref (M)

  Aliases: `CREF` `ColumnReducedEchelonForm`

  Compute the Column Reduced Echelon Form.

det

      det (M)

  Aliases: `Determinant`

  Get the determinant of a matrix.

  See Wikipedia or Planetmath for more information.

ref

      ref (M)

  Aliases: `REF` `RowEchelonForm`

  Get the row echelon form of a matrix. That is, apply gaussian elimination but not backaddition to `M`. The pivot rows are divided to make all pivots 1.

  See Wikipedia or Planetmath for more information.

rref

      rref (M)

  Aliases: `RREF` `ReducedRowEchelonForm`

  Get the reduced row echelon form of a matrix. That is, apply gaussian elimination together with backaddition to `M`.

  See Wikipedia or Planetmath for more information.

# Combinatorics

Catalan

      Catalan (n)

  Get `n`'th catalan number.

  See Planetmath for more information.

Combinations

      Combinations (k,n)

  Get all combinations of k numbers from 1 to n as a vector of vectors. (See also NextCombination)

DoubleFactorial

      DoubleFactorial (n)

  Double factorial: `n(n-2)(n-4)...`

  See Planetmath for more information.

Factorial

      Factorial (n)

  Factorial: `n(n-1)(n-2)...`

  See Planetmath for more information.

FallingFactorial

      FallingFactorial (n,k)

  Falling factorial: `(n)_k = n(n-1)...(n-(k-1))`

  See Planetmath for more information.

Fibonacci

      Fibonacci (x)

  Aliases: `fib`

  Calculate `n`th Fibonacci number. That is the number defined recursively by `Fibonacci(n) = Fibonacci(n-1) + Fibonacci(n-2)` and `Fibonacci(1) = Fibonacci(2) = 1`.

  See Wikipedia or Planetmath or Mathworld for more information.

FrobeniusNumber

      FrobeniusNumber (v,arg...)

  Calculate the Frobenius number. That is calculate smallest number that cannot be given as a non-negative integer linear combination of a given vector of non-negative integers. The vector can be given as separate numbers or a single vector. All the numbers given should have GCD of 1.

  See Mathworld for more information.

GaloisMatrix

      GaloisMatrix (combining_rule)

  Galois matrix given a linear combining rule (a_1*x_+...+a_n*x_n=x_(n+1)).

GreedyAlgorithm

      FrobeniusNumber (n,v)

  Find the vector `c` of non-negative integers such that taking the dot product with `v` is equal to n. If not possible returns `null`. `v` should be given sorted in increasing order and should consist of non-negative integers.

  See Mathworld for more information.

HarmonicNumber

      HarmonicNumber (n,r)

  Aliases: `HarmonicH`

  Harmonic Number, the `n`'th harmonic number of order `r`.

Hofstadter

      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)

  Compute linear recursive sequence using galois stepping.

Multinomial

      Multinomial (v,arg...)

  Calculate multinomial coefficients. Takes a vector of `k` non-negative integers and computes the multinomial coefficient. This corresponds to the coefficient in the homogeneous polynomial in `k` variables with the corresponding powers.

  The formula for `Multinomial(a,b,c)` can be written as:

      (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 `Binomial(a+b,b)`.

  See Planetmath, Mathworld, or Wikipedia for more information.

NextCombination

      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 have many combinations to go through and you don't want to waste memory to store them all.

  For example with Combination you would normally write a loop like:

      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));

  See also Combinations.
Pascal

      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` iterations.

  See Planetmath for more information.

Permutations

      Permutations (k,n)

  Get all permutations of `k` numbers from 1 to `n` as a vector of vectors.

  See Mathworld or Wikipedia for more information.

RisingFactorial

      RisingFactorial (n,k)

  Aliases: `Pochhammer`

  (Pochhammer) Rising factorial: (n)_k = n(n+1)...(n+(k-1)).

  See Planetmath for more information.

StirlingNumberFirst

      StirlingNumberFirst (n,m)

  Aliases: `StirlingS1`

  Stirling number of the first kind.

  See Planetmath or Mathworld for more information.

StirlingNumberSecond

      StirlingNumberSecond (n,m)

  Aliases: `StirlingS2`

  Stirling number of the second kind.

  See Planetmath or Mathworld for more information.

Subfactorial

      Subfactorial (n)

  Subfactorial: n! times sum_{k=1}^n (-1)^k/k!.

Triangular

      Triangular (nth)

  Calculate the `n`'th triangular number.

  See Planetmath for more information.

nCr

      nCr (n,r)

  Aliases: `Binomial`

  Calculate combinations, that is, the binomial coefficient. `n` can be any real number.

  See Planetmath for more information.

nPr

      nPr (n,r)

  Calculate the number of permutations of size `r`of numbers from 1 to `n`.

  See Mathworld or Wikipedia for more information.

# Calculus

CompositeSimpsonsRule

      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 that n should be even.

  See Planetmath for more information.

CompositeSimpsonsRuleTolerance

      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 and the desired tolerance.

  See Planetmath for more information.

Derivative

      Derivative (f,x0)

  Attempt to calculate derivative by trying first symbolically and then numerically.

EvenPeriodicExtension

      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]` extended to be even on `[-L,L]` and then extended to be periodic with period `2*L`.

  See also OddPeriodicExtension and PeriodicExtension.

FourierSeriesFunction

      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 the constant coefficient! That is, `a@(n)` refers to the term `cos(x*(n-1)*pi/L)`, while `b@(n)` refers to the term `sin(x*n*pi/L)`. Either `a` or `b` can be `null`.

  See Wikipedia or Mathworld for more information.

InfiniteProduct

      InfiniteProduct (func,start,inc)

  Try to calculate an infinite product for a single parameter function.

InfiniteProduct2

      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)

  Try to calculate an infinite sum for a single parameter function.

InfiniteSum2

      InfiniteSum2 (func,arg,start,inc)

  Try to calculate an infinite sum for a double parameter function with func(arg,n).

IsContinuous

      IsContinuous (f,x0)

  Try and see if a real-valued function is continuous at x0 by calculating the limit there.

IsDifferentiable

      IsDifferentiable (f,x0)

  Test for differentiability by approximating the left and right limits and comparing.

LeftLimit

      LeftLimit (f,x0)

  Calculate the left limit of a real-valued function at x0.

Limit

      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)

  Integration by midpoint rule.

NumericalDerivative

      NumericalDerivative (f,x0)

  Aliases: `NDerivative`

  Attempt to calculate numerical derivative.

NumericalFourierSeriesCoefficients

      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 of `f` with half-period `L` (that is defined on `[-L,L]` and extended periodically) with coefficients up to `N`th harmonic computed numerically. The coefficients are computed by numerical integration using `NumericalIntegral`.

  See Wikipedia or Mathworld for more information.

NumericalFourierSeriesFunction

      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 periodically) with coefficients up to `N`th harmonic computed numerically. This is the trigonometric real series composed of sines and cosines. The coefficients are computed by numerical integration using `NumericalIntegral`.

  See Wikipedia or Mathworld for more information.

NumericalFourierCosineSeriesCoefficients

      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 the even periodic extension and compute the Fourier series, which only has cosine terms. The series is computed up to the `N`th harmonic. The coefficients are computed by numerical integration using `NumericalIntegral`. Note that `a@(1)` is the constant coefficient! That is, `a@(n)` refers to the term `cos(x*(n-1)*pi/L)`.

  See Wikipedia or Mathworld for more information.

NumericalFourierCosineSeriesFunction

      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 periodic extension and compute the Fourier series, which only has cosine terms. The series is computed up to the `N`th harmonic. The coefficients are computed by numerical integration using `NumericalIntegral`.

  See Wikipedia or Mathworld for more information.

NumericalFourierSineSeriesCoefficients

      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 odd periodic extension and compute the Fourier series, which only has sine terms. The series is computed up to the `N`th harmonic. The coefficients are computed by numerical integration using `NumericalIntegral`.

  See Wikipedia or Mathworld for more information.

NumericalFourierSineSeriesFunction

      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 periodic extension and compute the Fourier series, which only has sine terms. The series is computed up to the `N`th harmonic. The coefficients are computed by numerical integration using `NumericalIntegral`.

  See Wikipedia or Mathworld for more information.

NumericalIntegral

      NumericalIntegral (f,a,b)

  Integration by rule set in NumericalIntegralFunction of f from a to b using NumericalIntegralSteps steps.

NumericalLeftDerivative

      NumericalLeftDerivative (f,x0)

  Attempt to calculate numerical left derivative.

NumericalLimitAtInfinity

      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)

  Attempt to calculate numerical right derivative.

OddPeriodicExtension

      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]` extended to be odd on `[-L,L]` and then extended to be periodic with period `2*L`.

  See also EvenPeriodicExtension and PeriodicExtension.

OneSidedFivePointFormula

      OneSidedFivePointFormula (f,x0,h)

  Compute one-sided derivative using five point formula.

OneSidedThreePointFormula

      OneSidedThreePointFormula (f,x0,h)

  Compute one-sided derivative using three-point formula.

PeriodicExtension

      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`.

  See also OddPeriodicExtension and EvenPeriodicExtension.

RightLimit

      RightLimit (f,x0)

  Calculate the right limit of a real-valued function at x0.

TwoSidedFivePointFormula

      TwoSidedFivePointFormula (f,x0,h)

  Compute two-sided derivative using five-point formula.

TwoSidedThreePointFormula

      TwoSidedThreePointFormula (f,x0,h)

  Compute two-sided derivative using three-point formula.

# Functions

Argument

      Argument (z)

  Aliases: `Arg` `arg`

  argument (angle) of complex number.

DirichletKernel

      DirichletKernel (n,t)

  Dirichlet kernel of order n.

DiscreteDelta

      DiscreteDelta (v)

  Returns 1 iff all elements are zero.

ErrorFunction

      ErrorFunction (x)

  Aliases: `erf`

  The error function, 2/sqrt(pi) * int_0^x e^(-t^2) dt.

  See Planetmath for more information.

FejerKernel

      FejerKernel (n,t)

  Fejer kernel of order `n` evaluated at `t`

  See Planetmath for more information.

GammaFunction

      GammaFunction (x)

  Aliases: `Gamma`

  The Gamma function. Currently only implemented for real values.

  See Planetmath for more information.

KroneckerDelta

      KroneckerDelta (v)

  Returns 1 iff all elements are equal.

MinimizeFunction

      MinimizeFunction (func,x,incr)

  Find the first value where f(x)=0.

MoebiusDiskMapping

      MoebiusDiskMapping (a,z)

  Moebius mapping of the disk to itself mapping a to 0.

  See Planetmath for more information.

MoebiusMapping

      MoebiusMapping (z,z2,z3,z4)

  Moebius mapping using the cross ratio taking z2,z3,z4 to 1,0, and infinity respectively.

  See Planetmath for more information.

MoebiusMappingInftyToInfty

      MoebiusMappingInftyToInfty (z,z2,z3)

  Moebius mapping using the cross ratio taking infinity to infinity and z2,z3 to 1 and 0 respectively.

  See Planetmath for more information.

MoebiusMappingInftyToOne

      MoebiusMappingInftyToOne (z,z3,z4)

  Moebius mapping using the cross ratio taking infinity to 1 and z3,z4 to 0 and infinity respectively.

  See Planetmath for more information.

MoebiusMappingInftyToZero

      MoebiusMappingInftyToZero (z,z2,z4)

  Moebius mapping using the cross ratio taking infinity to 0 and z2,z4 to 1 and infinity respectively.

  See Planetmath for more information.

PoissonKernel

      PoissonKernel (r,sigma)

  Poisson kernel on D(0,1) (not normalized to 1, that is integral of this is 2pi).

PoissonKernelRadius

      PoissonKernelRadius (r,sigma)

  Poisson kernel on D(0,R) (not normalized to 1).

RiemannZeta

      RiemannZeta (x)

  Aliases: `zeta`

  The Riemann zeta function. Currently only implemented for real values.

  See Planetmath for more information.

UnitStep

      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 function.

  See Wikipedia for more information.

cis

      cis (x)

  The `cis` function, that is the same as `cos(x)+1i*sin(x)`

deg2rad

      deg2rad (x)

  Convert degrees to radians.

rad2deg

      rad2deg (x)

  Convert radians to degrees.

# Equation Solving

CubicFormula

      CubicFormula (p)

  Compute roots of a cubic (degree 3) polynomial using the cubic formula. The polynomial should be given as a vector of coefficients. That is `4*x^3 + 2*x + 1` corresponds to the vector `[1,2,0,4]`. Returns a column vector of the three solutions. The first solution is always the real one as a cubic always has one real solution.

  See Planetmath, Mathworld, or Wikipedia for more information.

EulersMethod

      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`.

  Systems can be solved by just having `y` be a (column) vector everywhere. That is, `y0` can be a vector in which case `f` should take a number `x` and a vector of the same size for the second argument and should return a vector of the same size.

  See Mathworld, or Wikipedia for more information.

EulersMethodFull

      EulersMethodFull (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 a 2 by `n+1` matrix with the `x` and `y` values. Suitable for plugging into LinePlotDrawLine.

  Systems can be solved by just having `y` be a (column) vector everywhere. That is, `y0` can be a vector in which case `f` should take a number `x` and a vector of the same size for the second argument and should return a vector of the same size.

  See Mathworld, or Wikipedia for more information.

FindRootBisection

      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 to run, 0 means no limit. The function returns a vector `[success,value,iteration]`, where `success` is a boolean indicating success, `value` is the last value computed, and `iteration` is the number of iterations done.

FindRootFalsePosition

      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 iterations to run, 0 means no limit. The function returns a vector `[success,value,iteration]`, where `success` is a boolean indicating success, `value` is the last value computed, and `iteration` is the number of iterations done.

FindRootMullersMethod

      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 to run, 0 means no limit. The function returns a vector `[success,value,iteration]`, where `success` is a boolean indicating success, `value` is the last value computed, and `iteration` is the number of iterations done.

FindRootSecant

      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 to run, 0 means no limit. The function returns a vector `[success,value,iteration]`, where `success` is a boolean indicating success, `value` is the last value computed, and `iteration` is the number of iterations done.

PolynomialRoots

      PolynomialRoots (p)

  Compute roots of a polynomial (degrees 1 through 4) using one of the formulas for such polynomials. The polynomial should be given as a vector of coefficients. That is `4*x^3 + 2*x + 1` corresponds to the vector `[1,2,0,4]`. Returns a column vector of the solutions.

  The function calls QuadraticFormula, CubicFormula, and QuarticFormula.

QuadraticFormula

      QuadraticFormula (p)

  Compute roots of a quadratic (degree 2) polynomial using the quadratic formula. The polynomial should be given as a vector of coefficients. That is `3*x^2 + 2*x + 1` corresponds to the vector `[1,2,3]`. Returns a column vector of the two solutions.

  See Planetmath or Mathworld for more information.

QuarticFormula

      QuarticFormula (p)

  Compute roots of a quartic (degree 4) polynomial using the quartic formula. The polynomial should be given as a vector of coefficients. That is `5*x^4 + 2*x + 1` corresponds to the vector `[1,2,0,0,5]`. Returns a column vector of the four solutions.

  See Planetmath, Mathworld, or Wikipedia for more information.

RungeKutta

      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` increments, returns `y` at `x1`.

  Systems can be solved by just having `y` be a (column) vector everywhere. That is, `y0` can be a vector in which case `f` should take a number `x` and a vector of the same size for the second argument and should return a vector of the same size.

  See Mathworld, or Wikipedia for more information.

RungeKuttaFull

      RungeKuttaFull (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` increments, returns a 2 by `n+1` matrix with the `x` and `y` values. Suitable for plugging into LinePlotDrawLine.

  Systems can be solved by just having `y` be a (column) vector everywhere. That is, `y0` can be a vector in which case `f` should take a number `x` and a vector of the same size for the second argument and should return a vector of the same size.

  See Mathworld, or Wikipedia for more information.

# Statistics

Average

      Average (m)

  Aliases: `average` `Mean` `mean`

  Calculate average of an entire matrix.

  See Mathworld for more information.

GaussDistribution

      GaussDistribution (x,sigma)

  Integral of the GaussFunction from 0 to `x` (area under the normal curve).

  See Mathworld for more information.

GaussFunction

      GaussFunction (x,sigma)

  The normalized Gauss distribution function (the normal curve).

  See Mathworld for more information.

Median

      Median (m)

  Aliases: `median`

  Calculate median of an entire matrix.

  See Mathworld for more information.

PopulationStandardDeviation

      PopulationStandardDeviation (m)

  Aliases: `stdevp`

  Calculate the population standard deviation of a whole matrix.

RowAverage

      RowAverage (m)

  Aliases: `RowMean`

  Calculate average of each row in a matrix.

  See Mathworld for more information.

RowMedian

      RowMedian (m)

  Calculate median of each row in a matrix and return a column vector of the medians.

  See Mathworld for more information.

RowPopulationStandardDeviation

      RowPopulationStandardDeviation (m)

  Aliases: `rowstdevp`

  Calculate the population standard deviations of rows of a matrix and return a vertical vector.

RowStandardDeviation

      RowStandardDeviation (m)

  Aliases: `rowstdev`

  Calculate the standard deviations of rows of a matrix and return a vertical vector.

StandardDeviation

      StandardDeviation (m)

  Aliases: `stdev`

  Calculate the standard deviation of a whole matrix.

# Polynomials

AddPoly

      AddPoly (p1,p2)

  Add two polynomials (vectors).

DividePoly

      DividePoly (p,q,&r)

  Divide two polynomials (as vectors) using long division. Returns the quotient of the two polynomials. The optional argument `r` is used to return the remainder. The remainder will have lower degree than `q`.

  See Planetmath for more information.

IsPoly

      IsPoly (p)

  Check if a vector is usable as a polynomial.

MultiplyPoly

      MultiplyPoly (p1,p2)

  Multiply two polynomials (as vectors).

NewtonsMethodPoly

      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 maxn tries (then returns `null`).

Poly2ndDerivative

      Poly2ndDerivative (p)

  Take second polynomial (as vector) derivative.

PolyDerivative

      PolyDerivative (p)

  Take polynomial (as vector) derivative.

PolyToFunction

      PolyToFunction (p)

  Make function out of a polynomial (as vector).

PolyToString

      PolyToString (p,var...)

  Make string out of a polynomial (as vector).

SubtractPoly

      SubtractPoly (p1,p2)

  Subtract two polynomials (as vectors).

TrimPoly

      TrimPoly (p)

  Trim zeros from a polynomial (as vector).

# Set Theory

Intersection

      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)

  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)

  Returns `true` if X is a subset of Y (X and Y are vectors pretending to be sets).

MakeSet

      MakeSet (X)

  Returns a vector where every element of X appears only once.

SetMinus

      SetMinus (X,Y)

  Returns a set theoretic difference X-Y (X and Y are vectors pretending to be sets).

Union

      Union (X,Y)

  Returns a set theoretic union of X and Y (X and Y are vectors pretending to be sets).

# Miscellaneous

ASCIIToString

      ASCIIToString (vec)

  Convert a vector of ASCII values to a string.

AlphabetToString

      AlphabetToString (vec,alphabet)

  Convert a vector of 0-based alphabet values (positions in the alphabet string) to a string.

StringToASCII

      StringToASCII (str)

  Convert a string to a vector of ASCII values.

StringToAlphabet

      StringToAlphabet (str,alphabet)

  Convert a string to a vector of 0-based alphabet values (positions in the alphabet string), -1's for unknown letters.

# Symbolic Operations

SymbolicDerivative

      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)))

SymbolicDerivativeTry

      SymbolicDerivativeTry (f)

  Attempt to symbolically differentiate the function f, where f is a function of one variable, returns `null` if unsuccessful but is silent. (See `SymbolicDerivative`)

SymbolicNthDerivative

      SymbolicNthDerivative (f,n)

  Attempt to symbolically differentiate a function n times. (See `SymbolicDerivative`)

SymbolicNthDerivativeTry

      SymbolicNthDerivativeTry (f,n)

  Attempt to symbolically differentiate a function n times quietly and return `null` on failure (See `SymbolicNthDerivative`)

SymbolicTaylorApproximationFunction

      SymbolicTaylorApproximationFunction (f,x0,n)

  Attempt to construct the taylor approximation function around x0 to the nth degree. (See `SymbolicDerivative`)

# Plotting

LinePlot

      LinePlot (func1,func2,func3,...)

      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 limits of the plotting window as `x1`, `x2`, `y1`, `y2`. If limits are not specified, then the currently set limits apply (See `LinePlotWindow`)

  The parameter `LinePlotDrawLegends` controls the drawing of the legend.

  Examples:

      genius> LinePlot(sin,cos)
      genius> LinePlot(`(x)=x^2,-1,1,0,1)

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 (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.

  Extra parameters can be added to specify line color, thickness, arrows, and the plotting window. You can do this by adding a string `"color"`, `"thickness"`, `"window"`, or `"arrow"`, and after it either the color string, the thicknes as an integer, the window as 4-vector, and for arrow either `"origin"`, `"end"`, `"both"`, or `"none"`. For `"window"` we can specify `"fit"` rather than a vector in which case, the x range will be set precisely and the y range will be set with five percent borders around the line. Finally, the legend can be specified by adding `"legend"` and the string with the legend.

  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(EulersMethodFull(`(x,y)=y,0,3,100),"color","blue","legend","The Solution")

LinePlotParametric

      LinePlotParametric (xfunc,yfunc,...)

      LinePlotParametric (xfunc,yfunc,t1,t2,tinc)

      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 optionally the limits as `x1,x2,y1,y2`.

  If limits are not specified, then the currently set limits apply (See `LinePlotWindow`).

  The parameter `LinePlotDrawLegends` controls the drawing of the legend.

LinePlotCParametric

      LinePlotCParametric (func,...)

      LinePlotCParametric (func,t1,t2,tinc)

      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 `t1,t2,tinc`, then optionally the limits as `x1,x2,y1,y2`.

  If limits are not specified, then the currently set limits apply (See `LinePlotWindow`).

  The parameter `LinePlotDrawLegends` controls the drawing of the legend.

SlopefieldClearSolutions

      SlopefieldClearSolutions ()

  Clears the solutions drawn by the `SlopefieldDrawSolution` function.

SlopefieldDrawSolution

      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 used with increment `dx`. Solutions stay on the graph until a different plot is shown or until you call `SlopefieldClearSolutions`. You can also use the graphical interface to draw solutions and specify initial conditions with the mouse.

SlopefieldPlot

      SlopefieldPlot (func)

      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 the limits of the plotting window as `x1`, `x2`, `y1`, `y2`. If limits are not specified, then the currently set limits apply (See `LinePlotWindow`).

  The parameter `LinePlotDrawLegends` controls the drawing of the legend.

  Examples:

      genius> Slopefield(`(x,y)=sin(x-y),-5,5,-5,5)

SurfacePlot

      SurfacePlot (func)

      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 `x1`, `x2`, `y1`, `y2`, `z1`, `z2`. If limits are not specified, then the currently set limits apply (See `SurfacePlotWindow`). Genius can only plot a single surface function at this time.

  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)

VectorfieldClearSolutions

      VectorfieldClearSolutions ()

  Clears the solutions drawn by the `VectorfieldDrawSolution` function.

VectorfieldDrawSolution

      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 used with increment `dt` for an interval of length `tlen`. Solutions stay on the graph until a different plot is shown or until you call `VectorfieldClearSolutions`. You can also use the graphical interface to draw solutions and specify initial conditions with the mouse.

VectorfieldPlot

      VectorfieldPlot (funcx, funcy)

      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 dy/dt of the vectorfield. The functions should take two real numbers `x` and `y`, or a single complex number. When the parameter `VectorfieldNormalized` is `true`, then the magnitude of the vectors is normalized. That is, only the direction and not the magnitude is shown.

  Optionally you can specify the limits of the plotting window as `x1`, `x2`, `y1`, `y2`. If limits are not specified, then the currently set limits apply (See `LinePlotWindow`).

  The parameter `LinePlotDrawLegends` controls the drawing of the legend.

  Examples:

      genius> VectorfieldPlot(`(x,y)=x^2-y, `(x,y)=y^2-x, -1, 1, -1, 1)