Functions and Variables for Sums and Products
=============================================

 -- Function: bashindices (EXPR)

     Transforms the expression EXPR by giving each summation and product a unique index.  This gives changevar greater precision when it is working with summations or products.  The form of the unique index is jNUMBER. The quantity NUMBER is determined by referring to gensumnum, which can be changed by the user.  For example, gensumnum:0$ resets it.

     Categories: Sums and products

 -- Function: lsum (EXPR, X, L)

     Represents the sum of EXPR for each element X in L. A noun form 'lsum is returned if the argument L does not evaluate to a list.

     Examples:

          (%i1) lsum (x^i, i, [1, 2, 7]);
                                      7    2
          (%o1)                      x  + x  + x
          (%i2) lsum (i^2, i, rootsof (x^3 - 1, x));

                               ====
                               \      2
          (%o2)                 >    i
                               /
                               ====
                                             3
                               i in rootsof(x  - 1, x)

     Categories: Sums and products

 -- Function: intosum (EXPR)

     Moves multiplicative factors outside a summation to inside. If the index is used in the outside expression, then the function tries to find a reasonable index, the same as it does for sumcontract.  This is essentially the reverse idea of the outative property of summations, but note that it does not remove this property, it only bypasses it.

     In some cases, a scanmap (multthru, EXPR) may be necessary before the intosum.

     Categories: Expressions

 -- Option variable: simpproduct
     Default value: false

     When simpproduct is true, the result of a product is simplified. This simplification may sometimes be able to produce a closed form.  If simpproduct is false or if the quoted form 'product is used, the value is a product noun form which is a representation of the pi notation used in mathematics.

     Categories: Sums and products Simplification flags and variables

 -- Function: product (EXPR, I, I_0, I_1)

     Represents a product of the values of EXPR as the index I varies from I_0 to I_1. The noun form 'product is displayed as an uppercase letter pi.

     product evaluates EXPR and lower and upper limits I_0 and I_1, product quotes (does not evaluate) the index I.

     If the upper and lower limits differ by an integer, EXPR is evaluated for each value of the index I, and the result is an explicit product.

     Otherwise, the range of the index is indefinite. Some rules are applied to simplify the product. When the global variable simpproduct is true, additional rules are applied.  In some cases, simplification yields a result which is not a product; otherwise, the result is a noun form 'product.

     See also nouns and evflag

     Examples:

          (%i1) product (x + i*(i+1)/2, i, 1, 4);
          (%o1)           (x + 1) (x + 3) (x + 6) (x + 10)
          (%i2) product (i^2, i, 1, 7);
          (%o2)                       25401600
          (%i3) product (a[i], i, 1, 7);
          (%o3)                 a  a  a  a  a  a  a
                                 1  2  3  4  5  6  7
          (%i4) product (a(i), i, 1, 7);
          (%o4)          a(1) a(2) a(3) a(4) a(5) a(6) a(7)
          (%i5) product (a(i), i, 1, n);
                                       n
                                     /===\
                                      ! !
          (%o5)                       ! !  a(i)
                                      ! !
                                     i = 1
          (%i6) product (k, k, 1, n);
                                         n
                                       /===\
                                        ! !
          (%o6)                         ! !  k
                                        ! !
                                       k = 1
          (%i7) product (k, k, 1, n), simpproduct;
          (%o7)                          n!
          (%i8) product (integrate (x^k, x, 0, 1), k, 1, n);
                                       n
                                     /===\
                                      ! !    1
          (%o8)                       ! !  -----
                                      ! !  k + 1
                                     k = 1
          (%i9) product (if k <= 5 then a^k else b^k, k, 1, 10);
                                        15  40
          (%o9)                        a   b

     Categories: Sums and products

 -- Option variable: simpsum
     Default value: false

     When simpsum is true, the result of a sum is simplified. This simplification may sometimes be able to produce a closed form.  If simpsum is false or if the quoted form 'sum is used, the value is a sum noun form which is a representation of the sigma notation used in mathematics.

     Categories: Sums and products Simplification flags and variables

 -- Function: sum (EXPR, I, I_0, I_1)

     Represents a summation of the values of EXPR as the index I varies from I_0 to I_1. The noun form 'sum is displayed as an uppercase letter sigma.

     sum evaluates its summand EXPR and lower and upper limits I_0 and I_1, sum quotes (does not evaluate) the index I.

     If the upper and lower limits differ by an integer, the summand EXPR is evaluated for each value of the summation index I, and the result is an explicit sum.

     Otherwise, the range of the index is indefinite. Some rules are applied to simplify the summation. When the global variable simpsum is true, additional rules are applied.  In some cases, simplification yields a result which is not a summation; otherwise, the result is a noun form 'sum.

     When the evflag (evaluation flag) cauchysum is true, a product of summations is expressed as a Cauchy product, in which the index of the inner summation is a function of the index of the outer one, rather than varying independently.

     The global variable genindex is the alphabetic prefix used to generate the next index of summation, when an automatically generated index is needed.

     gensumnum is the numeric suffix used to generate the next index of summation, when an automatically generated index is needed. When gensumnum is false, an automatically-generated index is only genindex with no numeric suffix.

     See also lsum sumcontract intosum bashindices niceindices nouns evflag and zeilberger-pkg

     Examples:

          (%i1) sum (i^2, i, 1, 7);
          (%o1)                          140
          (%i2) sum (a[i], i, 1, 7);
          (%o2)           a  + a  + a  + a  + a  + a  + a
                           7    6    5    4    3    2    1
          (%i3) sum (a(i), i, 1, 7);
          (%o3)    a(7) + a(6) + a(5) + a(4) + a(3) + a(2) + a(1)
          (%i4) sum (a(i), i, 1, n);
                                      n
                                     ====
                                     \
          (%o4)                       >    a(i)
                                     /
                                     ====
                                     i = 1
          (%i5) sum (2^i + i^2, i, 0, n);
                                    n
                                   ====
                                   \       i    2
          (%o5)                     >    (2  + i )
                                   /
                                   ====
                                   i = 0
          (%i6) sum (2^i + i^2, i, 0, n), simpsum;
                                        3      2
                             n + 1   2 n  + 3 n  + n
          (%o6)             2      + --------------- - 1
                                            6
          (%i7) sum (1/3^i, i, 1, inf);
                                      inf
                                      ====
                                      \     1
          (%o7)                        >    --
                                      /      i
                                      ====  3
                                      i = 1
          (%i8) sum (1/3^i, i, 1, inf), simpsum;
                                          1
          (%o8)                           -
                                          2
          (%i9) sum (i^2, i, 1, 4) * sum (1/i^2, i, 1, inf);
                                        inf
                                        ====
                                        \     1
          (%o9)                      30  >    --
                                        /      2
                                        ====  i
                                        i = 1
          (%i10) sum (i^2, i, 1, 4) * sum (1/i^2, i, 1, inf), simpsum;
                                            2
          (%o10)                       5 %pi
          (%i11) sum (integrate (x^k, x, 0, 1), k, 1, n);
                                      n
                                     ====
                                     \       1
          (%o11)                      >    -----
                                     /     k + 1
                                     ====
                                     k = 1
          (%i12) sum (if k <= 5 then a^k else b^k, k, 1, 10);
                    10    9    8    7    6    5    4    3    2
          (%o12)   b   + b  + b  + b  + b  + a  + a  + a  + a  + a

     Categories: Sums and products

 -- Function: sumcontract (EXPR)

     Combines all sums of an addition that have upper and lower bounds that differ by constants.  The result is an expression containing one summation for each set of such summations added to all appropriate extra terms that had to be extracted to form this sum.  sumcontract combines all compatible sums and uses one of the indices from one of the sums if it can, and then try to form a reasonable index if it cannot use any supplied.

     It may be necessary to do an intosum (EXPR) before the sumcontract.

     Categories: Sums and products

 -- Option variable: sumexpand
     Default value: false

     When sumexpand is true, products of sums and exponentiated sums simplify to nested sums.

     See also cauchysum

     Examples:

          (%i1) sumexpand: true$
          (%i2) sum (f (i), i, 0, m) * sum (g (j), j, 0, n);

                               m      n
                              ====   ====
                              \      \
          (%o2)                >      >     f(i1) g(i2)
                              /      /
                              ====   ====
                              i1 = 0 i2 = 0

          (%i3) sum (f (i), i, 0, m)^2;
                               m      m
                              ====   ====
                              \      \
          (%o3)                >      >     f(i3) f(i4)
                              /      /
                              ====   ====
                              i3 = 0 i4 = 0

     Categories: Sums and products Simplification flags and variables

