Welcome to the MathLib.  A product of Prism Research.
(c) 1997-1999 Jonathan Kipling Knight, Prism Research.

Document Date: 2/25/99
MathLib version: 3.02

Answers to examples have been checked using nsScribe.

MathLib is an object-oriented mathematical library of routines that is accessible to any program on the Newton 2.x environment.  MathLib is really two libraries.   The Libraries can be retrieved by the use of a global function call.  The libraries have been separated into units which must be downloaded to the Newton separately.  RandomLib will not work without MathLib loaded.  Once loaded then the routines may be accessed anywhere NewtonScript can be used.  If you use nsScribe I really mean anywhere.

GetLibrary('Math) will retrieve a comprehensive math library which can be used by any student of engineering, math, physics, etc.

GetLibrary('Random) will retrieve a set of routines for statistical analysis of data.  There are several distributions supported both continuous and discrete.

A note for NSBASIC users.
For those who would use NSBASIC, the function calls that are explained in the examples will have to be changed to access the global variable "U" (e.g. u.lib:Gamma(2.3)).  Also, if you wish to include the Basic Internet Tool (BIT) library of routines in the GetLibrary function you may do so by registering the library with the following call:
|LibraryRegistry:Prism|.BIT := GetRoot().|BIT:NSBASIC|
From then on you can access the BIT library by calling GetLibrary('BIT) until a reboot occurs.

Reference of Math Routines

1. General Math

1.1 Numbers
_________________________________________________________________
e
The natural number. 2.71828182846

Example:
local lib,z;
lib := GetLibrary('Math);
z := Log(lib.e);
 = 1.0
_________________________________________________________________
euler
The Euler-Mascheroni constant. 0.577215664902

Example:
local lib,z;
lib := GetLibrary('Math);
z := lib:PolyGamma(1,0)+lib.euler;
 = 0.0
_________________________________________________________________
i
The positive square root of negative one. {class: 'Complex, r: 0, i: 1}

Example:
local lib,z;
lib := GetLibrary('Math);
z := lib:Square(lib.i);
 = -1
_________________________________________________________________
infinite
The largest possible floating point number for the Newton OS.  Numerically equal to 21024 but is unusable as such.

Example:
local lib,z;
lib := GetLibrary('Math);
z := 1/lib.infinite;
 = 0.0
_________________________________________________________________
pi
The circle ratio.  This is the ratio of the circumference of a circle to its diameter (in flat space). 3.14159265359

Example:
local lib,z;
lib := GetLibrary('Math);
z := cos(lib.pi);
 = -1.0
_________________________________________________________________
primes
An array of the first 2585 prime numbers up to sqrt(Pow(2,29)).

Example:
local lib,z;
lib := GetLibrary('Math);
z := lib:MakeRational(lib.primes[5],lib.primes[100]);
 = {class: 'Rational,n: 13,d: 547}
_________________________________________________________________
_conversion
This is the conversion currently used by all trigonometric function.  This number is in Units per radian.  Possible values are 180/pi for degrees, 200/pi for gradians, and 1.0 for radians.  The default is 1.0.

Example:
local lib,z;
lib := GetLibrary('Math);
lib._conversion := 180/lib.pi;
z := lib:sin(90);
 = 1.0

1.2 General Math Routines
_________________________________________________________________
|+|(x,y)
Adds two numbers, vectors, matrices or polynomials : x+y

Input	Class	Range	Description
x	Complex	(-°,°)
y	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	x+y

Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
y := 4;
z := lib:|+|(x,y);
 = {class: 'Complex,r: 4.3,i: 12}
_______________________________________________________________
|-|(x,y)
Subtracts two numbers, vectors, matrices, or polynomials : x-y

Input	Class	Range	Description
x	Complex	(-°,°)
y	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	x-y

Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
y := 4;
z := lib:|-|(x,y);
 = {class: 'Complex,r: -3.7,i: 12}
_______________________________________________________________
|*|(x,y)
Multiplies two numbers, vectors, matrices or polynomials : x*y.  The dot (scalar) product in the case of vectors.

Input	Class	Range	Description
x	Complex	(-°,°)
y	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	x*y

Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
y := 4;
z := lib:|*|(x,y);
 = {class: 'Complex,r: 1.2,i: 48}
_______________________________________________________________
|/|(x,y)
Divides two numbers or matrices : x/y.  If y is a matrix then the answer is x times the inverse of y.
Input	Class	Range	Description
x	Complex	(-°,°)
y	Complex	(-°,°)	divisor

Output	Class	Range	Description
z	Complex	(-°,°)	x/y

Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
y := 4;
z := lib:|/|(x,y);
 = {class: 'Complex,r: 0.075,i: 3.0}
Matrix Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := 1;
y := [[2,3,4],[3,8,0.2],[5,0,-2]];
z := lib:|/|(x,y);
 = [
	[
	0.0935672514619883,
	-0.0350877192982456,
	0.183625730994152
],
	[
	-0.0409356725146199,
	0.140350877192982,
	-0.0678362573099415
],
	[
	0.233918128654971,
	-0.0877192982456141,
	-0.0409356725146199
]
]
_______________________________________________________________
|=|(x,y)
Tests two items for equality : x=y

Input	Class	Range	Description
x	Complex	(-°,°)
y	Complex	(-°,°)

Output	Class	Range	Description
z	Boolean	NIL,TRUE	x=y

Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
x.i:=0;
y:=0.3;
z := lib:|=|(x,y);
 = TRUE
_______________________________________________________________
|<>|(x,y)
Tests two items for inequality : x<>y

Input	Class	Range	Description
x	Complex	(-°,°)
y	Complex	(-°,°)

Output	Class	Range	Description
z	Boolean	NIL,TRUE	x<>y

Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
y := 4;
z := lib:|<>|(x,y);
 = TRUE
_________________________________________________________________
abs(x), fabs(x)
Absolute value of a real number, the magnitude of a complex number, or the determinant of a square matrix.

Input	Class	Range	Description
x	Complex	(-°,°)	number to be sized

Output	Class	Range	Description
z	real	[0,°)	magnitude of x

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(12,-3);
z := lib:fabs(x);
 = 12.369316876853
Determinant example:
local lib,x,z;
lib := GetLibrary('Math);
x := [[0,1,2,3],[9,8,7,6],[8.5,-3,4,2],[3,3,3,0]];
z := lib:fabs(x);
 = 499.5
_______________________________________________________________
acos(x)
Trigonometric arccosine of a number. Principal value (k=0).

Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:acos(x);
 = {
	class: 'Complex,
	r: 1.54588778220986,
	i: -3.18009461623283
}
other answers are lib:Negate(z) and lib:|+|(z,2*lib.pi*k) for any integer k
_______________________________________________________________
acosh(x)
Hyperbolic arccosine of a number.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:acosh(x);
 = {
	class: 'Complex,
	r: 3.18009461623283,
	i: 1.54588778220986
}
_______________________________________________________________
AirySolution(x)
Airy's solution to Bessel's Equation.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	[Ai,Bi,¶/¶x Ai,¶/¶x Bi]

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := -2;
z := lib:AirySolution(x);
 = [
	0.227407428201685,
	-0.412302587956398,
	0.618259020741691,
	0.27879516692117
]
_______________________________________________________________
ArrayAve(x)
Arithmetic average of an array.
Input	Class	Range	Description
x	Array	(-°,°)	complex elements in array

Output	Class	Range	Description
z	complex	(-°,°)	sum elements divided by amount

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := [-2.3,lib:MakeComplex(0.3,12),3.3,5];
z := lib:ArrayAve(x);
 = {class: 'Complex,r: 1.575,i: 3.0}
_______________________________________________________________
ArrayMax(x)
Maximum in an array
Input	Class	Range	Description
x	Array	(-°,°)	real elements in x

Output	Class	Range	Description
z	Real	(-°,°)	maximum in x

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := [-2.3,lib.infinite,3.3,5];
z := lib:ArrayMax(x);
 = 1/0
_______________________________________________________________
ArrayMin(x)
Minimum in an array.
Input	Class	Range	Description
x	Array	(-°,°)	real elements in x

Output	Class	Range	Description
z	Real	(-°,°)	minimum in x

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := [-2.3,lib.infinite,3.3,5];
z := lib:ArrayMin(x);
 = -2.3
_______________________________________________________________
ArrayRemoveDuplicates(x)
Removes duplicates from an array.  x is destructively altered.
Input	Class	Range	Description
x	Array	(-°,°)	complex elements in x

Output	Class	Range	Description
z	Imm	NIL	no usable output

Example:
local lib,x;
lib := GetLibrary('Math);
x := [1.2,lib.i,3,1.2];
lib:ArrayRemoveDuplicates(x);
x
 = [1.2,{class: 'Complex,r: 0,i: 1},3]
_______________________________________________________________
asin(x)
Trigonometric arcsine of a number. Principal value (k=0).
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:asin(x);
 = {
	class: 'Complex,
	r: 0.0249085445850377,
	i: 3.18009461623281
}
other answers are lib:|-|(lib.pi,z) and lib:|+|(z,2*lib.pi*k) for any integer k
_______________________________________________________________
asinh(x)
Hyperbolic arcsine of a number.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:asinh(x);
 = {
	class: 'Complex,
	r: 3.1766288632217,
	i: 1.54571438270682
}
_______________________________________________________________
AssocLegendre(x,m,n)
Associated Legendre function upper index m, lower index n.
Input	Class	Range	Description
x	Complex	(-°,°)
m	integer	[0,n]
n	integer	[0,°)

Output	Class	Range	Description
z	Complex	(-°,°)	Lmn(x)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:AssocLegendre(x,2,3);
 = {class: 'Complex,r: 1948.095,i: 26051.4}
_______________________________________________________________
atan(x)
Trigonometric arctangent of a number. Principal value (k=0).
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:atan(x);
 = {
	class: 'Complex,
	r: 1.56869975651217,
	i: 0.0834742616960157
}
other answers are lib:|+|(z,lib.pi*k) for any integer k
_______________________________________________________________
atan2(y,x)
Trigonometric arctangent of y/x, Real returned in the proper quadrant. Principal value (k=0).
Input	Class	Range	Description
x	Complex	(-°,°)
y	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	atan(y/x)

Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
y := lib:MakeComplex(0.3,-2);
z := lib:atan2(y,x);
 = {
	class: 'Complex,
	r: 6.11861209390149,
	i: -0.0283743258576964
}
other answers are lib:|+|(z,2*lib.pi*k) for any integer k
_______________________________________________________________
atanh(x)
Hyperbolic arctangent of a number.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:atanh(x);
 = {
	class: 'Complex,
	r: 0.00206769391509604,
	i: 1.48770643090179
}
_______________________________________________________________
BaseConv(x,y)
If x is a string, converts x to a base ten number assuming x is of base y.  If x is a number, converts x to a base y number assuming x is of base ten.  The string representation of a number is explained in the example.
Input	Class	Range	Description
x	Real	(-°,°)	base 10 number to be changed to base y
	String	(-°,°)	base y number to be changed to base 10
y	Real	(1,°)	change to/from base

Output	Class	Range	Description
z	String	(-°,°)	new representation base y
	Real	(-°,°)	new representation base 10

Example:
local lib,z;
lib := GetLibrary('Math);
z := lib:BaseConv(3.14159,22);
 = "3.32BE"
digits with value greater than nine will have a Unicode representation starting from $A = 10, $B = 11, etc. However, there are not many printable characters above $~ = 71 */
Scientific notation is supported. For example:
local lib,z;
lib:=GetLibrary('math);
z := lib:BaseConv("7.G4Be+2A",30);
 = 1.88692e+104
_______________________________________________________________
BernoulliNumber(n)
Bernoulli number of order n.
Input	Class	Range	Description
n	Integer	[0,°)	order

Output	Class	Range	Description
z	Real	(-°,°)	Bn = Bn(0)

Example:
local lib,n,z;
lib := GetLibrary('Math);
n := 66;
z := lib:BernoulliNumber(n);
 = 2.27526964884626e+40
_______________________________________________________________
BernoulliPolynomial(x,n)
Bernoulli function of order n evaluated at x.
Input	Class	Range	Description
x	Complex	(-°,°)
n	Integer	[0,°)	order

Output	Class	Range	Description
z	Complex	(-°,°)	Bn(x)

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := 2.7;
n := 10;
z := lib:BernoulliPolynomial(x,n);
 = 1186.25885518066
_______________________________________________________________
Bessel(x,n)
Bessel Function of order n.
Input	Class	Range	Description
x	Complex	(-°,°)
n	Complex	(-°,°)	order of function

Output	Class	Range	Description
z	Complex	(-°,°)	Jn(x)

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := 3.6;
n := 0;
z := lib:Bessel(x,n);
 = -0.391768983700798
_______________________________________________________________
BesselSolution(x,n)
Bessel Function of order n
Input	Class	Range	Description
x	Complex	(-°,°)
n	Complex	(-°,°)	order of function

Output	Class	Range	Description
z	Complex	(-°,°)	[Jn(x),Yn(x),
			¶/¶x Jn(x),¶/¶x Yn(x)]

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := 3.6;
n := 0;
z := lib:BesselSolution(x,n);
 = [
	-0.391768983700798,
	0.147710012611181,
	-0.0954655471778765,
	-0.415391762111444
]
_______________________________________________________________
Beta(x,y)
Beta function
Input	Class	Range	Description
x	Complex	(-°,°)
y	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	B(x,y)

Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := 0.5;
y := lib:MakeComplex(0.3,12);
z := lib:Beta(x,y);
 = {
	class: 'Complex,
	r: 0.362591724492805,
	i: -0.361083418728532
}
_______________________________________________________________
BinCoeff(x,y)
Continuous Binomial Coefficient.
Input	Class	Range	Description
x	Complex	(-°,°)
y	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	(xy)

Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := 6;
y := 0.4;
z := lib:BinCoeff(x,y);
 = 2.35416022356472
_______________________________________________________________
ChebyshevDerivative(fn)
Takes the derivative of the Chebyshev approximation.  Valid in the range that was originally fitted.
Input	Class	Range	Description
fn	Chebyshev	(-°,°)	Chebyshev coefficients as returned from
			ChebyshevFit

Output	Class	Range	Description
z	Chebyshev	(-°,°)	Chebyshev approximation to derivative.
			¶/¶x fn(x)

Example:
local lib,msgFr,fn,parms,p,n,z,range;
lib := GetLibrary('Math);
msgFr := lib;
fn := 'RiemannZeta;
range := [-6,-3];
parms := [5.3];
p := 0;
parms[p] := range;
n := 5;
z := lib:ChebyshevFit(msgFr,fn,parms,p,n);
lib:ChebyshevDerivative(z)
 = [Chebyshev:  0.00421892471638556,0.00764674041260698,-0.00204365830389825,-0.00202931642723419,0.0,[-6,-3]]
_______________________________________________________________
ChebyshevEval(fn,x)
Evaluates the Chebyshev approximation z at x.
Input	Class	Range	Description
fn	Chebyshev	(-°,°)	Chebyshev coefficients as returned from
			ChebyshevFit
x	Real	(-°,°)	number that is within the original fitting
			range.

Output	Class	Range	Description
z	Real	(-°,°)	fn(x).

Example:
local lib,msgFr,fn,parms,p,n,z,range;
lib := GetLibrary('Math);
msgFr := lib;
fn := 'RiemannZeta;
range := [-6,-3];
parms := [5.3];
p := 0;
parms[p] := range;
n := 5;
z := lib:ChebyshevFit(msgFr,fn,parms,p,n);
lib:ChebyshevEval(z,-5)
 = -0.0039855609892807
_______________________________________________________________
ChebyshevFit(msgFr,fn,parms,p,n)
Will fit any function to a Chebyshev polynomial of size n.  The resulting function object will be valid over the range contained in parms[p].  The new fitted polynomial can be evaluated, derived, or integrated.
Input	Class	Range	Description
msgFr	Frame		frame to which the message fn is sent
	Imm	NIL	fn is a stand-alone function
fn	Symbol		message to be sent to msgFr.
	func		stand-alone function.
parms	Array	(-°,°)	array of parameters to be passed to fn.
			parms[p] contains an array that is the
			range to be evaluated over.
p	Integer	[0,#p-1]	parameter to be evaluated.
n	Integer	[1,°)	order of fittness, size of the estimating
			polynomial.

Output	Class	Range	Description
z	Chebyshev	(-°,°)	Chebyshev coefficients

Example:
local lib,msgFr,fn,parms,p,n,z,range;
lib := GetLibrary('Math);
msgFr := lib;
fn := 'RiemannZeta;
range := [-6,-3];
parms := [5.3];
p := 0;
parms[p] := range;
n := 5;
z := lib:ChebyshevFit(msgFr,fn,parms,p,n);
[array: lib:ChebyshevEval(z,-5),Perform(msgFr,fn,[-5])]
 = [-0.0039855609892807,-0.00396825396825397]
_______________________________________________________________
ChebyshevIntegral(fn)
Takes the integral from the beginning of the valid range of the Chebyshev approximation.  Valid in the range that was originally fitted.
Input	Class	Range	Description
fn	Chebyshev	(-°,°)	Chebyshev coefficients as returned from
			ChebyshevFit

Output	Class	Range	Description
z	Chebyshev	(-°,°)	Chebyshev approximation to integral.
			z(x) = ºxafn(y) dy

Example:
local lib,msgFr,fn,parms,p,n,z,range;
lib := GetLibrary('Math);
msgFr := lib;
fn := 'RiemannZeta;
range := [-6,-3];
parms := [5.3];
p := 0;
parms[p] := range;
n := 5;
z := lib:ChebyshevFit(msgFr,fn,parms,p,n);
lib:ChebyshevIntegral(z)
 = [Chebyshev:  -0.00383112142707194,-0.00134536763945881,0.00195294444044528,0.00100225453626171,-9.57964829952304e-05,[-6,-3]]
_______________________________________________________________
CleanComplex(x)
Returns real if a number has no imaginary part.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	x.r if x.i=0

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
x.i := 0;
z := lib:CleanComplex(x);
 = 0.3
_______________________________________________________________
Cos(x)
Trigonometric cosine of a number
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Cos(x);
 = {
	class: 'Complex,
	r: 77742.7955142357,
	i: -24048.6647967258
}
_______________________________________________________________
Cosh(x)
Hyperbolic cosine of a number
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Cosh(x);
 = {
	class: 'Complex,
	r: 0.88211304336318,
	i: -0.163397342445282
}
_______________________________________________________________
Cross(v1,v2)
Cross product of two 3-vectors.  Formerly named X.
Input	Class	Range	Description
v1	Complex	(-°,°)
v2	Complex	(-°,°)

Output	Class	Range	Description
v	Complex	(-°,°)	v1 X v2

Example:
local lib,v1,v2,v,t;
lib := GetLibrary('Math);
v1 := [0.3,5,-4];
v2 := [-2,1,3];
v := lib:Cross(v1,v2); // cross product
t := lib:|*|(v,v1); // dot product
[v,t]
  = [[19,7.1,10.3],0.0]
_______________________________________________________________
Curl(v,x,type)
The curl of the vector of functions at x.
Input	Class	Range	Description
v	Array	(-°,°)	array of functions
x	Array	(-°,°)	parameter list
type	symbol		Coordinate system: 'Cartesian,
			'spherical, or 'cylindrical.
	Array	func obj	Array of functions defining coordinates.

Output	Class	Range	Description
z	Complex	(-°,°)	curl

Example:
local lib,xfn,yfn,zfn,x,z;
lib:=GetLibrary('Math);
xfn:=func(x,y,z) (x+y)/z;
yfn:=func(x,y,z) Pow(x+y,z);
zfn:=func(x,y,z) Gamma(x)/z;
x:=lib.e/6;
z:=lib:curl([xfn,yfn,zfn],[x,3,2*x],'cartesian);
 = [2.38103081868807,2.39902478158396,-4.78005560027203]
_______________________________________________________________
Derivative(msgFr,fn,p,d)
Derivative of fn at p[d] with respect to parameter d.
Input	Class	Range	Description
msgFr	Imm	NIL	no message receiver. fn is stand-alone.
	frame		frame to which the message fn will be sent.
			fn is a symbol which is sent to msgFr.
fn	func		stand-alone function object.
	symbol		function or message.
p	Array		parameters to fn. p[d] contains the value at
			which the derivative is evaluated.
d	Integer	[0,#p-1]	parameter of fn to be derived.

Output	Class	Range	Description
z	Real	(-°,°)	¶/¶x[d]  fn(x,y,...) at p[d].

Example:
local lib,msgFr,fn,p,d,z;
lib := GetLibrary('Math);
msgFr := NIL;
fn:='log;
p:=[1/3];
d:=0;
z:=lib:Derivative(msgFr,fn,p,d);
 = 3.0

local lib,msgFr,fn,p,d,z;
lib := GetLibrary('Math);
msgFr := lib;
fn:='beta;
p:=[3,6];
d:=1;
z:=lib:Derivative(msgFr,fn,p,d);
 = -0.00258645124715767
¶/¶y Beta(x,y) at x=3, y=6
_______________________________________________________________
DirichletBeta(x)
Dirichlet Beta function. Infinite power sum over alternating sign odd integers.
Input	Class	Range	Description
x	Complex	(-°,°)	

Output	Class	Range	Description
z	Complex	(-°,°)	· k:[1,3,...,°) {(-1)(k-1)/2/kx}

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := -2.5;
z := lib:DirichletBeta(x);
 = -0.47477605534091
_______________________________________________________________
DirichletEta(x)
Dirichlet Eta function. Infinite power sum over alternating sign integers.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	· k:[1,°) {(-1)k/kx}

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := -2.5;
z := lib:DirichletEta(x);
 = -0.0878411207213629
_______________________________________________________________
DirichletLambda(x)
Infinite power sum over odd integers.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	· k:[1,3,...,°) (1/kx)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := -2.5;
z := lib:DirichletLambda(x);
 = -0.0396620959717563
_______________________________________________________________
Divergence(v,x,type)
The divergence of the vector of functions at x.
Input	Class	Range	Description
v	Array	(-°,°)	array of functions
x	Array	(-°,°)	parameter list
type	symbol		Coordinate system: 'Cartesian,
			'spherical, or 'cylindrical.
	Array	func obj	Array of functions defining coordinate system.

Output	Class	Range	Description
z	Complex	(-°,°)	¶/¶x v[0] + ¶/¶y v[1] + ¶/¶z v[2]

Example:
local lib,xfn,yfn,zfn,x,z;
lib:=GetLibrary('Math);
xfn:=func(x,y,z) (x+y)/z;
yfn:=func(x,y,z) Pow(x+y,z);
zfn:=func(x,y,z) Gamma(x)/z;
x:=lib.e/6;
z:=lib:divergence([xfn,yfn,zfn],[x,3,2*x],'cartesian);
 = -0.470839787034033
_______________________________________________________________
Erf(x)
Error function over complex plane.  Fixes error in NOS 2.0 fn.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	Erf(x)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Erf(x);
 = {
	class: 'Complex,
	r: 1.15873377394202e+61,
	i: 9.35400929610503e+60
}
_______________________________________________________________
ErfC(x)
Complimentary Error function over complex plane.  1-Erf(x).
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	ErfC(x)

Example:
lib := GetLibrary('Math);
x := 4.8;
z := lib:ErfC(x);
 = 1.1352143584922e-11
_______________________________________________________________
EulerNumber(n)
Euler number of order n.
Input	Class	Range	Description
n	Integer	[0,°)	order

Output	Class	Range	Description
z	Real	(-°,°)	En = En(1/2)*2n

Example:
local lib,n,z;
lib := GetLibrary('Math);
n := 66;
z := lib:EulerNumber(n);
 = -7.88628420666155e+79
_______________________________________________________________
EulerPolynomial(x,n)
Euler function of order n evaluated at x.
Input	Class	Range	Description
x	Complex	(-°,°)
n	Integer	[0,°)	order

Output	Class	Range	Description
z	Complex	(-°,°)	En(x)

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := 2.7;
n := 10;
z := lib:EulerPolynomial(x,n);
 = 363.227573529902
_______________________________________________________________
Exp(x)
Exponential of a number : ex
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	ex

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Exp(x);
 = {
	class: 'Complex,
	r: 1.13908369850293,
	i: -0.724297679269643
}
_______________________________________________________________
Factorial(x)
Continuous factorial function.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	x!

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := 0.5;
z := lib:Factorial(x);
 = 0.886226925452758
// = sqrt(lib.pi)/2
_________________________________________________________________
FloorMod(x,y)
The modulus of x.  Brings x with the range [0,y) by subtracting off multiples of y.
Input	Class	Range	Description
x	Real	(-°,°)	value to be brought within range
y	Real	(-°,°)	target range

Output	Class	Range	Description
z	Real	[0,y)

Example:
local lib,z;
lib := GetLibrary('Math);
z := lib:FloorMod(-45.3,360);
 = 314.7
_______________________________________________________________
Gamma(x)
Gamma function
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Gamma(x);
 = {
	class: 'Complex,
	r: 2.24256979147648e-09,
	i: -9.67504075120069e-09
}
_______________________________________________________________
GaussJordan(A,b)
Solves multiple equations simultaneously by Gauss-Jordan elimination with full pivoting.  The input arrays are destructively altered.  The matrix A is altered to its matrix-inverse and the set of vectors b is altered to the corresponding answers.  The equation to be solved is Ax=b.
Input	Class	Range	Description
A	Array	(-°,°)	square matrix of complex numbers.
b	Array	(-°,°)	an array of arrays of complex numbers.

Output	Class	Range	Description
z	Imm	NIL	no usable output

Example:
Solve for three unknowns
   1.2x + 7.6y + 3.3z = 2.2
   36x + 3.4y - 1.2z = 1.2
   -13x + 3.0y + 7.3z = -1.2
Also with different equality
   1.2x + 7.6y + 3.3z = 3.2
   36x + 3.4y - 1.2z = -32
   -13x + 3.0y + 7.3z = 13

local lib,A,b;
lib := GetLibrary('Math);
A := [[1.2,7.6,3.3],
         [36,3.4,-1.2],
         [-13,3.0,7.3]];
b := [[2.2,1.2,-1.2],
        [3.2,-32,13]];
lib:GaussJordan(A,b);
b
b  = [
	[
	-0.0240144939196458,
	0.466445562876018,
	-0.398839056107322
],
	[
	-0.957334715976984,
	0.656338556984883,
	-0.193748901185676
]
]
A = [
	[
	-0.0211717308970199,
	0.0339552249924759,
	0.0151524632809776
],
	[
	0.184153831025451,
	-0.038484574881775,
	-0.0895738537317969
],
	[
	-0.113382739005152,
	0.0762837876092482,
	0.200781312855904
]
]
Answer for first set:
   x = -0.0240144939196458,y = 0.466445562876018,z = -0.398839056107322
Answer for second set:
   x = -0.957334715976984,y = 0.656338556984883,z = -0.193748901185676
_______________________________________________________________
Gradient(fn,x,type)
The gradient operator.
Input	Class	Range	Description
fn	func	(-°,°)	function
x	Array	(-°,°)	parameter list
type	symbol		Coordinate system: 'Cartesian,
			'spherical, or 'cylindrical.
	Array	func obj	Array of functions for coordinate system.

Output	Class	Range	Description
z	Complex	(-°,°)	[¶/¶x fn,¶/¶y fn,¶/¶z fn]

Example:
local lib,fn,th,z;
lib := GetLibrary('Math);
fn := func(r,th,phi) r*sin(th)*tan(phi);
th:=lib.pi/6;
z := lib:Gradient(fn,[5,th,0.2],'Spherical);
 = [0.101355017754197,0.175552040352591,2.62016123558055]
_________________________________________________________________
HankelSolution(x,n)
Hankel's solution to Bessel's Differential Equation.
Input	Class	Range	Description
x	Complex	(-°,°) 
n	Complex	(-°,°)	order

Output	Class	Range	Description
z	Complex	(-°,°)	[H(0)n(x),H(1)n(x),
			¶/¶x H(0)n(x), ¶/¶x H(1)n(x)]

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
n := -2.2;
z := lib:HankelSolution(x,n);
 = [
	{
	class: 'Complex,
	r: -1.00281613413244e-06,
	i: 1.3723511074204e-06
},
	{
	class: 'Complex,
	r: -25228.623577684,
	i: 17514.4924155544
},
	{
	class: 'Complex,
	r: -1.44789191836026e-06,
	i: -1.06168226921e-06
},
	{
	class: 'Complex,
	r: 17090.9387826882,
	i: 24610.733167162
}
]
_______________________________________________________________
IncompleteBeta(x,a,b)
Incomplete Beta function which is the integral from zero to x of the normalized beta probability distribution.
Input	Class	Range	Description
x	Real	[0,1]
a	Real	(0,°)
b	Real	(0,°)

Output	Class	Range	Description
z	Real	[0,1]	Ix(a,b)=Bx(a,b)/B(a,b)

Example:
local lib,x,a,b,z;
lib := GetLibrary('Math);
x:=0.7;
a:=2.3;
b:=7.3;
z := lib:IncompleteBeta(x,a,b);
 = 0.99859421710381
_______________________________________________________________
IncompleteGamma(x,a)
Incomplete Gamma function which is the integral from zero to x of the normalized gamma probability distribution.
Input	Class	Range	Description
x	Real	[0,°)
a	Real	(0,°)

Output	Class	Range	Description
z	Real	[0,1]	P(a,x)

Example:
local lib,x,a,z;
lib := GetLibrary('Math);
x := 2.7;
a := 0.35;
z := lib:IncompleteGamma(x,a);
 = 0.988378365926057
_______________________________________________________________
Infimum(msgFr,fn,p,d)
Minimum of fn in range p[d]
Input	Class	Range	Description
msgFr	Imm	NIL	fn is a stand-alone function object.
	frame		frame to which the message fn is sent.
			fn is a symbol which is sent to msgFr.
fn	func		function object to be minimized.
	symbol		message to be minimized.
p	Array		parameters to fn. p[d] contains array of
			the limits of search.
d	Integer	[0,#p-1]	parameter of fn to be minimized over.

Output	Class	Range	Description
z	Real	(-°,°)	value at which fn is minimum between
			p[d][0] and p[d][1].

Example:
local lib,range,msgFr,fn,z;
lib := GetLibrary('Math);
range:=[3.3,5];
msgFr:=NIL;
fn:=GetGlobalFn('sin);
z:=lib:Infimum(msgFr,fn,[range],0);
[z,3*lib.pi/2]
  = [4.71238897377504,4.71238898038469]
_______________________________________________________________
Integral(msgFr,fn,p,d)
Integral of fn between range p[d] with respect to parameter d.
Input	Class	Range	Description
msgFr	Imm	NIL	fn is a stand-alone function object.
	frame		frame to which the message fn will be sent.
			fn is a symbol which is sent to msgFr.
fn	func		function to be integrated.
	symbol		message to be integrated.
p	Array		parameters to fn. p[d] contains an array
			of the limits of integration.
d	Integer	[0,#p-1]	parameter of fn to be integrated over.

Output	Class	Range	Description
z	Real	(-°,°)	definite integral from p[d][0] to p[d][1] of fn.

Example:
local lib,msgfr,fn,range,p,d,z,w;
lib:=GetLibrary('Math);
msgFr:=GetLibrary('Random).Gamma;
fn:='Probability;
range:=[0,5.6];
p:=[0,1,3.3];
d:=0;
z:=lib:Integral(msgFr,fn,[range,p],d);
w:=msgFr:Cumulation(range[1],p);
w&&z
 = "0.890539 0.890542"

_______________________________________________________________
IsComplex(x)
Tests if a number is of class 'Complex.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Boolean	NIL,TRUE	ClassOf(x)='Complex

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,0);
z := lib:IsComplex(x);
 = NIL
_______________________________________________________________
IsHermitian(A)
Tests if a matrix is equal to the conjugate of its transpose.
Input	Class	Range	Description
A	Array	(-°,°)	complex matrix

Output	Class	Range	Description
z	Boolean	NIL,TRUE	A = AT*

Example:
local lib,A,z;
lib := GetLibrary('Math);
A := [[1,0,0],[0,-2,lib.i],[0,lib:MakeComplex(0,-1),-5]];
z := lib:IsHermitian(A);
 = TRUE
_______________________________________________________________
IsOrthogonal(A)
Tests if a matrix' inverse is equal to its transpose.
Input	Class	Range	Description
A	Array	(-°,°)	complex matrix

Output	Class	Range	Description
z	Boolean	NIL,TRUE	A-1 = AT

Example:
local lib,A,z;
lib := GetLibrary('Math);
A := [[1,0,0],[0,-2,lib.i],[0,lib:MakeComplex(0,-1),-5]];
z := lib:IsOrthogonal(A);
 = NIL
_______________________________________________________________
IsRational(x)
Tests if a number is of class 'Rational. To be used when doing fraction math.
Input	Class	Range	Description
x	Rational	(-°,°) 

Output	Class	Range	Description
z	Boolean	NIL,TRUE	ClassOf(x)='Rational

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeRational(16,4);
z := lib:IsRational(x);
x = 4.0, z = NIL
_______________________________________________________________
IsSymmetric(A)
Tests if a matrix is equal to its transpose.
Input	Class	Range	Description
A	Array	(-°,°)	complex matrix

Output	Class	Range	Description
z	Boolean	NIL,TRUE	A = AT

Example:
local lib,A,z;
lib := GetLibrary('Math);
A := [[1,0,0],[0,-2,lib.i],[0,lib:MakeComplex(0,-1),-5]];
z := lib:IsSymmetric(A);
 = NIL
_______________________________________________________________
IsSkewSymmetric(A)
Tests if a matrix is equal to the negative of its transpose.
Input	Class	Range	Description
A	Array	(-°,°)	complex matrix

Output	Class	Range	Description
z	Boolean	NIL,TRUE	A = -AT

Example:
local lib,A,z;
lib := GetLibrary('Math);
A := [[1,0,0],[0,-2,lib.i],[0,lib:MakeComplex(0,-1),-5]];
z := lib:IsSkewSymmetric(A);
 = NIL
_______________________________________________________________
IsUnitary(A)
Tests if a matrix' inverse is equal to the conjugate of its transpose.
Input	Class	Range	Description
A	Array	(-°,°)	complex matrix

Output	Class	Range	Description
z	Boolean	NIL,TRUE	A-1 = AT*

Example:
local lib,A,z;
lib := GetLibrary('Math);
A := [[1,0,0],[0,-2,lib.i],[0,lib:MakeComplex(0,-1),-5]];
z := lib:IsUnitary(A);
 = NIL
_______________________________________________________________
Laplacian(fn,x,type)
The Laplacian operator or div-grad.
Input	Class	Range	Description
fn	func	(-°,°)	function
x	Array	(-°,°)	parameter list
type	symbol		Coordinate system: 'Cartesian,
			'spherical, or 'cylindrical.
	Array	func obj	Array of functions defining coordinates.

Output	Class	Range	Description
z	Complex	(-°,°)	¶2/¶x2 fn+¶2/¶y2 fn+¶2/¶z2 fn

Example:
local lib,fn,th,z;
lib := GetLibrary('Math);
fn := func(r,th,phi) r*sin(th)*tan(phi);
th := lib.pi/6;
z  :=  lib:Laplacian(fn,[5,th,0.2],'Spherical);
 = -11.9160100077242
_________________________________________________________________
LBeta(x,y)
Natural log of the Beta function.
Input	Class	Range	Description
x	Complex	(-°,°)
y	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	Log(Beta(x,y))

Example:
local lib,A,z;
lib := GetLibrary('Math);
x := 0.5;
y := lib:MakeComplex(0.3,12);
z := lib:LBeta(x,y);
 = {
	class: 'Complex,
	r: -0.669984102775654,
	i: -0.783313935972515
}
_______________________________________________________________
LBinCoeff(x,y)
Natural log of the Binary Coefficient.
Input	Class	Range	Description
x	Complex	(-°,°)
y	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	Log(BinCoeff(x,y))

Example:
local lib,A,z;
lib := GetLibrary('Math);
x := 0.5;
y := lib:MakeComplex(0.3,12);
z := lib:LBinCoeff(x,y);
 = {
	class: 'Complex,
	r: 32.0125370131849,
	i: -0.15083419022017
}
_______________________________________________________________
LegendrePolynomial(x,n)
Legendre Polynomials evaluated at x.
Input	Class	Range	Description
x	Complex	(-°,°)
n	Integer	[0,°)

Output	Class	Range	Description
z	Complex	(-°,°)	Ln(x)

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
n := 6;
z := lib:LegendrePolynomial(x,n);
 = {
	class: 'Complex,
	r: -43113892.9693188,
	i: 6493897.940985
}
_______________________________________________________________
LGamma(x)
Natural Logarithm of the Gamma function.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	Log(Gamma(x))

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:LGamma(x);
 = {
	class: 'Complex,
	r: -18.4275500519533,
	i: 17.506526607775
}
_______________________________________________________________
LinearRegression(data,xErr,Fns)
Linear Regression of paired data with arbitrary functions.  Solves for the coefficients of y := sumi(a[i]*Fns[0][i](x)) using least squares regression.
Input	Class	Range	Description
data	Array	(-°,°)	complex paired data x:=data[0], y:=data[1].
			x is array of independent values or NIL.
			y is array of dependant values or NIL.
			If NIL then a function must be provide in
			Fns[1] that calculates [x,y] at i. 
xErr	Array	(0,°)	xErr[i] is the error in data[0][i].
	func	(0,°)	xErr(data[0][i]) is the error in data[0][i].
	number	(0,°)	xErr is the error for all data[0] values.
Fns	Array		Elements are functions, constants,
			polynomials, or global function
			symbols. Fns[0] is the array of
			functions to be summed over. Fns[1]
			is the function to preprocess data
			returning [x,y] for the i'th data point.

Output	Class	Range	Description
z	Array	(-°,°)	complex array of coefficients. The second
			last element is the chi-squared fitness.
			The last element is a matrix of covariances
			between each coefficient.

Example:
local lib,dat,xErr,Fns,z;
lib := GetLibrary('Math);
dat := [[0.1,-0.3,0.5,-0.99,0.3,0.5], // x
           [1.2,3.4,86,24,30,6]]; // y
xErr := 1; // use one if error is unknown
Fns := [[2,[0,0,1],'sin],NIL]; // y:=z[0]*2+z[1]*x^2+z[2]*sin(x)
z := lib:LinearRegression(dat,xErr,Fns);
 = [
	3.05895284082066,
	61.6132225592797,
	49.3685269630245,
	3366.36329476341,
	[
	[0.108456097915887,-0.449296743406928,-0.229511473065691],
	[-0.449296743406928,3.03416330525824,1.456062816194],
	[-0.229511473065691,1.456062816194,1.44780974172002]
]
]
chi squared fitness = z[3]
covariance = z[4] = [[c00,c01,c02],[c10,c11,c12],[c20,c21,c22]]

local lib,dat,xErr,Fns,z,preprocess;
lib := GetLibrary('Math);
dat := [[0.1,-0.3,0.5,-0.99,0.3,0.5], // x
           nil]; // y
preprocess := func(dat,i) [dat[0][i],pow(i,3)]; // y=i^3
xErr := 1; // use one if error is unknown
Fns := [[2,[0,0,1],'sin],preprocess]; // y:=z[0]*2+z[1]*x^2+z[2]*sin(x)
z := lib:LinearRegression(dat,xErr,Fns);
 = [5.62136091520382,83.8295818989578,78.7748192250357,7777.87683094057,[[0.108456097915887,-0.449296743406928,-0.229511473065691],[-0.449296743406928,3.03416330525824,1.456062816194],[-0.229511473065691,1.456062816194,1.44780974172002]]]
_______________________________________________________________
Log(x)
Natural log of a number or matrix. The primary answer is returned (k=0).
If the other answers are needed, add multiples of 2¹*k*i.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	Ln(x)

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Log(x);
 = {
	class: 'Complex,
	r: 2.48521905217242,
	i: 1.54580153317598
}
other answers are lib:|+|(z,lib:MakeComplex(0,2*lib.pi*k)) for any integer k
_______________________________________________________________
LUBacksub(A,b)
Lower-Upper solving of matrix equation Ax=b. Input b is destructively altered to the answer.  Input A is unaltered and therefore reusable.
Input	Class	Range	Description
A	LUDecomp	(-°,°)	output of LUDecomp
b	Array	(-°,°)	complex vector

Output	Class	Range	Description
z	Imm	NIL	no usable output

Example:

    x + 2y = 5
    -3x - 4y = 6

local lib,A,b,z;
lib := GetLibrary('Math);
A:=[[1,2],[-3,-4]];
b:=[5,6];
z:=lib:LUDecomp(A);
lib:LUBacksub(z,b);
b
 = [-16.0,10.5]

 x = -16, y = 10.5
_______________________________________________________________
LUDecomp(A)
Lower-Upper Decomposition of a square matrix. Input is destructively altered.  The output is to be used with LUBacksub.
Input	Class	Range	Description
A	Array	(-°,°)	complex, square matrix

Output	Class	Range	Description
z	LUDecomp	(-°,°)	special format array

Example:
local lib,A,z;
lib := GetLibrary('Math);
A := [[1,2],[-3,-4]];
z := lib:LUDecomp(A);
 = [LUDecomp:  
	[[-3,-4],[-0.333333333333333,0.666666666666667]],
	[1,1],
	-1
]
_______________________________________________________________
MakeComplex(x,y)
Use this to make a complex number if y<>0.
Input	Class	Range	Description
x	Real	(-°,°)	real component
y	Real	(-°,°)	imaginary component

Output	Class	Range	Description
z	Complex	(-°,°)	{class:'Complex,r:x,i:y}

Example:
local lib,z;
lib := GetLibrary('Math);
z := lib:MakeComplex(0.3,12);
 = {class: 'Complex,r: 0.3,i: 12}
_______________________________________________________________
MakeRational(x,y)
Use this to make a Rational number (x/y) if x and y < 229.  The fraction will be reduced to its smallest form.
Input	Class	Range	Description
x	Real	(-°,°)	numerator
y	Real	(-°,°)	denominator

Output	Class	Range	Description
z	Rational	(-°,°)	{class:'Rational,n:x,d:y}

Example:
local lib,z;
lib := GetLibrary('Math);
z := lib:MakeRational(3,12);
 = {class: 'Rational,n: 1.0,d: 4}
_______________________________________________________________
MakePolynomial(n,init)
Use this to initialize an array of polynomial coefficients.
Input	Class	Range	Description
n	integer	[0,°)	length of polynomial
init	Complex	(-°,°)	initial value of each coefficient

Output	Class	Range	Description
z	Polynom	(-°,°)	[Polynom: init,init,init,...]

Example:
local lib,z;
lib := GetLibrary('Math);
z := lib:MakePolynomial(3,0);
 = [Polynom:0,0,0]
_______________________________________________________________
ModifiedBessel(x,n)
Modified Bessel Function of order n.  This is also known as Hyperbolic.
Input	Class	Range	Description
x	Complex	(-°,°)
n	Real	(-°,°)	order

Output	Class	Range	Description
z	Complex	(-°,°)	In(x)

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := 3.6;
n := 0;
z := lib:ModifiedBessel(x,n);
 = 8.02768454705401
_______________________________________________________________
ModifiedBesselSolution(x,n)
Solutions to the Modified Bessel Equation of order n.
Input	Class	Range	Description
x	Complex	(-°,°)
n	Real	(-°,°)	order of function

Output	Class	Range	Description
z	Complex	(-°,°)	[In(x),Kn(x),¶/¶x In(x),¶/¶x Kn(x)]

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := 3.6;
n := 0;
z := lib:ModifiedBesselSolution(x,n);
 = [
	8.02768454705401,
	0.0174996410181466,
	6.7927146013613,
	-0.0197949620197206
]
_______________________________________________________________
ModifiedNeumann(x,n)
Modified Neumann Function of order n.  This is also known as Modified Weber's equation. A solution to Modified Bessel equation.
Input	Class	Range	Description
x	Complex	(-°,°)
n	Real	(-°,°)	order

Output	Class	Range	Description
z	Complex	(-°,°)	Kn(x)

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := 3.6;
n := 0;
z := lib:ModifiedNeumann(x,n);
 = 0.0174996410181466
_______________________________________________________________
Negate(x)
Negates a number, vector or matrix : -x
Input	Class	Range	Description
x	Complex	(-°,°)	value to be negated

Output	Class	Range	Description
z	Complex	(-°,°)	-x

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(1,-3);
z := lib:Negate(x);
 = {class: 'Complex,r: -1,i: 3}
_______________________________________________________________
Neumann(x,n)
Neumann Function of order n.  This is also known as Weber's equation. A solution to Bessel's equation.
Input	Class	Range	Description
x	Complex	(-°,°)
n	Real	(-°,°)	order

Output	Class	Range	Description
z	Complex	(-°,°)	Yn(x)

Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := 3.6;
y := 0;
z := lib:Neumann(x,y);
 = 0.147710012611181
_______________________________________________________________
PFE(num,den)
Polynomial Fraction Expansion.  This function will return the fractional expansion of the polynomial division.  That is, num/den = Sum(i:0 to n, ai/Sum(j:0 to mj,bji*xj)).
Input	Class	Range	Description
num	Poly	(-°,°)	numerator polynomial or number
den	Poly	(-°,°)	denominator polynomial

Output	Class	Range	Description
z	Array	(-°,°)	array of polynomial fractions to be added

Example:
local lib,num,den,z;
lib := GetLibrary('Math);
num := [2,-3];
den := [5,4];
z := lib:PFE(num,den);
 = [-0.75,{class: ‘Rational,n:5.75,d: [Polynom: -1.25,-1]}]
/*
This means that
(2-3x)/(5+4x) = -0.75 + 5.75/(-1.25-x)

note: there is an error, 5.75 should be 5.75/(-4).  I’ll have to fix this in a future version.
*/
_______________________________________________________________
PiDigit(d,n,B)
Produces n digits of Pi (3.14159...) in base B starting at position d.  Currently two bases are accurate to 2 million digits: 16 and 1<<20.  Estimates on an MP120 make calulation time for 2 millionth hexadecimal digit at five days (should be 12 hours on MP2000).  Warning: the last (tenth) digit returned is untrustworthy due to round-off error.
Input	Class	Range	Description
d	integer	[0,221]	digit position
n	integer	[1,12]	number of digits to return
B	integer	[2,°)	base (16 or 1<<20)

Output	Class	Range	Description
z	string		Pi digits, if B<=16
	array		Pi digits, if B>16

Example:
local lib,d,n,B,z;
lib := GetLibrary('Math);
d:=1000;
n:=10;
B:=16;
[array: lib:PiDigit(d,n,B),lib:PiDigit(d+1,n,B)]  = ["5743101E4A","743101E49D"]
_______________________________________________________________
PolyGamma(x,y)
The (y+1) derivative of LGamma evaluated at x.  The Digamma function is when y=0.
Input	Class	Range	Description
x	Complex	(-°,°)
y	integer	[-1,°)	derivative

Output	Class	Range	Description
z	Complex	(-°,°)	(¶/¶x)y+1 of LGamma(x)

Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
y := 2;
z := lib:PolyGamma(x,y);
 = {
	class: 'Complex,
	r: 0.00704687903093198,
	i: -0.00025562064626309
}
_______________________________________________________________
PolyLogMod(n,b,f,m,nu)
The fraction of the PolyLog summation. This is accurate if b,f and m are integers or rationals and nu is an integer.  · k:[0,°){b(n-k)/(f*k+m)nu}mod 1.  The case f*k+m=0 is excluded.
Input	Class	Range	Description
n	integer	(-°,°)	starting power
b	Real	(-°,°)	base
f	Real	(-°,°)	factor
m	Real	(-°,°)	starting denominator
nu	Real	(-°,°)	denominator power

Output	Class	Range	Description
z	Complex	(-1,1)

Example:
local lib,n,b,f,m,nu,z;
lib:=GetLibrary('Math);
n:=50;
b:=16;
f := lib:MakeRational(5,76);
m:=1;
nu:=1;
z:=lib:PolyLogMod(n,b,f,m,nu);
 = 0.530131203454609
_______________________________________________________________
PolyNom(x,y)
Evaluate polynomial with coefficients x at the number y
Input	Class	Range	Description
x	Array	(-°,°)	complex elements which are coefficients of a 
			polynomial of degree (Length(x)-1)
y	Complex	(-°,°)	input to the polynomial equation

Output	Class	Range	Description
z	Complex	(-°,°)	· i:[0,n] {x[i]*yi}

Example:
local lib,x,y,z;
lib:=GetLibrary('Math);
x:=[Polynom:0.3,lib.i,0,0,12]; // 0.3 + i*y + 12*y^4
y:=3.3;
z:=lib:PolyNom(x,y);
 = {class: 'Complex,r: 1423.4052,i: 3.3}
_______________________________________________________________
PolynomialFit(xData,yData,n)
Derivative of fn at p[d] with respect to parameter d.
Input	Class	Range	Description
xData	array	Complex	array of independant data.
yData	array	Complex	array of dependant data.
n	Integer	[0,#data)	order of polynomial to be fit.

Output	Class	Range	Description
z	array	(-°,°)	z[0] is array of n coefficients.
			z[1] is the chi-squared measure.

Example:
local lib,n,xData,yData,j,z,x;
lib := GetLibrary('Math);
n := 100;
xData := Array(n,NIL);
yData := Array(n,NIL);
x := 0;
for j:=0 to n-1 do
begin
	x := x + 0.3/n;
	xData[j] := x;
	yData[j] := lib:gamma(x);
end;
z:=lib:PolynomialFit(xData,yData,6);
 = [
[Polynom: 
171.638562050683,
-5071.90297542448,
49804.4838230596,
-183493.309405766,
169000.89984453,
167920.504257882,
90089.5007629843],
47371.4882644824
]
_______________________________________________________________
PolynomialZeroes(x)
All zeroes of polynomials of order four and less. This routine also attempts to find roots for order>=5 but is not guarenteed to find all roots.  Formerly named PolynomialSolution.
Input	Class	Range	Description
x	Array	(-°,°)	complex elements which are coefficients
			of a polynomial of order (Length(x)-1)

Output	Class	Range	Description
z	Array	(-°,°)	PolyNom(x,z[i])=0 for i:[0,order]

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := [Polynom:0.3,lib.i,0,0,12]; // 0.3+i*z+12*z^4=0
z := lib:PolynomialZeroes(x);
  = [
	{class: 'Complex,r: 0.396743346247565,i: -0.294309621033872},
	{class: 'Complex,r: -0.125821394343278,i: 0.294309621033872},
	{class: 'Complex,r: 0.125821394343278,i: 0.294309621033871},
	{class: 'Complex,r: -0.396743346247566,i: -0.294309621033872}
]
_______________________________________________________________
PolynomialToChebyshev(x)
Converts a polynomial into a Chebyshev polynomial valid between (-1,1).
Input	Class	Range	Description
x	Array	(-°,°)	polynomial coefficients

Output	Class	Range	Description
z	Chebyshev	(-°,°)	Array to be used with other Chebyshev
			functions

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := [Polynom:3,0,-9.3,4,36,2];
z := lib:PolynomialToChebyshev(x);
 = [Chebyshev:  23.7,4.25,13.35,1.625,4.5,0.125,[-1,1]]
_______________________________________________________________
Pow(x,y)
One number raised to the power of another : xy.  Returns the primary answer (k=0) in the case of multiple answers.  If y is rational real then the number of answers is the denominator of y.  See example for other answers.
Input	Class	Range	Description
x	Complex	(-°,°)
y	Complex	(-°,°)	exponent

Output	Class	Range	Description
z	Complex	(-°,°)	xy

Example:
local lib,x,y,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
y := lib:MakeComplex(1,-1);
z := lib:Pow(x,y);
 = {
	class: 'Complex,
	r: 33.2423798950268,
	i: -45.4609921705084
}
other answers are lib:|*|(z,lib:Exp(lib:|*|(lib:MakeComplex(0,2*lib.pi*k),y))) for any integer k
_______________________________________________________________
PowMod(x,y,z)
The modulus of xy. fmod(Pow(x,y),z). This is an accurate means of getting an answer even though Pow(x,y) may overflow.  Accurate only if x,y is integer and z is integer or 'Rational.
Input	Class	Range	Description
x	Real	(-°,°)	base
y	Real	(-°,°)	exponent
z	Real	(0,°)	modulus

Output	Class	Range	Description
w	Real	(-z,z)	fmod(Pow(x,y),z)

Example:
local lib,x,y,z,w;
lib := GetLibrary('Math);
x := 5;
y := 2000;
z:=46;
w:=lib:PowMod(x,y,z);
[w,fmod(pow(x,y),z)]
 = [35.0,(1/0)/(1/0)]
_______________________________________________________________
QGaussIntegral(msgFr,fn,parms,dx,n)
Integral of function by Gauss-Legendre Quadrature of order n.  The weight function is one.
Input	Class	Range	Description
msgFr	Imm	NIL	fn is a stand-alone function object.
	frame		frame to which the message fn will be sent. 
			fn is a symbol which is sent to msgFr.
fn	func		function to be integrated.
	symbol		message to be integrated.
p	Array		parameters to fn. p[d] contains an array
			of the limits of integration.
d	Integer	[0,#p-1]	parameter of fn to be integrated over.
n	Integer	[2,°)	order of quadrature (higher the better).

Output	Class	Range	Description
z	Real	(-°,°)	ºp[d][0] to p[d][1] of fn.

Example:
local lib,msgfr,fn,range,p,d,n,z;
lib:=GetLibrary('Math);
msgFr:=NIL;
fn:=GetGlobalFn('Exp);
range := [0,5.6];
d:=0;
n:=16; //order
z := lib:QGaussIntegral(msgFr,fn,[range],d,n);
[z,exp(5.6)-exp(0)]
 = [269.426416352977,269.426407426153]

local lib,msgfr,fn,range,p,d,z;
lib:=GetLibrary('Math);
msgFr:=lib;
fn:='LGamma;
range:=[5.6,lib.i];
p:=[range];
d:=0;
z:=lib:QGaussIntegral(msgFr,fn,p,d,10);
 = {
	class: 'Complex,
	r: -5.22515462229719,
	i: 0.764292117513662
}
ºi5.6 Log(Gamma(x)) dx
_______________________________________________________________
ReduceRational(x)
Reduces a rational number to it's smallest form. Note: MakeRational and most algebra functions automatically call ReduceRational.  Therefore this function is not normally needed.
Input	Class	Range	Description
x	Rational	(-229,229) 

Output	Class	Range	Description
z	Rational	(-229,229) 

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := {class:'Rational,n:36,d:2040};
z := lib:ReduceRational(x);
 = {class: 'Rational,n: 3.0,d: 170}
_______________________________________________________________
RemQuo(num,den)
Riemann-Siegel Theta function.
Input	Class	Range	Description
num	Poly	(-°,°)	numerator
den	Poly	(-°,°)	denominator

Output	Class	Range	Description
z	Array	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
num := [Polynom:2,-3];
den := [Polynom: 5,-4];
z := lib:RemQuo(num,den);
 = [-1.75,0.75]
/*
This means
(2-3x)/(5-4x) = 0.75 - 1.75/(5-4x)
*/
_______________________________________________________________
RiemannSiegelTheta(x)
Riemann-Siegel Theta function.
Input	Class	Range	Description
x	Real	(-°,°)

Output	Class	Range	Description
z	Real	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := 5.2;
z := lib:RiemannSiegelTheta(x);
 = -3.48065183021066
_______________________________________________________________
RiemannSiegelZ(x)
Riemann-Siegel Z function. Zeta(0.5 + i * t)*Exp(Theta(t)).
Input	Class	Range	Description
x	Real	(-°,°)

Output	Class	Range	Description
z	Real	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := 35.2;
z := lib:RiemannSiegelZ(x);
 = 2.91067033259366
_______________________________________________________________
RiemannZeta(x)
Riemann Zeta function. Infinite power sum over integers.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	·k:[1,°) 1/kx for x>1

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := -5.2;
z := lib:RiemannZeta(x);
 = -0.00368043804779309
_______________________________________________________________
RootSearch(msgFr,fn,parms,p,ans)
Searches for the answer to a transcendal equation or any equation where the answer is known but not the input.
Input	Class	Range	Description
msgFr	Imm	NIL	fn is a standalone function object.
	frame		frame to which the message fn is sent.
fn	func		standalone function object.
	symbol		message to be sent to msgFr.
parms	Array		starting parameters to be passed to fn.
p	Integer	[0,#p-1]	parameter number to be searched.
ans	Complex	(-°,°)	answer to the function.

Output	Class	Range	Description
z	Complex	(-°,°)	fn at parms[p]:=z = ans

Example:
local lib,z;
lib := GetLibrary('Math);
z := lib:RootSearch(nil,'expm1,[4.5],0,5);
[z,expm1(z)]
 = [1.79175946922805,5.0]

local lib,z;
lib := GetLibrary('Math);
z := lib:RootSearch(lib,'bessel,[2,0],0,0); // bessel zero near 2
[z,lib:bessel(z,0)]
 = [2.40482555769577,-2.51329198274926e-17]
_______________________________________________________________
Round(x)
Round a number to the nearest integer.
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°) 

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Round(x);
 = {class: 'Complex,r: 0.0,i: 12.0}
_______________________________________________________________
RoundDec(x,d)
Round a number to the nearest decimal place.
Input	Class	Range	Description
x	Complex	(-°,°)
d	integer	(-°,°)	decimal place

Output	Class	Range	Description
z	Complex	(-°,°) 

Example:
local lib,x,d,z;
lib := GetLibrary('Math);
x := lib.euler;
d := 5;
z := lib:RoundDec(x,d);
 = 0.57722
_______________________________________________________________
RoundSigFigs(x)
Round a number to the nearest significant figures.
Input	Class	Range	Description
x	Complex	(-°,°)
s	integer	(-°,°)	significant figures

Output	Class	Range	Description
z	Complex	(-°,°) 

Example:
local lib,x,s,z;
lib := GetLibrary('Math);
x := 509.67324;
s := 6;
z := lib:RoundSigFigs(x,s);
 = 509.673
_______________________________________________________________
Sin(x)
Trigonometric sine of a number
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Sin(x);
 = {
	class: 'Complex,
	r: 24048.6647985415,
	i: 77742.7955083658
}
_______________________________________________________________
Sinh(x)
Hyperbolic sine of a number
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Sinh(x);
 = {
	class: 'Complex,
	r: 0.256970655139752,
	i: -0.560900336824361
}
_______________________________________________________________
SinSeries(c,x,y)
Sine series summation. Useful for certain astronomy algorithms
and Fourier series.
Input	Class	Range	Description
c	Array	(-°,°)	coefficients for the summation.
			c[i][0] is the coefficient to the sine function.
			If this is an array then it represents a 
			polynomial which is to be evaluated at x.
			c[i][1] is the constant (radians) to be added
			to the sine argument.  c[i][2+] are the 
			coefficients to the corresponding angles y[0+].
x	Complex	(-°,°)	polynomial argument
y	Array	(-°,°)	angles (radians) for sine function

Output	Class	Range	Description
z	Complex	(-°,°)	sum over coefficients and sine

Example:
local lib,x,y,c,z;
lib:=GetLibrary('Math);
x:=3;
y:=[2.3,4.6,0.2,-0.3];//A,B,C,D
c:=[[1.2,0,1,1,1,-1],//1.2sin(A+B+C-D)+
    [3.3,0,1,0,0,0],//3.3sin(A)+
    [1.0,lib.pi/2,0,0,0,1],//1.0cos(D)+
    [[2.3,4.2],0,1,-1,0,0],//(2.3+4.2x)sin(A-B)+
    [0.01,0.13,0,0,2,1]];//0.01sin(0.13+2C+D)
z:=lib:SinSeries(c,x,y);
 = -6.61411448191505
_______________________________________________________________
SphericalBessel(x,y)
Spherical Bessel Function of order n.
Input	Class	Range	Description
x	Complex	(-°,°)
n	Real	(-°,°)	order

Output	Class	Range	Description
z	Complex	(-°,°)	jn(x)

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := 3.6;
n := 0;
z := lib:SphericalBessel(x,n);
 = -0.122922345359681
_______________________________________________________________
SphericalBesselSolution(x,y)
Solutions to the Spherical Bessel Equation of order n.
Input	Class	Range	Description
x	Complex	(-°,°)
n	Real	(-°,°)	order of function

Output	Class	Range	Description
z	Complex	(-°,°)	[jn(x),yn(x),¶/¶x jn(x), ¶/¶x yn(x)]

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := 3.6;
n := 0;
z := lib:SphericalBesselSolution(x,n);
 = [
	-0.122922345359681,
	0.249099560092819,
	-0.214954464159574,
	-0.192116667607686
]
_______________________________________________________________
SphericalNeumann(x,y)
Spherical Neumann Function of order n.
Input	Class	Range	Description
x	Complex	(-°,°)
n	Real	(-°,°)	order

Output	Class	Range	Description
z	Complex	(-°,°)	Kn(x)

Example:
local lib,x,n,z;
lib := GetLibrary('Math);
x := 3.6;
n := 0;
z := lib:SphericalNeumann(x,n);
 = 0.249099560092819
_______________________________________________________________
Sqrt(x)
Square root of a number or matrix. Returns the primary answer (z.r>0).  The other answer is :Negate(z).
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	Ãx

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Sqrt(x);
 = {
	class: 'Complex,
	r: 2.48029730216415,
	i: 2.41906484144654
}
other answer is lib:Negate(z)
_______________________________________________________________
Square(x)
Square of a number or matrix : x2
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)	x2

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Square(x);
 = {class: 'Complex,r: -143.91,i: 7.2}
_______________________________________________________________
Supremum(msgFr,fn,p,d)
Maximum of fn in range p[d]
Input	Class	Range	Description
msgFr	Imm	NIL	fn is a stand-alone function object.
	frame		frame to which the message fn will be sent.
			fn is a symbol which is sent to msgFr.
fn	func		function to be maximized.
	symbol		message to be maximized.
p	Array		parameters to fn. p[d] contains an array of
			the limits of search.
d	Integer	[0,#p-1]	parameter of fn to be maximized over.

Output	Class	Range	Description
z	Real	(-°,°)	value at which fn is maximum between 
			p[d][0] and p[d][1].

Example:
local lib,range,msgfr,fn,z;
lib:=GetLibrary('Math);
range:=[0,3.3];
msgFr:=NIL;
fn:=GetGlobalFn('sin);
z:=lib:Supremum(msgFr,fn,[range],0);
 = 1.57079631717677
= lib.pi/2
_______________________________________________________________
SVBacksub(A,b)
Singular-Value solving of matrix equation Ax=b useful for near singular equations. Input b is destructively altered but A is unaltered.  
Input	Class	Range	Description
A	SVDecomp	(-°,°)	output of SVDecomp
b	Array	(-°,°)	complex vector

Output	Class	Range	Description
z	Imm	NIL	no usable output

Example:

    x + 2y = 5
    -3x - 4y = 6

local lib,A,b,z;
lib:=GetLibrary('Math);
A:=[[1,2],[-3,-4]];
b:=[5,6];
z:=lib:SVDecomp(A);
lib:SVBacksub(z,b);
b
 = [-16.0,10.5]
x = -16, y = 10.5
_______________________________________________________________
SVDecomp(A)
Singular-Value Decomposition of a matrix. Input is destructively altered.  The output is to be used with SVBacksub.  This method provides a means to solve sets of equations that are singular in nature (or near singular) where other methods would blow up.
Input	Class	Range	Description
A	Array	(-°,°)	complex, square matrix

Output	Class	Range	Description
z	SVDecomp	(-°,°)	special format array

Example:
local lib,A,z;
lib := GetLibrary('Math);
A := [[1,2],[-3,-4]];
z := lib:SVDecomp(A);
 = [SVDecomp:  
	[
	[0.914514295677304,-0.404553584833757],
	[0.404553584833757,0.914514295677304]
],
	[0.365966190626258,5.46498570421904],
	[
	[-0.817415560470363,-0.576048436766321],
	[0.576048436766321,-0.817415560470363]
]
]
_______________________________________________________________
SymbolicDerivative(fn,d)
This call will transform the function fn into its derivative with respect to parameter d. This is limited to all math functions that are in ROM or polynomials.  The returned object is either the symbol for the OS function or a function object or a number. Any output from this can be evaluated with :SymbolicEval(dfn,x) where x is list of parameters to be passed to dfn. Returns NIL if unable to do derivative symbolically.
Input	Class	Range	Description
fn	number	(-°,°)	number
	symbol		symbol of global function
	Array	(-°,°)	polynomial coefficients
	Chebyshev	(-°,°)	Chebyshev fit 

d	integer	[0,...]	parameter number

Output	Class	Range	Description
z			derivative function

Example:
local lib,fn,z,z1,z2,z3;
lib:=GetLibrary('Math);
fn:='sin;
z:=lib:SymbolicDerivative(fn,0);
//¶/¶x(sin(x))='cos
z1:=lib:SymbolicDerivative(z,0);
//¶/¶x(cos(x))=func(x)-sin(x)  
z2:=lib:SymbolicDerivative('|/|,1);
//¶/¶y(x/y)= func(x,y) -x/(y*y)  
z3:=lib:SymbolicDerivative([3,2.3,4],0);
//¶/¶x(3+2.3*x+4*x*x) = [2.3,8]
_______________________________________________________________
SymbolicIntegral(fn,dx)
This call will transform the function fn into its indefinite integral with respect to parameter dx. This is limited to all math functions that are in ROM or polynomials.  The returned object is either the symbol for the OS function or a function object or a number. Any output from this can be evaluated with :SymbolicEval(ifn,x) where x is list of parameters to be passed to ifn. Returns NIL if unable to do integral symbolically.
Input	Class	Range	Description
fn	number	(-°,°)	number
	symbol		symbol of function
	Array	(-°,°)	polynomial coefficients
	Chebyshev	(-°,°)	Chebyshev fit 
dx	integer	[0,...]	parameter number

Output	Class	Range	Description
z			integral function

Example:
printdepth := 3;
local lib,fn,z,z1,z2,z3;
lib := GetLibrary('Math);
fn := 'sin;
z := lib:SymbolicIntegral(fn,0); // ºsin(x)dx=func(x) -cos(x)
z1 := lib:SymbolicIntegral('cos,0); // ºcos(x)dx='sin
z2 := lib:SymbolicIntegral('|/|,1); // ºx/ydy = func(x,y) x*Log(y)
z3 := lib:SymbolicIntegral([3,2.3,4],0); // º3 + 2.3*x + 4*x*x dx
[z,z1,z2,z3]
 = /* inspect printDepth:=11;printLength:=4558 */
[
	{class: Ref(0x32),instructions: MakeBinaryFromHex("7B1829192902",'instructions),literals: [literals:  'cos,'negate],argFrame: NIL,numArgs: 0x1},
	'sin,
	{
	class: Ref(0x32),
	instructions: MakeBinaryFromHex("7020C46F00187B7BC70007270008C700087CC700085F001F7C19297BC7000702",'instructions),
	literals: [literals:  'dx,'log],
	argFrame: {_nextArgFrame: Ref(0xC66DFED),_parent: NIL,_implementor: NIL},
	numArgs: 0x2
},
	[0,3,1.15,1.33333333333333]
]
_______________________________________________________________
SymbolicEval(fn,x)
This call will transform the function fn into it's derivative with respect to parameter d. This is limited to all math functions that are in ROM or polynomials.  The returned object is either the symbol for the OS function or a function object or a number.  Any output from this can be evaluated with :SymbolicEval(dfn,x) where x is list of parameters to be passed to dfn. Returns NIL if unable to do derivative symbolically.
Input	Class	Range	Description
fn	number		number (no evaluation needed)
	symbol		symbol of function
	Array	(-°,°)	polynomial coefficients
	Chebyshev	(-°,°)	Chebyshev fit
x	Array	(-°,°)	array of parameters

Output	Class	Range	Description
z			answer to evaluation

Example:
local lib,fn,z,z1,z2,z3;
lib:=GetLibrary('Math);
fn:='sin;
z:=lib:SymbolicEval(fn,32);//sin(32)=0.551426681241692
fn:=lib:SymbolicDerivative('cos,0);
z1:=lib:SymbolicEval(fn,2);//¶/¶x(cos(x)) at x=2 = -0.909297426825682
z2:=lib:SymbolicEval('|/|,[5,-2]);//=-2.5
z3:=lib:SymbolicEval([3,2.3,4],4);//(3 + 2.3*x + 4*x*x) at x=4 = 76.2
_______________________________________________________________
Tan(x)
Trigonometric tangent of a number
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Tan(x);
 = {
	class: 'Complex,
	r: 4.26320261269592e-11,
	i: 0.999999999937685
}
_______________________________________________________________
Tanh(x)
Hyperbolic tangent of a number
Input	Class	Range	Description
x	Complex	(-°,°)

Output	Class	Range	Description
z	Complex	(-°,°)

Example:
local lib,x,z;
lib := GetLibrary('Math);
x := lib:MakeComplex(0.3,12);
z := lib:Tanh(x);
 = {
	class: 'Complex,
	r: 0.395524409699372,
	i: -0.56259535344261
}
_______________________________________________________________