Series

(directly go to documentation on : Add, Sum, Factorize, Taylor, InverseTaylor, ReversePoly, BigOh, LagrangeInterpolant. )

# 6. Series

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 -- find sum of a list of values

##### Standard library

##### Calling format:

    Add(val1, val2, ...)
    Add({list})

##### Parameters:

`val1`, `val2` -- expressions

`{list}` -- list of expressions to add

##### Description:

This function adds all its arguments and returns their sum. It accepts any number of arguments. The arguments can be also passed as a list.

##### Examples:

    In> Add(1,4,9);
    Out> 14;
    In> Add(1 .. 10);
    Out> 55;

###

Sum -- find sum of a sequence

##### Standard library

##### Calling format:

    Sum(var, from, to, body)

##### Parameters:

`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

##### Description:

The command finds the sum of the sequence generated by an iterative formula. The expression "body" is evaluated while the variable "var" ranges over all integers from "from" up to "to", and the sum of all the results is returned. Obviously, "to" should be greater than or equal to "from".

Warning: `Sum` does not evaluate its arguments `var` and `body` until the actual loop is run.

##### Examples:

    In> Sum(i, 1, 3, i^2);
    Out> 14;

##### See also:

Factorize .

###

Factorize -- product of a list of values

##### Standard library

##### Calling format:

    Factorize(list)
    Factorize(var, from, to, body)

##### Parameters:

`list` -- list of values to multiply

`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

##### Description:

The first form of the `Factorize` command simply multiplies all the entries in "list" and returns their product.

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

##### Examples:

    In> Factorize({1,2,3,4});
    Out> 24;
    In> Factorize(i, 1, 4, i);
    Out> 24;

##### See also:

Sum , Apply .

###

Taylor -- univariate Taylor series expansion

##### Standard library

##### Calling format:

    Taylor(var, at, order) expr

##### Parameters:

`var` -- variable

`at` -- point to get Taylor series around

`order` -- order of approximation

`expr` -- expression to get Taylor series for

##### Description:

This function returns the Taylor series expansion of the expression "expr" with respect to the variable "var" around "at" up to order "order". This is a polynomial which agrees with "expr" at the point "var = at", and furthermore the first "order" derivatives of the polynomial at this point agree with "expr". Taylor expansions around removable singularities are correctly handled by taking the limit as "var" approaches "at".

##### Examples:

    In> PrettyForm(Taylor(x,0,9) Sin(x))

         3    5      7       9
        x    x      x       x
    x - -- + --- - ---- + ------
        6    120   5040   362880

    Out> True;

##### See also:

D , InverseTaylor , ReversePoly , BigOh .

###

InverseTaylor -- Taylor expansion of inverse

##### Standard library

##### Calling format:

    InverseTaylor(var, at, order) expr

##### Parameters:

`var` -- variable

`at` -- point to get inverse Taylor series around

`order` -- order of approximation

`expr` -- expression to get inverse Taylor series for

##### Description:

This function builds the Taylor series expansion of the inverse of the expression "expr" with respect to the variable "var" around "at" up to order "order". It uses the function `ReversePoly` to perform the task.

##### Examples:

    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

##### See also:

ReversePoly , Taylor , BigOh .

###

ReversePoly -- solve h(f(x))=g(x)+O(x^n) for h

##### Standard library

##### Calling format:

    ReversePoly(f, g, var, newvar, degree)

##### Parameters:

`f`, `g` -- functions of "var"

`var` -- a variable

`newvar` -- a new variable to express the result in

`degree` -- the degree of the required solution

##### Description:

This function returns a polynomial in "newvar", say "h(newvar)", with the property that "h(f(var))" equals "g(var)" up to order "degree". The degree of the result will be at most "degree-1". The only requirement is that the first derivative of "f" should not be zero.

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

##### Examples:

    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;

##### See also:

InverseTaylor , Taylor , BigOh .

###

BigOh -- drop all terms of a certain order in a polynomial

##### Standard library

##### Calling format:

    BigOh(poly, var, degree)

##### Parameters:

`poly` -- a univariate polynomial

`var` -- a free variable

`degree` -- positive integer

##### Description:

This function drops all terms of order "degree" or higher in "poly", which is a polynomial in the variable "var".

##### Examples:

    In> BigOh(1+x+x^2+x^3,x,2)
    Out> x+1;

##### See also:

Taylor , InverseTaylor .

###

LagrangeInterpolant -- polynomial interpolation

##### Standard library

##### Calling format:

    LagrangeInterpolant(xlist, ylist, var)

##### Parameters:

`xlist` -- list of argument values

`ylist` -- list of function values

`var` -- free variable for resulting polynomial

##### Description:

This function returns a polynomial in the variable "var" which interpolates the points "(xlist, ylist)". Specifically, the value of the resulting polynomial at "xlist[1]" is "ylist[1]", the value at "xlist[2]" is "ylist[2]", etc. The degree of the polynomial is not greater than the length of "xlist".

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.

##### Examples:

    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 )

##### See also:

Subst .