Introduction to Series
======================

Maxima contains functions taylor and powerseries for finding the series of differentiable functions.  It also has tools such as nusum capable of finding the closed form of some series.  Operations such as addition and multiplication work as usual on series.  This section presents the global variables which control the expansion.

Functions and Variables for Series
==================================

 -- Option variable: cauchysum
     Default value: false

     When multiplying together sums with inf as their upper limit, if sumexpand is true and cauchysum is true then the Cauchy product will be used rather than the usual product. In the Cauchy product the index of the inner summation is a function of the index of the outer one rather than varying independently.

     Example:

          (%i1) sumexpand: false$
          (%i2) cauchysum: false$

          (%i3) s: sum (f(i), i, 0, inf) * sum (g(j), j, 0, inf);
                                inf         inf
                                ====        ====
                                \           \
          (%o3)                ( >    f(i))  >    g(j)
                                /           /
                                ====        ====
                                i = 0       j = 0

          (%i4) sumexpand: true$
          (%i5) cauchysum: true$

          (%i6) expand(s,0,0);
                           inf     i1
                           ====   ====
                           \      \
          (%o6)             >      >     g(i1 - i2) f(i2)
                           /      /
                           ====   ====
                           i1 = 0 i2 = 0

     Categories: Sums and products

 -- Function: deftaylor (F_1(X_1), EXPR_1, ..., F_N(X_N), EXPR_N)

     For each function F_I of one variable X_I, deftaylor defines EXPR_I as the Taylor series about zero. EXPR_I is typically a polynomial in X_I or a summation; more general expressions are accepted by deftaylor without complaint.

     powerseries (F_I(X_I), X_I, 0) returns the series defined by deftaylor.

     deftaylor returns a list of the functions F_1, ..., F_N. deftaylor evaluates its arguments.

     Example:

          (%i1) deftaylor (f(x), x^2 + sum(x^i/(2^i*i!^2), i, 4, inf));
          (%o1)                          [f]
          (%i2) powerseries (f(x), x, 0);
                                inf
                                ====      i1
                                \        x         2
          (%o2)                  >     -------- + x
                                /       i1    2
                                ====   2   i1!
                                i1 = 4
          (%i3) taylor (exp (sqrt (f(x))), x, 0, 4);
                                2         3          4
                               x    3073 x    12817 x
          (%o3)/T/     1 + x + -- + ------- + -------- + . . .
                               2     18432     307200

     Categories: Power series

 -- Option variable: maxtayorder
     Default value: true

     When maxtayorder is true, then during algebraic manipulation of (truncated) Taylor series, taylor tries to retain as many terms as are known to be correct.

     Categories: Power series

 -- Function: niceindices (EXPR)

     Renames the indices of sums and products in EXPR.  niceindices attempts to rename each index to the value of niceindicespref[1], unless that name appears in the summand or multiplicand, in which case niceindices tries the succeeding elements of niceindicespref in turn, until an unused variable is found.  If the entire list is exhausted, additional indices are constructed by appending integers to the value of niceindicespref[1], e.g., i0, i1, i2, ...

     niceindices returns an expression. niceindices evaluates its argument.

     Example:

          (%i1) niceindicespref;
          (%o1)                  [i, j, k, l, m, n]
          (%i2) product (sum (f (foo + i*j*bar), foo, 1, inf), bar, 1, inf);
                           inf    inf
                          /===\   ====
                           ! !    \
          (%o2)            ! !     >      f(bar i j + foo)
                           ! !    /
                          bar = 1 ====
                                  foo = 1
          (%i3) niceindices (%);

                               inf  inf
                              /===\ ====
                               ! !  \
          (%o3)                ! !   >    f(i j l + k)
                               ! !  /
                              l = 1 ====
                                    k = 1

     Categories: Sums and products

 -- Option variable: niceindicespref
     Default value: [i, j, k, l, m, n]

     niceindicespref is the list from which niceindices takes the names of indices for sums and products.

     The elements of niceindicespref are must be names of simple variables.

     Example:

          (%i1) niceindicespref: [p, q, r, s, t, u]$
          (%i2) product (sum (f (foo + i*j*bar), foo, 1, inf), bar, 1, inf);
                           inf    inf
                          /===\   ====
                           ! !    \
          (%o2)            ! !     >      f(bar i j + foo)
                           ! !    /
                          bar = 1 ====
                                  foo = 1
          (%i3) niceindices (%);
                               inf  inf
                              /===\ ====
                               ! !  \
          (%o3)                ! !   >    f(i j q + p)
                               ! !  /
                              q = 1 ====
                                    p = 1

     Categories: Sums and products

 -- Function: nusum (EXPR, X, I_0, I_1)

     Carries out indefinite hypergeometric summation of EXPR with respect to X using a decision procedure due to R.W. Gosper. EXPR and the result must be expressible as products of integer powers, factorials, binomials, and rational functions.

     The terms "definite" and "indefinite summation" are used analogously to "definite" and "indefinite integration". To sum indefinitely means to give a symbolic result for the sum over intervals of variable length, not just e.g. 0 to inf.  Thus, since there is no formula for the general partial sum of the binomial series, nusum can't do it.

     nusum and unsum know a little about sums and differences of finite products.  See also unsum

     Examples:

          (%i1) nusum (n*n!, n, 0, n);

          Dependent equations eliminated:  (1)
          (%o1)                     (n + 1)! - 1
          (%i2) nusum (n^4*4^n/binomial(2*n,n), n, 0, n);
                               4        3       2              n
                2 (n + 1) (63 n  + 112 n  + 18 n  - 22 n + 3) 4      2
          (%o2) ------------------------------------------------ - ------
                              693 binomial(2 n, n)                 3 11 7
          (%i3) unsum (%, n);
                                        4  n
                                       n  4
          (%o3)                   ----------------
                                  binomial(2 n, n)
          (%i4) unsum (prod (i^2, i, 1, n), n);
                              n - 1
                              /===\
                               ! !   2
          (%o4)              ( ! !  i ) (n - 1) (n + 1)
                               ! !
                              i = 1
          (%i5) nusum (%, n, 1, n);

          Dependent equations eliminated:  (2 3)
                                      n
                                    /===\
                                     ! !   2
          (%o5)                      ! !  i  - 1
                                     ! !
                                    i = 1

     Categories: Sums and products

 -- Function: pade (TAYLOR_SERIES, NUMER_DEG_BOUND, DENOM_DEG_BOUND)

     Returns a list of all rational functions which have the given Taylor series expansion where the sum of the degrees of the numerator and the denominator is less than or equal to the truncation level of the power series, i.e. are "best" approximants, and which additionally satisfy the specified degree bounds.

     TAYLOR_SERIES is an univariate Taylor series. NUMER_DEG_BOUND and DENOM_DEG_BOUND are positive integers specifying degree bounds on the numerator and denominator.

     TAYLOR_SERIES can also be a Laurent series, and the degree bounds can be inf which causes all rational functions whose total degree is less than or equal to the length of the power series to be returned.  Total degree is defined as NUMER_DEG_BOUND + DENOM_DEG_BOUND. Length of a power series is defined as "truncation level" + 1 - min(0, "order of series").

          (%i1) taylor (1 + x + x^2 + x^3, x, 0, 3);
                                        2    3
          (%o1)/T/             1 + x + x  + x  + . . .
          (%i2) pade (%, 1, 1);
                                           1
          (%o2)                       [- -----]
                                         x - 1
          (%i3) t: taylor(-(83787*x^10 - 45552*x^9 - 187296*x^8
                             + 387072*x^7 + 86016*x^6 - 1507328*x^5
                             + 1966080*x^4 + 4194304*x^3 - 25165824*x^2
                             + 67108864*x - 134217728)
                 /134217728, x, 0, 10);
                              2    3       4       5       6        7
                       x   3 x    x    15 x    23 x    21 x    189 x
          (%o3)/T/ 1 - - + ---- - -- - ----- + ----- - ----- - ------
                       2    16    32   1024    2048    32768   65536

                                            8         9          10
                                      5853 x    2847 x    83787 x
                                    + ------- + ------- - --------- + . . .
                                      4194304   8388608   134217728
          (%i4) pade (t, 4, 4);
          (%o4)                          []

     There is no rational function of degree 4 numerator/denominator, with this power series expansion.  You must in general have degree of the numerator and degree of the denominator adding up to at least the degree of the power series, in order to have enough unknown coefficients to solve.

          (%i5) pade (t, 5, 5);
                               5                4                 3
          (%o5) [- (520256329 x  - 96719020632 x  - 489651410240 x

                            2
           - 1619100813312 x  - 2176885157888 x - 2386516803584)

                         5                 4                  3
          /(47041365435 x  + 381702613848 x  + 1360678489152 x

                            2
           + 2856700692480 x  + 3370143559680 x + 2386516803584)]

     Categories: Power series

 -- Function: powerseries (EXPR, X, A)

     Returns the general form of the power series expansion for EXPR in the variable X about the point A (which may be inf for infinity):

                     inf
                     ====
                     \               n
                      >    b  (x - a)
                     /      n
                     ====
                     n = 0

     If powerseries is unable to expand EXPR, taylor may give the first several terms of the series.

     When verbose is true, powerseries prints progress messages.

          (%i1) verbose: true$
          (%i2) powerseries (log(sin(x)/x), x, 0);
          can't expand
                                           log(sin(x))
          so we'll try again after applying the rule:
                                                  d
                                                / -- (sin(x))
                                                [ dx
                                  log(sin(x)) = i ----------- dx
                                                ]   sin(x)
                                                /
          in the first simplification we have returned:
                                       /
                                       [
                                       i cot(x) dx - log(x)
                                       ]
                                       /
                              inf
                              ====        i1  2 i1             2 i1
                              \      (- 1)   2     bern(2 i1) x
                               >     ------------------------------
                              /                i1 (2 i1)!
                              ====
                              i1 = 1
          (%o2)                -------------------------------------
                                                2

     Categories: Power series

 -- Option variable: psexpand
     Default value: false

     When psexpand is true, an extended rational function expression is displayed fully expanded. The switch ratexpand has the same effect.

     When psexpand is false, a multivariate expression is displayed just as in the rational function package.

     When psexpand is  multi, then terms with the same total degree in the variables are grouped together.

     Categories: Display flags and variables

 -- Function: revert (EXPR, X)
 -- Function: revert2 (EXPR, X, N)

     These functions return the reversion of EXPR, a Taylor series about zero in the variable X.  revert returns a polynomial of degree equal to the highest power in EXPR.  revert2 returns a polynomial of degree N, which may be greater than, equal to, or less than the degree of EXPR.

     load ("revert") loads these functions.

     Examples:

          (%i1) load ("revert")$
          (%i2) t: taylor (exp(x) - 1, x, 0, 6);
                             2    3    4    5     6
                            x    x    x    x     x
          (%o2)/T/      x + -- + -- + -- + --- + --- + . . .
                            2    6    24   120   720
          (%i3) revert (t, x);
                         6       5       4       3       2
                     10 x  - 12 x  + 15 x  - 20 x  + 30 x  - 60 x
          (%o3)/R/ - --------------------------------------------
                                          60
          (%i4) ratexpand (%);
                               6    5    4    3    2
                              x    x    x    x    x
          (%o4)             - -- + -- - -- + -- - -- + x
                              6    5    4    3    2
          (%i5) taylor (log(x+1), x, 0, 6);
                              2    3    4    5    6
                             x    x    x    x    x
          (%o5)/T/       x - -- + -- - -- + -- - -- + . . .
                             2    3    4    5    6
          (%i6) ratsimp (revert (t, x) - taylor (log(x+1), x, 0, 6));
          (%o6)                           0
          (%i7) revert2 (t, x, 4);
                                    4    3    2
                                   x    x    x
          (%o7)                  - -- + -- - -- + x
                                   4    3    2

     Categories: Power series

 -- Function: taylor
     taylor (EXPR, X, A, N)
     taylor (EXPR, [X_1, X_2, ...], A, N)
     taylor (EXPR, [X, A, N, 'asymp])
     taylor (EXPR, [X_1, X_2, ...], [A_1, A_2, ...], [N_1, N_2, ...])
     taylor (EXPR, [X_1, A_1, N_1], [X_2, A_2, N_2], ...)

     taylor (EXPR, X, A, N) expands the expression EXPR in a truncated Taylor or Laurent series in the variable X around the point A, containing terms through (X - A)^N.

     If EXPR is of the form F(X)/G(X) and G(X) has no terms up to degree N then taylor attempts to expand G(X) up to degree 2 N. If there are still no nonzero terms, taylor doubles the degree of the expansion of G(X) so long as the degree of the expansion is less than or equal to N 2^taylordepth.

     taylor (EXPR, [X_1, X_2, ...], A, N) returns a truncated power series of degree N in all variables X_1, X_2, ... about the point (A, A, ...).

     taylor (EXPR, [X_1, A_1, N_1], [X_2, A_2, N_2], ...) returns a truncated power series in the variables X_1, X_2, ... about the point (A_1, A_2, ...), truncated at N_1, N_2, ...

     taylor (EXPR, [X_1, X_2, ...], [A_1, A_2, ...], [N_1, N_2, ...]) returns a truncated power series in the variables X_1, X_2, ... about the point (A_1, A_2, ...), truncated at N_1, N_2, ...

     taylor (EXPR, [X, A, N, 'asymp]) returns an expansion of EXPR in negative powers of X - A. The highest order term is (X - A)^-N.

     When maxtayorder is true, then during algebraic manipulation of (truncated) Taylor series, taylor tries to retain as many terms as are known to be correct.

     When psexpand is true, an extended rational function expression is displayed fully expanded. The switch ratexpand has the same effect. When psexpand is false, a multivariate expression is displayed just as in the rational function package. When psexpand is  multi, then terms with the same total degree in the variables are grouped together.

     See also the taylor_logexpand switch for controlling expansion.

     Examples:

          (%i1) taylor (sqrt (sin(x) + a*x + 1), x, 0, 3);
                                     2             2
                       (a + 1) x   (a  + 2 a + 1) x
          (%o1)/T/ 1 + --------- - -----------------
                           2               8

                                             3      2             3
                                         (3 a  + 9 a  + 9 a - 1) x
                                       + -------------------------- + . . .
                                                     48
          (%i2) %^2;
                                              3
                                             x
          (%o2)/T/           1 + (a + 1) x - -- + . . .
                                             6
          (%i3) taylor (sqrt (x + 1), x, 0, 5);
                                 2    3      4      5
                            x   x    x    5 x    7 x
          (%o3)/T/      1 + - - -- + -- - ---- + ---- + . . .
                            2   8    16   128    256
          (%i4) %^2;
          (%o4)/T/                  1 + x + . . .
          (%i5) product ((1 + x^i)^2.5, i, 1, inf)/(1 + x^2);

                                   inf
                                  /===\
                                   ! !    i     2.5
                                   ! !  (x  + 1)
                                   ! !
                                  i = 1
          (%o5)                   -----------------
                                        2
                                       x  + 1

          (%i6) ev (taylor(%, x,  0, 3), keepfloat);
                                         2           3
          (%o6)/T/    1 + 2.5 x + 3.375 x  + 6.5625 x  + . . .
          (%i7) taylor (1/log (x + 1), x, 0, 3);
                                         2       3
                           1   1   x    x    19 x
          (%o7)/T/         - + - - -- + -- - ----- + . . .
                           x   2   12   24    720
          (%i8) taylor (cos(x) - sec(x), x, 0, 5);
                                          4
                                     2   x
          (%o8)/T/                - x  - -- + . . .
                                         6
          (%i9) taylor ((cos(x) - sec(x))^3, x, 0, 5);
          (%o9)/T/                    0 + . . .
          (%i10) taylor (1/(cos(x) - sec(x))^3, x, 0, 5);
                                                         2          4
                      1     1       11      347    6767 x    15377 x
          (%o10)/T/ - -- + ---- + ------ - ----- - ------- - --------
                       6      4        2   15120   604800    7983360
                      x    2 x    120 x

                                                                    + . . .
          (%i11) taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6);
                         2  2       4      2   4
                        k  x    (3 k  - 4 k ) x
          (%o11)/T/ 1 - ----- - ----------------
                          2            24

                                              6       4       2   6
                                         (45 k  - 60 k  + 16 k ) x
                                       - -------------------------- + . . .
                                                    720
          (%i12) taylor ((x + 1)^n, x, 0, 4);

                                2       2     3      2         3
                              (n  - n) x    (n  - 3 n  + 2 n) x
          (%o12)/T/ 1 + n x + ----------- + --------------------
                                   2                 6

                                         4      3       2         4
                                       (n  - 6 n  + 11 n  - 6 n) x
                                     + ---------------------------- + . . .
                                                    24

          (%i13) taylor (sin (y + x), x, 0, 3, y, 0, 3);
                         3                 2
                        y                 y
          (%o13)/T/ y - -- + . . . + (1 - -- + . . .) x
                        6                 2

                              3                       2
                         y   y            2      1   y            3
                    + (- - + -- + . . .) x  + (- - + -- + . . .) x  + . . .
                         2   12                  6   12
          (%i14) taylor (sin (y + x), [x, y], 0, 3);
                               3        2      2      3
                              x  + 3 y x  + 3 y  x + y
          (%o14)/T/   y + x - ------------------------- + . . .
                                          6
          (%i15) taylor (1/sin (y + x), x, 0, 3, y, 0, 3);
                    1   y              1    1               1            2
          (%o15)/T/ - + - + . . . + (- -- + - + . . .) x + (-- + . . .) x
                    y   6               2   6                3
                                       y                    y

                                                     1            3
                                                + (- -- + . . .) x  + . . .
                                                      4
                                                     y
          (%i16) taylor (1/sin (y + x), [x, y], 0, 3);
                                       3         2       2        3
                      1     x + y   7 x  + 21 y x  + 21 y  x + 7 y
          (%o16)/T/ ----- + ----- + ------------------------------- + . . .
                    x + y     6                   360

     Categories: Power series

 -- Option variable: taylordepth
     Default value: 3

     If there are still no nonzero terms, taylor doubles the degree of the expansion of G(X) so long as the degree of the expansion is less than or equal to N 2^taylordepth.

     Categories: Power series

 -- Function: taylorinfo (EXPR)

     Returns information about the Taylor series EXPR. The return value is a list of lists. Each list comprises the name of a variable, the point of expansion, and the degree of the expansion.

     taylorinfo returns false if EXPR is not a Taylor series.

     Example:

          (%i1) taylor ((1 - y^2)/(1 - x), x, 0, 3, [y, a, inf]);
                            2                       2
          (%o1)/T/ - (y - a)  - 2 a (y - a) + (1 - a )

                   2                        2
           + (1 - a  - 2 a (y - a) - (y - a) ) x

                   2                        2   2
           + (1 - a  - 2 a (y - a) - (y - a) ) x

                   2                        2   3
           + (1 - a  - 2 a (y - a) - (y - a) ) x  + . . .
          (%i2) taylorinfo(%);
          (%o2)               [[y, a, inf], [x, 0, 3]]

     Categories: Power series

 -- Function: taylorp (EXPR)

     Returns true if EXPR is a Taylor series, and false otherwise.

     Categories: Predicate functions Power series

 -- Option variable: taylor_logexpand
     Default value: true

     taylor_logexpand controls expansions of logarithms in taylor series.

     When taylor_logexpand is true, all logarithms are expanded fully so that zero-recognition problems involving logarithmic identities do not disturb the expansion process.  However, this scheme is not always mathematically correct since it ignores branch information.

     When taylor_logexpand is set to false, then the only expansion of logarithms that occur is that necessary to obtain a formal power series.

     Categories: Power series Exponential and logarithm functions

 -- Option variable: taylor_order_coefficients
     Default value: true

     taylor_order_coefficients controls the ordering of coefficients in a Taylor series.

     When taylor_order_coefficients is true, coefficients of taylor series are ordered canonically.

     Categories: Power series

 -- Function: taylor_simplifier (EXPR)

     Simplifies coefficients of the power series EXPR. taylor calls this function.

     Categories: Power series

 -- Option variable: taylor_truncate_polynomials
     Default value: true

     When taylor_truncate_polynomials is true, polynomials are truncated based upon the input truncation levels.

     Otherwise, polynomials input to taylor are considered to have infinite precision.

     Categories: Power series

 -- Function: taytorat (EXPR)

     Converts EXPR from taylor form to canonical rational expression (CRE) form.  The effect is the same as rat (ratdisrep (EXPR)), but faster.

     Categories: Power series Rational expressions

 -- Function: trunc (EXPR)

     Annotates the internal representation of the general expression EXPR so that it is displayed as if its sums were truncated Taylor series. EXPR is not otherwise modified.

     Example:

          (%i1) expr: x^2 + x + 1;
                                      2
          (%o1)                      x  + x + 1
          (%i2) trunc (expr);
                                          2
          (%o2)                  1 + x + x  + . . .
          (%i3) is (expr = trunc (expr));
          (%o3)                         true

     Categories: Power series

 -- Function: unsum (F, N)

     Returns the first backward difference F(N) - F(N - 1). Thus unsum in a sense is the inverse of sum.

     See also nusum

     Examples:

          (%i1) g(p) := p*4^n/binomial(2*n,n);
                                               n
                                            p 4
          (%o1)               g(p) := ----------------
                                      binomial(2 n, n)
          (%i2) g(n^4);
                                        4  n
                                       n  4
          (%o2)                   ----------------
                                  binomial(2 n, n)
          (%i3) nusum (%, n, 0, n);
                               4        3       2              n
                2 (n + 1) (63 n  + 112 n  + 18 n  - 22 n + 3) 4      2
          (%o3) ------------------------------------------------ - ------
                              693 binomial(2 n, n)                 3 11 7
          (%i4) unsum (%, n);
                                        4  n
                                       n  4
          (%o4)                   ----------------
                                  binomial(2 n, n)

     Categories: Sums and products

 -- Option variable: verbose
     Default value: false

     When verbose is true, powerseries prints progress messages.

     Categories: Power series

Introduction to Fourier series
==============================

The fourie package comprises functions for the symbolic computation of Fourier series. There are functions in the fourie package to calculate Fourier integral coefficients and some functions for manipulation of expressions.

Categories: Fourier transform Share packages Package fourie

Functions and Variables for Fourier series
==========================================

 -- Function: equalp (X, Y)

     Returns true if equal (X, Y) otherwise false (doesn't give an error message like equal (x, y) would do in this case).

     Categories: Package fourie

 -- Function: remfun
     remfun (F, EXPR)
     remfun (F, EXPR, X)

     remfun (F, EXPR) replaces all occurrences of F (ARG) by ARG in EXPR.

     remfun (F, EXPR, X) replaces all occurrences of F (ARG) by ARG in EXPR only if ARG contains the variable X.

     Categories: Package fourie

 -- Function: funp
     funp (F, EXPR)
     funp (F, EXPR, X)

     funp (F, EXPR) returns true if EXPR contains the function F.

     funp (F, EXPR, X) returns true if EXPR contains the function F and the variable X is somewhere in the argument of one of the instances of F.

     Categories: Package fourie

 -- Function: absint
     absint (F, X, HALFPLANE)
     absint (F, X)
     absint (F, X, A, B)

     absint (F, X, HALFPLANE) returns the indefinite integral of F with respect to X in the given halfplane (pos, neg, or both). F may contain expressions of the form abs (x), abs (sin (x)), abs (a) * exp (-abs (b) * abs (x)).

     absint (F, X) is equivalent to absint (F, X, pos).

     absint (F, X, A, B) returns the definite integral of F with respect to X from A to B. F may include absolute values.

     Categories: Package fourie Integral calculus

 -- Function: fourier (F, X, P)

     Returns a list of the Fourier coefficients of F(X) defined on the interval [-p, p].

     Categories: Package fourie

 -- Function: foursimp (L)

     Simplifies sin (n %pi) to 0 if sinnpiflag is true and cos (n %pi) to (-1)^n if cosnpiflag is true.

     Categories: Package fourie Trigonometric functions Simplification functions

 -- Option variable: sinnpiflag
     Default value: true

     See foursimp.

     Categories: Package fourie

 -- Option variable: cosnpiflag
     Default value: true

     See foursimp.

     Categories: Package fourie

 -- Function: fourexpand (L, X, P, LIMIT)

     Constructs and returns the Fourier series from the list of Fourier coefficients L up through LIMIT terms (LIMIT may be inf).  X and P have same meaning as in fourier.

     Categories: Package fourie

 -- Function: fourcos (F, X, P)

     Returns the Fourier cosine coefficients for F(X) defined on [0, P].

     Categories: Package fourie

 -- Function: foursin (F, X, P)

     Returns the Fourier sine coefficients for F(X) defined on [0, P].

     Categories: Package fourie

 -- Function: totalfourier (F, X, P)

     Returns fourexpand (foursimp (fourier (F, X, P)), X, P, 'inf).

     Categories: Package fourie

 -- Function: fourint (F, X)

     Constructs and returns a list of the Fourier integral coefficients of F(X) defined on [minf, inf].

     Categories: Package fourie

 -- Function: fourintcos (F, X)

     Returns the Fourier cosine integral coefficients for F(X) on [0, inf].

     Categories: Package fourie

 -- Function: fourintsin (F, X)

     Returns the Fourier sine integral coefficients for F(X) on [0, inf].

     Categories: Package fourie

Functions and Variables for Poisson series
==========================================

 -- Function: intopois (A)
     Converts A into a Poisson encoding.

     Categories: Poisson series

 -- Function: outofpois (A)

     Converts A from Poisson encoding to general representation.  If A is not in Poisson form, outofpois carries out the conversion, i.e., the return value is outofpois (intopois (A)). This function is thus a canonical simplifier for sums of powers of sine and cosine terms of a particular type.

     Categories: Poisson series

 -- Function: poisdiff (A, B)

     Differentiates A with respect to B. B must occur only in the trig arguments or only in the coefficients.

     Categories: Poisson series

 -- Function: poisexpt (A, B)

     Functionally identical to intopois (A^B). B must be a positive integer.

     Categories: Poisson series

 -- Function: poisint (A, B)

     Integrates in a similarly restricted sense (to poisdiff).  Non-periodic terms in B are dropped if B is in the trig arguments.

     Categories: Poisson series

 -- Option variable: poislim
     Default value: 5

     poislim determines the domain of the coefficients in the arguments of the trig functions.  The initial value of 5 corresponds to the interval [-2^(5-1)+1,2^(5-1)], or [-15,16], but it can be set to [-2^(n-1)+1, 2^(n-1)].

     Categories: Poisson series

 -- Function: poismap (SERIES, SINFN, COSFN)

     will map the functions SINFN on the sine terms and COSFN on the cosine terms of the Poisson series given.  SINFN and COSFN are functions of two arguments which are a coefficient and a trigonometric part of a term in series respectively.

     Categories: Poisson series

 -- Function: poisplus (A, B)

     Is functionally identical to intopois (a + b).

     Categories: Poisson series

 -- Function: poissimp (A)

     Converts A into a Poisson series for A in general representation.

     Categories: Poisson series

 -- Special symbol: poisson

     The symbol /P/ follows the line label of Poisson series expressions.

     Categories: Poisson series

 -- Function: poissubst (A, B, C)

     Substitutes A for B in C.  C is a Poisson series.

     (1) Where B is a variable U, V, W, X, Y, or Z, then A must be an expression linear in those variables (e.g., 6*u + 4*v).

     (2) Where B is other than those variables, then A must also be free of those variables, and furthermore, free of sines or cosines.

     poissubst (A, B, C, D, N) is a special type of substitution which operates on A and B as in type (1) above, but where D is a Poisson series, expands cos(D) and sin(D) to order N so as to provide the result of substituting A + D for B in C.  The idea is that D is an expansion in terms of a small parameter.  For example, poissubst (u, v, cos(v), %e, 3) yields cos(u)*(1 - %e^2/2) - sin(u)*(%e - %e^3/6).

     Categories: Poisson series

 -- Function: poistimes (A, B)

     Is functionally identical to intopois (A*B).

     Categories: Poisson series

 -- Function: poistrim ()

     is a reserved function name which (if the user has defined it) gets applied during Poisson multiplication.  It is a predicate function of 6 arguments which are the coefficients of the U, V, ..., Z in a term.  Terms for which poistrim is true (for the coefficients of that term) are eliminated during multiplication.

     Categories: Poisson series

 -- Function: printpois (A)

     Prints a Poisson series in a readable format.  In common with outofpois, it will convert A into a Poisson encoding first, if necessary.

     Categories: Poisson series Display functions