Add | find sum of a list of values |
Sum | find sum of a sequence |
Factorize | product of a list of values |
Taylor | univariate Taylor series expansion |
InverseTaylor | Taylor expansion of inverse |
ReversePoly | solve h(f(x))=g(x)+O(x^n) for h |
BigOh | drop all terms of a certain order in a polynomial |
LagrangeInterpolant | polynomial interpolation |
Add(val1, val2, ...) Add({list}) |
{list} -- list of expressions to add
In> Add(1,4,9); Out> 14; In> Add(1 .. 10); Out> 55; |
Sum(var, from, to, body) |
from -- integer value to iterate from
to -- integer value to iterate up to
body -- expression to evaluate for each iteration
Warning: Sum does not evaluate its arguments var and body until the actual loop is run.
In> Sum(i, 1, 3, i^2); Out> 14; |
Factorize(list) Factorize(var, from, to, body) |
var -- variable to iterate over
from -- integer value to iterate from
to -- integer value to iterate up to
body -- expression to evaluate for each iteration
If the second calling sequence is used, the expression "body" is evaluated while the variable "var" ranges over all integers from "from" up to "to", and the product of all the results is returned. Obviously, "to" should be greater than or equal to "from".
In> Factorize({1,2,3,4}); Out> 24; In> Factorize(i, 1, 4, i); Out> 24; |
Taylor(var, at, order) expr |
at -- point to get Taylor series around
order -- order of approximation
expr -- expression to get Taylor series for
In> PrettyForm(Taylor(x,0,9) Sin(x)) 3 5 7 9 x x x x x - -- + --- - ---- + ------ 6 120 5040 362880 Out> True; |
InverseTaylor(var, at, order) expr |
at -- point to get inverse Taylor series around
order -- order of approximation
expr -- expression to get inverse Taylor series for
In> PrettyPrinter'Set("PrettyForm") True In> exp1 := Taylor(x,0,7) Sin(x) 3 5 7 x x x x - -- + --- - ---- 6 120 5040 In> exp2 := InverseTaylor(x,0,7) ArcSin(x) 5 7 3 x x x --- - ---- - -- + x 120 5040 6 In> Simplify(exp1-exp2) 0 |
ReversePoly(f, g, var, newvar, degree) |
var -- a variable
newvar -- a new variable to express the result in
degree -- the degree of the required solution
This function is used to determine the Taylor series expansion of the inverse of a function "f": if we take "g(var)=var", then "h(f(var))=var" (up to order "degree"), so "h" will be the inverse of "f".
In> f(x):=Eval(Expand((1+x)^4)) Out> True; In> g(x) := x^2 Out> True; In> h(y):=Eval(ReversePoly(f(x),g(x),x,y,8)) Out> True; In> BigOh(h(f(x)),x,8) Out> x^2; In> h(x) Out> (-2695*(x-1)^7)/131072+(791*(x-1)^6) /32768 +(-119*(x-1)^5)/4096+(37*(x-1)^4) /1024+(-3*(x-1)^3)/64+(x-1)^2/16; |
BigOh(poly, var, degree) |
var -- a free variable
degree -- positive integer
In> BigOh(1+x+x^2+x^3,x,2) Out> x+1; |
LagrangeInterpolant(xlist, ylist, var) |
ylist -- list of function values
var -- free variable for resulting polynomial
The lists "xlist" and "ylist" should be of equal length. Furthermore, the entries of "xlist" should be all distinct to ensure that there is one and only one solution.
This routine uses the Lagrange interpolant formula to build up the polynomial.
In> f := LagrangeInterpolant({0,1,2}, \ {0,1,1}, x); Out> (x*(x-1))/2-x*(x-2); In> Eval(Subst(x,0) f); Out> 0; In> Eval(Subst(x,1) f); Out> 1; In> Eval(Subst(x,2) f); Out> 1; In> PrettyPrinter'Set("PrettyForm"); True In> LagrangeInterpolant({x1,x2,x3}, {y1,y2,y3}, x) y1 * ( x - x2 ) * ( x - x3 ) ---------------------------- ( x1 - x2 ) * ( x1 - x3 ) y2 * ( x - x1 ) * ( x - x3 ) + ---------------------------- ( x2 - x1 ) * ( x2 - x3 ) y3 * ( x - x1 ) * ( x - x2 ) + ---------------------------- ( x3 - x1 ) * ( x3 - x2 ) |