This is maxima.info, produced by makeinfo version 6.5 from maxima.texi.

This is a Texinfo Maxima Manual

   Copyright 1994,2001 William F. Schelter

START-INFO-DIR-ENTRY
* Maxima: (maxima).     A computer algebra system.
END-INFO-DIR-ENTRY


File: maxima.info,  Node: Introduction to algebraic extensions,  Next: Functions and Variables for algebraic extensions,  Prev: Functions and Variables for Polynomials,  Up: Polynomials

11.3 Introduction to algebraic extensions
=========================================

We assume here that the fields are of characteristic 0 so that
irreductible polynomials have simple roots (are separable, thus square
free).  The base fields K of interest are the field Q of rational
numbers, for algebraic numbers, and the fields of rational functions on
the real numbers R or the complex numbers C, that is R(t) or C(t), when
considering algebraic functions.  An extension of degree n is defined by
an irreducible degree n polynomial p(x) with coefficients in the base
field, and consists of the quotient of the ring K[x] of polynomials by
the multiples of p(x).  So if p(x) = x^n + p_0 x^{n - 1} + ... + p_n,
each time one encounters x^n one substitutes -(p_0 x^{n - 1} + ... +
p_n).  This is a field because of Bezout’s identity, and a vector space
of dimension n over K spanned by 1, x, ..., x^{n - 1}.  When K = C(t),
this field can be identified with the field of algebraic functions on
the algebraic curve of equation p(x, t) = 0.

   In Maxima the process of taking rationals modulo p is obtained by the
function ‘tellrat’ when ‘algebraic’ is true.  The best way to ensure, in
particular when considering the case where p depends on other variables
that this simplification property is attached to x is to write (note the
polynomial must be monic): ‘tellrat(x^n = -(p_0*x^(n - 1) + ... + p_n))’
where the p_i may depend on other variables.  When one wants to remove
this tellrat property one then has to write ‘untellrat(x)’.

   In the field K[x] one may do all sorts of algebraic computations,
taking quotients, GCD of two elements, etc.  by the same algorithms as
in the usual case.  In particular one can do factorization of
polynomials on an extension, using the function ‘algfac’ below.
Moreover multiplication by an element f is a linear operation of the
vector space K[x] over K and as such has a trace and a determinant.
These are called ‘algtrace’ and ‘algnorm’ below.  One can see that the
trace of an element f(x) in K[x] is the sum of the values f(a) when a
runs over roots of p and the norm is the product of the f(a).  Both are
symmetric in the roots of p and thus belong to K.

   The field K[x] is also called the field obtained by adjoining a root
a of p(x) to K. One can similarly adjoin a second root b of another
polynomial obtaining a new extension K[a,b].  In fact there is a “prime
element” c in K[a, b] such that K[a, b] = K[c].  This is obtained by
function ‘primeelmt’ below.  Recursively one can thus adjoin any number
of elements.  In particular adjoining all the roots of p(x) to K one
gets the splitting field of p, which is the smallest extension in which
p completely splits in linear functions.  The function ‘splitfield’
constructs a primitive element of the splitting field, which in general
is of very high degree.

   The relevant concepts are explained in a concise and self-contained
way in the small books edited by Dover: “Algebraic theory of numbers,”
by Pierre Samuel, “Algebraic curves,” by Robert Walker, and the methods
presented here are described in the article “Algebraic factoring and
rational function integration” by B. Trager, _Proceedings of the 1976
AMS Symposium on Symbolic and Algebraic Computation_.


File: maxima.info,  Node: Functions and Variables for algebraic extensions,  Prev: Introduction to algebraic extensions,  Up: Polynomials

11.4 Functions and Variables for algebraic extensions
=====================================================

 -- Function: algfac (<f>, <p>)

     Returns the factorization of <f> in the field K[a].  Does the same
     as ‘factor(<f>, <p>)’ which in fact calls ‘algfac’.  One can also
     specify the variable <a> as in ‘algfac(<f>, <p>, <a>)’.

     Examples:

          (%i1) algfac(x^4 + 1, a^2 - 2);
                                     2              2
          (%o1)                    (x  - a x + 1) (x  + a x + 1)
          (%i2) algfac(x^4 - t*x^2 + 1, a^2 - t - 2, a);
                                     2              2
          (%o2)                    (x  - a x + 1) (x  + a x + 1)

     In the second example note that a = sqrt(2 + t).

 -- Function: algnorm (<f>, <p>, <a>)

     Returns the norm of the polynomial f(a) in the extension obtained
     by a root <a> of polynomial <p>.  The coefficients of <f> may
     depend on other variables.

     Examples:

          (%i1) algnorm(x*a^2 + y*a + z,a^2 - 2, a);
                                      2              2      2
          (%o1)/R/                   z  + 4 x z - 2 y  + 4 x

     The norm is also the resultant of polynomials <f> and <p>, and the
     product of the differences of the roots of <f> and <p>.

 -- Function: algtrace (<f>, <p>, <a>)

     Returns the trace of the polynomial f(a) in the extension obtained
     by a root <a> of polynomial <p>.  The coefficients of <f> may
     depend on other variables which remain “inert”.

     Example:

          (%i1) algtrace(x*a^5 + y*a^3 + z + 1, a^2 + a + 1, a);
          (%o1)/R/                       2 z + 2 y - x + 2

 -- Function: bdiscr (<args>)

     Computes the discriminant of a basis x_i in K[a] as the determinant
     of the matrix of elements trace(x_i*x_j).  The args are the
     elements of the basis followed by the minimal polynomial.

     Example:

          (%i1) bdiscr(1, x, x^2, x^3 - 2);
          (%o1)/R/                             - 108
          (%i2) poly_discriminant(x^3 - 2, x);
          (%o2)                                - 108

     A standard base in an extension of degree n is 1, x, ..., x^{n -
     1}.  In this case it is known that the discriminant of this base is
     the discriminant of the minimal polynomial.  This is checked in
     (%o2) above.

 -- Function: primelmt (<f_b>, <p_a>, <c>)

     Computes a prime element for the extension of K[a] by a root <b> of
     a polynomial f_b(b) whose coefficients may depend on <a>.  One
     assumes that <f_b> is square free.  The function returns an
     irreducible polynomial, a root of which generates K[a, b], and the
     expression of this primitive element in terms of <a> and <b>.

     Examples:

          (%i1) primelmt(b^2 - a*b - 1, a^2 - 2, c);
                                        4       2
          (%o1)                       [c  - 12 c  + 9, b + a]
          (%i2) solve(b^2 - sqrt(2)*b - 1)[1];
                                            sqrt(6) - sqrt(2)
          (%o2)                       b = - -----------------
                                                    2
          (%i3) primelmt(b^2 - 3, a^2 - 2, c);
                                        4       2
          (%o3)                       [c  - 10 c  + 1, b + a]
          (%i4) factor(c^4 - 12*c^2 + 9, a^4 - 10*a^2 + 1);
                           3    2                       3    2
          (%o4) ((4 c - 3 a  - a  + 27 a + 5) (4 c - 3 a  + a  + 27 a - 5)
                                     3    2                       3    2
                           (4 c + 3 a  - a  - 27 a + 5) (4 c + 3 a  + a  - 27 a - 5))/256
          (%i5) primelmt(b^3 - 3, a^2 - 2, c);
                             6      4      3       2
          (%o5)            [c  - 6 c  - 6 c  + 12 c  - 36 c + 1, b + a]
          (%i6) factor(b^3 - 3, %[1]);
                      5       4        3        2
          (%o6) ((48 c  + 27 c  - 320 c  - 468 c  + 124 c + 755 b - 1092)
                     5        5         4       4          3        3          2        2
           ((- 48 b c ) - 54 c  - 27 b c  + 64 c  + 320 b c  + 360 c  + 468 b c  + 149 c
                                     2
           - 124 b c - 1272 c + 755 b  + 1092 b + 1606))/570025

     In (%o1), <f_b> depends on ‘a’.  Using ‘solve’, the solution
     depends on sqrt(2) and sqrt(3).  In (%o3), K[sqrt(2), sqrt(3)] is
     computed, and we see that the the primitive polynomial in (%o1)
     factorizes completely here.  In (%i5), we compute K[sqrt(2),
     3^{1/3}], and we see that ‘b^3 - 3’ gets one factor in this
     extension.  If we assume this extension is real, the two other
     factors are complex.

 -- Function: splitfield (<p>, <x>)

     Computes the splitting field of the polynomial p(x).  In the
     generic case it is of degree n! in terms of the degree n of <p>,
     but may be of lower order if the Galois group of <p> is a strict
     subgroup of the group of permutations of n elements.  The function
     returns a primitive polynomial for this extension and the
     expressions of the roots of <p> as polynomials of a root of this
     primitive polynomial.  The polynomial <f> may be irreducible or
     factorizable.

     Examples:

          (%i1) splitfield(x^3 + x + 1, x);
                                                        4         2
                        6         4         2       alg1  + 5 alg1  - 9 alg1 + 4
          (%o1)/R/ [alg1  + 6 alg1  + 9 alg1  + 31, ----------------------------,
                                                                 18
                                           4         2          4         2
                                       alg1  + 5 alg1  + 4  alg1  + 5 alg1  + 9 alg1 + 4
                                     - -------------------, ----------------------------]
                                                9                        18
          (%i2) splitfield(x^4 + 10*x^2 - 96*x - 71, x)[1];
                       8           6           5            4             3
          (%o2)/R/ alg2  + 148 alg2  - 576 alg2  + 9814 alg2  - 42624 alg2
                                                              2
                                                 + 502260 alg2  + 1109952 alg2 + 18860337

     In the first case we have the primitive polynomial of degree 6 and
     the 3 roots of the third degree equations in terms of a variable
     ‘alg1’ produced by the system.  In the second case the primitive
     polynomial is of degree 8 instead of 24, because the Galois group
     of the equation is reduced to D8 since there are relations between
     the roots.


File: maxima.info,  Node: Константы,  Next: Тригонометрия,  Prev: Polynomials,  Up: Top

12 Константы
************

* Menu:

* Математические константы::


File: maxima.info,  Node: Математические константы,  Prev: Константы,  Up: Константы

12.1 Математические константы
=============================

 -- Константа: %e
     ‘%e’ представляет основание натурального логарифма, также известное
     как число Эйлера.  Численное значение ‘%e’ является числом с
     плавающей точкой двойной точности 2.718281828459045d0.

 -- Константа: %i
     ‘%i’ представляет мнимую единицу, sqrt(-1).

 -- Константа: false
     ‘false’ – логическая константа "ложь".  В Maxima ‘false’
     представляется значением ‘NIL’ в Lisp.

 -- Константа: ind

     ‘ind’ представляет конечный, неопределенный результат.

     См.  также ‘limit’.

     Пример:

          (%i1) limit (sin(1/x), x, 0);
          (%o1)                          ind

 -- Константа: inf
     ‘inf’ представляет вещественную положительную бесконечность.

 -- Константа: infinity
     ‘infinity’ представляет комплексную бесконечность.

 -- Константа: minf
     ‘minf’ представляет вещественную минус (т.е.  отрицательную)
     бесконечность.

 -- Константа: %phi

     ‘%phi’ представляет так называемое золотое сечение, (1 +
     sqrt(5))/2.  Численное значение ‘%phi’ является числом с плавающей
     точкой двойной точности 1.618033988749895d0.

     ‘fibtophi’ выражает числа Фибоначчи ‘fib(n)’ в терминах ‘%phi’.

     По умолчанию Maxima не знает алгебраические свойства ‘%phi’.  После
     выполнения ‘tellrat(%phi^2 - %phi - 1)’ и ‘algebraic: true’,
     ‘ratsimp’ может упрощать некоторые выражения, содержащие ‘%phi’.

     Примеры:

     ‘fibtophi’ выражает числа Фибоначчи ‘fib(n)’ в терминах ‘%phi’.

          (%i1) fibtophi (fib (n));
                                     n             n
                                 %phi  - (1 - %phi)
          (%o1)                  -------------------
                                     2 %phi - 1
          (%i2) fib (n-1) + fib (n) - fib (n+1);
          (%o2)          - fib(n + 1) + fib(n) + fib(n - 1)
          (%i3) fibtophi (%);
                      n + 1             n + 1       n             n
                  %phi      - (1 - %phi)        %phi  - (1 - %phi)
          (%o3) - --------------------------- + -------------------
                          2 %phi - 1                2 %phi - 1
                                                    n - 1             n - 1
                                                %phi      - (1 - %phi)
                                              + ---------------------------
                                                        2 %phi - 1
          (%i4) ratsimp (%);
          (%o4)                           0

     По умолчанию Maxima не знает алгебраические свойства ‘%phi’.  После
     выполнения ‘tellrat(%phi^2 - %phi - 1)’ и ‘algebraic: true’,
     ‘ratsimp’ может упрощать некоторые выражения, содержащие ‘%phi’.

          (%i1) e : expand ((%phi^2 - %phi - 1) * (A + 1));
                           2                      2
          (%o1)        %phi  A - %phi A - A + %phi  - %phi - 1
          (%i2) ratsimp (e);
                            2                     2
          (%o2)        (%phi  - %phi - 1) A + %phi  - %phi - 1
          (%i3) tellrat (%phi^2 - %phi - 1);
                                      2
          (%o3)                  [%phi  - %phi - 1]
          (%i4) algebraic : true;
          (%o4)                         true
          (%i5) ratsimp (e);
          (%o5)                           0

 -- Константа: %pi
     ‘%pi’ представляет отношение длины окружности к ее диаметру.
     Численное значение ‘%pi’ является числом с плавающей точкой двойной
     точности 3.141592653589793d0.

 -- Константа: true
     ‘true’ – логическая константа "истина".  В Maxima ‘true’
     представляется значением ‘T’ в Lisp.

 -- Константа: und

     ‘und’ представляет неопределенный результат.

     См.  также ‘limit’.

     Пример:

          (%i1) limit (1/x, x, 0);
          (%o1)                          und


File: maxima.info,  Node: Тригонометрия,  Next: Special Functions,  Prev: Константы,  Up: Top

13 Тригонометрия
****************

* Menu:

* Тригонометрия в Maxima::
* Функции и переменные для тригонометрии::


File: maxima.info,  Node: Тригонометрия в Maxima,  Next: Функции и переменные для тригонометрии,  Prev: Тригонометрия,  Up: Тригонометрия

13.1 Тригонометрия в Maxima
===========================

В Maxima определено много тригонометрических функций.
Запрограммированны не все тригонометрические тождества, но пользователь
может добавить большинство из них благодаря возможностям системы по
поиску совпадений с шаблонами (подстановки).  В Maxima определены
следующие тригонометрические функции ‘acos’, ‘acosh’, ‘acot’, ‘acoth’,
‘acsc’, ‘acsch’, ‘asec’, ‘asech’, ‘asin’, ‘asinh’, ‘atan’, ‘atanh’,
‘cos’, ‘cosh’, ‘cot’, ‘coth’, ‘csc’, ‘csch’, ‘sec’, ‘sech’, ‘sin’,
‘sinh’, ‘tan’ и ‘tanh’.  Для работы с тригонометрическими функциями есть
ряд особых команд, см.  ‘trigexpand’, ‘trigreduce’ и ‘trigsign’.  Два
встроенных пакета расширяют правила упрощения Maxima: ‘ntrig’ и
‘atrig1’.  Для подробностей запустите ‘describe(<command>)’.


File: maxima.info,  Node: Функции и переменные для тригонометрии,  Prev: Тригонометрия в Maxima,  Up: Тригонометрия

13.2 Функции и переменные для тригонометрии
===========================================

 -- Управляющая переменная: %piargs
     Значение по умолчанию: ‘true’

     Если ‘%piargs’ равно ‘true’, то тригонометрические функции
     упрощаются до алгебраических констант, если аргумент кратен %pi,
     %pi/2, %pi/3, %pi/4 или %pi/6.

     Maxima использует некоторые тождества, применимые, если %pi
     домножается на целую переменную (символ, определенный как целое
     число).

     Примеры:

          (%i1) %piargs : false;
          (%o1)                         false
          (%i2) [sin (%pi), sin (%pi/2), sin (%pi/3)];
                                          %pi       %pi
          (%o2)            [sin(%pi), sin(---), sin(---)]
                                           2         3
          (%i3) [sin (%pi/4), sin (%pi/5), sin (%pi/6)];
                                %pi       %pi       %pi
          (%o3)            [sin(---), sin(---), sin(---)]
                                 4         5         6
          (%i4) %piargs : true;
          (%o4)                         true
          (%i5) [sin (%pi), sin (%pi/2), sin (%pi/3)];
                                          sqrt(3)
          (%o5)                    [0, 1, -------]
                                             2
          (%i6) [sin (%pi/4), sin (%pi/5), sin (%pi/6)];
                                   1         %pi   1
          (%o6)                [-------, sin(---), -]
                                sqrt(2)       5    2
          (%i7) [cos (%pi/3), cos (10*%pi/3), tan (10*%pi/3), cos (sqrt(2)*%pi/3)];
                          1    1               sqrt(2) %pi
          (%o7)          [-, - -, sqrt(3), cos(-----------)]
                          2    2                    3

     Некоторые тождества применяются, если ‘%pi’ и ‘%pi/2’ домножается
     на целую переменную (символ, определенный как целое число):

          (%i1) declare (n, integer, m, even);
          (%o1)                         done
          (%i2) [sin (%pi * n), cos (%pi * m), sin (%pi/2 * m), cos (%pi/2 * m)];
                                                m/2
          (%o2)                  [0, 1, 0, (- 1)   ]

 -- Управляющая переменная: %iargs
     Значение по умолчанию: ‘true’

     Если ‘%iargs’ равно ‘true’, то тригонометрические функции
     упрощаются до гиперболических, если аргумент явно домножается на
     мнимую единицу %i.

     Упрощение производится, даже если аргумент явно является
     вещественным; Maxima лишь проверяет, просматривается ли явно в
     аргументе множитель %i.

     Примеры:

          (%i1) %iargs : false;
          (%o1)                         false
          (%i2) [sin (%i * x), cos (%i * x), tan (%i * x)];
          (%o2)           [sin(%i x), cos(%i x), tan(%i x)]
          (%i3) %iargs : true;
          (%o3)                         true
          (%i4) [sin (%i * x), cos (%i * x), tan (%i * x)];
          (%o4)           [%i sinh(x), cosh(x), %i tanh(x)]

     Упрощение проводится, даже если аргумент явно является
     вещественным:

          (%i1) declare (x, imaginary);
          (%o1)                         done
          (%i2) [featurep (x, imaginary), featurep (x, real)];
          (%o2)                     [true, false]
          (%i3) sin (%i * x);
          (%o3)                      %i sinh(x)

 -- Функция: acos (<x>)
     - Арккосинус.

 -- Функция: acosh (<x>)
     - Ареакосинус (гиперболический арккосинус).

 -- Функция: acot (<x>)
     - Арккотангенс.

 -- Функция: acoth (<x>)
     - Ареакотангенс (гиперболический арккотангенс).

 -- Функция: acsc (<x>)
     - Арккосеканс.

 -- Функция: acsch (<x>)
     - Ареакосеканс (гиперболический арккосеканс).

 -- Функция: asec (<x>)
     - Арксеканс.

 -- Функция: asech (<x>)
     - Ареасеканс (гиперболический арксеканс).

 -- Функция: asin (<x>)
     - Арксинус.

 -- Функция: asinh (<x>)
     - Ареасинус (гиперболический арксинус).

 -- Функция: atan (<x>)
     - Арктангенс.

 -- Функция: atan2 (<y>, <x>)
     - соответствует значению ‘atan(<y>/<x>)’ на интервале (‘-%pi’,
     ‘%pi’).

 -- Функция: atanh (<x>)
     - Ареатангенс (гиперболический арктангенс).

 -- Пакет: atrig1
     Пакет ‘atrig1’ содержит несколько дополнительных правил упрощения
     для обратных тригонометрических функций.  Вместе с уже известными
     Maxima правилами, полностью реализована работа с углами ‘0’,
     ‘%pi/6’, ‘%pi/4’, ‘%pi/3’ и ‘%pi/2’, а также соответствующими
     углами в трех других четвертях.  Для использования пакета выполните
     ‘load("atrig1");’.

 -- Функция: cos (<x>)
     - Косинус.

 -- Функция: cosh (<x>)
     - Ареакосинус (гиперболический арккосинус).

 -- Функция: cot (<x>)
     - Котангенс.

 -- Функция: coth (<x>)
     - Ареакотангенс (гиперболический арккотангенс).

 -- Функция: csc (<x>)
     - Косеканс.

 -- Функция: csch (<x>)
     - Ареакосеканс (гиперболический арккосеканс).

 -- Управляющая переменная: halfangles
     Значение по умолчанию: ‘false’

     Если ‘halfangles’ равно ‘true’, то тригонометрические функции
     аргументов ‘<expr>/2’ упрощаются в функции от <expr>.

     Примеры:

          (%i1) halfangles : false;
          (%o1)                         false
          (%i2) sin (x / 2);
                                           x
          (%o2)                        sin(-)
                                           2
          (%i3) halfangles : true;
          (%o3)                         true
          (%i4) sin (x / 2);
                                  sqrt(1 - cos(x))
          (%o4)                   ----------------
                                      sqrt(2)

 -- Пакет: ntrig
     Пакет ‘ntrig’ содержит набор правил упрощения для
     тригонометрических функций с аргументами вида ‘<f>(<n> %pi/10)’,
     где <f> - одна из функций ‘sin’, ‘cos’, ‘tan’, ‘csc’, ‘sec’ и
     ‘cot’.

 -- Функция: sec (<x>)
     - Секанс.

 -- Функция: sech (<x>)
     - Гиперболический секанс.

 -- Функция: sin (<x>)
     - Синус.

 -- Функция: sinh (<x>)
     - Гиперболический синус.

 -- Функция: tan (<x>)
     - Тангенс.

 -- Функция: tanh (<x>)
     - Гиперболический тангенс.

 -- Функция: trigexpand (<expr>)
     Раскрывает тригонометрические и гиперболические функции суммы или
     произведения углов в <expr>.  Для получения лучших результатов
     нужно сначала раскрыть <expr>.  Для повышения пользовательского
     контроля за упрощением функция раскрывает только один уровень
     сумм/произведений за раз.  Для полного раскрытия в синусы и
     косинусы укажите ‘trigexpand: true’.

     ‘trigexpand’ управляется следующими глобальными флагами:

     ‘trigexpand’
          Раскрывать все получающиеся в последствии выражения с синусами
          и косинусами.
     ‘halfangles’
          Раскрывать функции половинных углов в функции полных углов.
     ‘trigexpandplus’
          Раскрывать функции сумм аргументов (например, ‘sin(x + y)’).
     ‘trigexpandtimes’
          Раскрывать функции кратных аргументов (например, ‘sin(2 x)’).

     Примеры:

          (%i1) x+sin(3*x)/sin(x),trigexpand=true,expand;
                                   2           2
          (%o1)               - sin (x) + 3 cos (x) + x
          (%i2) trigexpand(sin(10*x+y));
          (%o2)          cos(10 x) sin(y) + sin(10 x) cos(y)


 -- Управляющая переменная: trigexpandplus
     Значение по умолчанию: ‘true’

     ‘trigexpandplus’ управляет раскрытием функций от сумм аргументов в
     ‘trigexpand’ (если ‘trigexpand’ равно ‘true’, либо в функции
     ‘trigexpand’), например, ‘sin(x+y)’.  Упрощение производится,
     только если ‘trigexpandplus’ равно ‘true’.

 -- Управляющая переменная: trigexpandtimes
     Значение по умолчанию: ‘true’

     ‘trigexpandplus’ управляет раскрытием функций от произведений
     аргументов в ‘trigexpand’ (если ‘trigexpand’ равно ‘true’, либо в
     функции ‘trigexpand’), например, ‘sin(2*x)’.  Упрощение
     производится, только если ‘trigexpandtimes’ равно ‘true’.

 -- Управляющая переменная: triginverses
     Значение по умолчанию: ‘all’

     ‘triginverses’ управляет раскрытием композиций тригонометрических и
     гиперболических функций со своими обратными функциями.

     Если ‘all’, то и ‘atan(tan(<x>))’, и ‘tan(atan(<x>))’ упрощается в
     <x>.

     Если ‘true’, то упрощение ‘<arcfun>(<fun>(<x>))’ не производится.

     Если ‘false’, то ни ‘<arcfun>(<fun>(<x>))’, ни
     ‘<fun>(<arcfun>(<x>))’ не будет упрощено.

 -- Функция: trigreduce (<expr>, <x>)
 -- Функция: trigreduce (<expr>)

     Раскрывает произведения и степени ‘sin’, ‘cos’, ‘sinh’, ‘cosh’ в
     функции кратных аргументов <x>.  Также производится попытка
     исключить такие функции из знаменателей.  Если <x> не указано,
     будут использоваться все переменные из <expr>.

     См.  также ‘poissimp’.

          (%i1) trigreduce(-sin(x)^2+3*cos(x)^2+x);
                         cos(2 x)      cos(2 x)   1        1
          (%o1)          -------- + 3 (-------- + -) + x - -
                            2             2       2        2


     В некоторых простых случаях команды упрощения используют информацию
     о переменных, объявленную следующим образом:

          (%i1) declare(j, integer, e, even, o, odd)$
          (%i2) sin(x + (e + 1/2)*%pi);
          (%o2)                        cos(x)
          (%i3) sin(x + (o + 1/2)*%pi);
          (%o3)                       - cos(x)


 -- Управляющая переменная: trigsign
     Значение по умолчанию: ‘true’

     Если ‘trigsign’ равно ‘true’, допускается упрощение отрицательных
     аргументов тригонометрических функций.  Например, ‘sin(-x)’
     раскроется в ‘-sin(x)’.

 -- Функция: trigsimp (<expr>)
     Применяет тождества sin(x)^2 + cos(x)^2 = 1 и cosh(x)^2 - sinh(x)^2
     = 1 для упрощения выражений с ‘tan’, ‘sec’, и так далее, до
     выражений с ‘sin’, ‘cos’, ‘sinh’, ‘cosh’.

     Результат может упрощаться далее с ‘trigreduce’, ‘ratsimp’, и
     ‘radcan’.

     ‘demo ("trgsmp.dem")’ показывает несколько примеров для ‘trigsimp’.

 -- Функция: trigrat (<expr>)
     Возвращает канонический упрощенный квазилинейный вид
     тригонометрического выражения; <expr> - рациональная дробь с
     функциями ‘sin’, ‘cos’ или ‘tan’, аргументы которых - линейные
     формы некоторых переменных и ‘%pi/<n>’ (<n> - целое) с целыми
     коэффициентами.  Результат - упрощенная дробь с линейным числителем
     и знаменателем с ‘sin’ и ‘cos’.  Таким образом, ‘trigrat’ переходит
     к линейному виду, только если это возможно.

          (%i1) trigrat(sin(3*a)/sin(a+%pi/3));
          (%o1)            sqrt(3) sin(2 a) + cos(2 a) - 1


     Следующий пример взят из раздела 1.5.5, "Теорема Морлея", книги
     Davenport, Siret, Tournier, Calcul Formel, изд-во Masson
     (английский перевод - Addison-Wesley).

          (%i1) c: %pi/3 - a - b;
                                              %pi
          (%o1)                     - b - a + ---
                                               3
          (%i2) bc: sin(a)*sin(3*c)/sin(a+b);
                                sin(a) sin(3 b + 3 a)
          (%o2)                 ---------------------
                                     sin(b + a)
          (%i3) ba: bc, c=a, a=c$
          (%i4) ac2: ba^2 + bc^2 - 2*bc*ba*cos(b);
                   2       2
                sin (a) sin (3 b + 3 a)
          (%o4) -----------------------
                         2
                      sin (b + a)

                                                  %pi
             2 sin(a) sin(3 a) cos(b) sin(b + a - ---) sin(3 b + 3 a)
                                                   3
           - --------------------------------------------------------
                                     %pi
                             sin(a - ---) sin(b + a)
                                      3

                2         2         %pi
             sin (3 a) sin (b + a - ---)
                                     3
           + ---------------------------
                       2     %pi
                    sin (a - ---)
                              3
          (%i5) trigrat (ac2);
          (%o5) - (sqrt(3) sin(4 b + 4 a) - cos(4 b + 4 a)

           - 2 sqrt(3) sin(4 b + 2 a) + 2 cos(4 b + 2 a)

           - 2 sqrt(3) sin(2 b + 4 a) + 2 cos(2 b + 4 a)

           + 4 sqrt(3) sin(2 b + 2 a) - 8 cos(2 b + 2 a) - 4 cos(2 b - 2 a)

           + sqrt(3) sin(4 b) - cos(4 b) - 2 sqrt(3) sin(2 b) + 10 cos(2 b)

           + sqrt(3) sin(4 a) - cos(4 a) - 2 sqrt(3) sin(2 a) + 10 cos(2 a)

           - 9)/4



File: maxima.info,  Node: Special Functions,  Next: Эллиптические функции,  Prev: Тригонометрия,  Up: Top

14 Special Functions
********************

* Menu:

* Introduction to Special Functions::
* Bessel Functions::
* Airy Functions::
* Gamma and Factorial Functions::
* Exponential Integrals::
* Error Function::
* Struve Functions::
* Hypergeometric Functions::
* Parabolic Cylinder Functions::
* Functions and Variables for Special Functions::


File: maxima.info,  Node: Introduction to Special Functions,  Next: Bessel Functions,  Up: Special Functions

14.1 Introduction to Special Functions
======================================

Special function notation follows:

     bessel_j (index, expr)         Bessel function, 1st kind
     bessel_y (index, expr)         Bessel function, 2nd kind
     bessel_i (index, expr)         Modified Bessel function, 1st kind
     bessel_k (index, expr)         Modified Bessel function, 2nd kind

     hankel_1 (v,z)                 Hankel function of the 1st kind
     hankel_2 (v,z)                 Hankel function of the 2nd kind
     struve_h (v,z)                 Struve H function
     struve_l (v,z)                 Struve L function

     assoc_legendre_p[v,u] (z)      Legendre function of degree v and order u
     assoc_legendre_q[v,u] (z)      Legendre function, 2nd kind

     %f[p,q] ([], [], expr)         Generalized Hypergeometric function
     gamma (z)                      Gamma function
     gamma_incomplete_lower (a,z)   Lower incomplete gamma function
     gamma_incomplete (a,z)         Tail of incomplete gamma function
     hypergeometric (l1, l2, z)     Hypergeometric function
     %s[u,v] (z)                    Lommel "small" s function
     slommel[u,v] (z)               Lommel "big" S function
     %m[u,k] (z)                    Whittaker function, 1st kind
     %w[u,k] (z)                    Whittaker function, 2nd kind
     erfc (z)                       Complement of the erf function

     expintegral_e (v,z)            Exponential integral E
     expintegral_e1 (z)             Exponential integral E1
     expintegral_ei (z)             Exponential integral Ei
     expintegral_li (z)             Logarithmic integral Li
     expintegral_si (z)             Exponential integral Si
     expintegral_ci (z)             Exponential integral Ci
     expintegral_shi (z)            Exponential integral Shi
     expintegral_chi (z)            Exponential integral Chi

     kelliptic (z)                  Complete elliptic integral of the first
                                    kind (K)
     parabolic_cylinder_d (v,z)     Parabolic cylinder D function


File: maxima.info,  Node: Bessel Functions,  Next: Airy Functions,  Prev: Introduction to Special Functions,  Up: Special Functions

14.2 Bessel Functions
=====================

 -- Function: bessel_j (<v>, <z>)

     The Bessel function of the first kind of order v and argument z.
     See A&S eqn 9.1.10
     (https://personal.math.ubc.ca/~cbm/aands/page_360.htm) and DLMF
     10.2.E2 (https://dlmf.nist.gov/10.2.E2).

     ‘bessel_j’ is defined as

                          inf
                          ====       k  - v - 2 k  v + 2 k
                          \     (- 1)  2          z
                           >    --------------------------
                          /        k! gamma(v + k + 1)
                          ====
                          k = 0

     although the infinite series is not used for computations.

     When ‘besselexpand’ is ‘true’, ‘bessel_j’ is expanded in terms of
     elementary functions when the order v is half of an odd integer.
     See ‘besselexpand’.

 -- Function: bessel_y (<v>, <z>)

     The Bessel function of the second kind of order v and argument z.
     See A&S eqn 9.1.2
     (https://personal.math.ubc.ca/~cbm/aands/page_358.htm) and DLMF
     10.2.E3 (https://dlmf.nist.gov/10.2.E3).

     ‘bessel_y’ is defined as
                        cos(%pi v) bessel_j(v, z) - bessel_j(-v, z)
                        -------------------------------------------
                                       sin(%pi v)

     when v is not an integer.  When v is an integer n, the limit as v
     approaches n is taken.

     When ‘besselexpand’ is ‘true’, ‘bessel_y’ is expanded in terms of
     elementary functions when the order v is half of an odd integer.
     See ‘besselexpand’.

 -- Function: bessel_i (<v>, <z>)

     The modified Bessel function of the first kind of order v and
     argument z.  See A&S eqn 9.6.10
     (https://personal.math.ubc.ca/~cbm/aands/page_375.htm) and DLMF
     10.25.E2 (https://dlmf.nist.gov/10.25.E2).

     ‘bessel_i’ is defined as
                              inf
                              ====   - v - 2 k  v + 2 k
                              \     2          z
                               >    -------------------
                              /     k! gamma(v + k + 1)
                              ====
                              k = 0

     although the infinite series is not used for computations.

     When ‘besselexpand’ is ‘true’, ‘bessel_i’ is expanded in terms of
     elementary functions when the order v is half of an odd integer.
     See ‘besselexpand’.

 -- Function: bessel_k (<v>, <z>)

     The modified Bessel function of the second kind of order v and
     argument z.  See A&S eqn 9.6.2
     (https://personal.math.ubc.ca/~cbm/aands/page_375.htm) and DLMF
     10.27.E4 (https://dlmf.nist.gov/10.27.E4).

     ‘bessel_k’ is defined as
                         %pi (bessel_i(- v, z) - bessel_i(v, z))
                         ---------------------------------------
                                      2 sin(%pi v)

     when v is not an integer.  If v is an integer n, then the limit as
     v approaches n is taken.

     When ‘besselexpand’ is ‘true’, ‘bessel_k’ is expanded in terms of
     elementary functions when the order v is half of an odd integer.
     See ‘besselexpand’.

 -- Function: hankel_1 (<v>, <z>)

     The Hankel function of the first kind of order v and argument z.
     See A&S eqn 9.1.3
     (https://personal.math.ubc.ca/~cbm/aands/page_358.htm) and DLMF
     10.4.E3 (https://dlmf.nist.gov/10.4.E3).

     ‘hankel_1’ is defined as

             bessel_j(v,z) + %i * bessel_y(v,z)

     Maxima evaluates ‘hankel_1’ numerically for a complex order v and
     complex argument z in float precision.  The numerical evaluation in
     bigfloat precision is not supported.

     When ‘besselexpand’ is ‘true’, ‘hankel_1’ is expanded in terms of
     elementary functions when the order v is half of an odd integer.
     See ‘besselexpand’.

     Maxima knows the derivative of ‘hankel_1’ wrt the argument z.

     Examples:

     Numerical evaluation:

          (%i1) hankel_1(1,0.5);
          (%o1)      0.24226845767487384 - 1.4714723926702433 %i
          (%i2) hankel_1(1,0.5+%i);
          (%o2)     - 0.2558287994862166 %i - 0.23957560188301597

     Expansion of ‘hankel_1’ when ‘besselexpand’ is ‘true’:

          (%i1) hankel_1(1/2,z),besselexpand:true;
                         sqrt(2) sin(z) - sqrt(2) %i cos(z)
          (%o1)          ----------------------------------
                                 sqrt(%pi) sqrt(z)

     Derivative of ‘hankel_1’ wrt the argument z.  The derivative wrt
     the order v is not supported.  Maxima returns a noun form:

          (%i1) diff(hankel_1(v,z),z);
                       hankel_1(v - 1, z) - hankel_1(v + 1, z)
          (%o1)        ---------------------------------------
                                          2
          (%i2) diff(hankel_1(v,z),v);
                                 d
          (%o2)                  -- (hankel_1(v, z))
                                 dv

 -- Function: hankel_2 (<v>, <z>)

     The Hankel function of the second kind of order v and argument z.
     See A&S eqn 9.1.4
     (https://personal.math.ubc.ca/~cbm/aands/page_358.htm) and DLMF
     10.4.E3 (https://dlmf.nist.gov/10.4.E3).

     ‘hankel_2’ is defined as

             bessel_j(v,z) - %i * bessel_y(v,z)

     Maxima evaluates ‘hankel_2’ numerically for a complex order v and
     complex argument z in float precision.  The numerical evaluation in
     bigfloat precision is not supported.

     When ‘besselexpand’ is ‘true’, ‘hankel_2’ is expanded in terms of
     elementary functions when the order v is half of an odd integer.
     See ‘besselexpand’.

     Maxima knows the derivative of ‘hankel_2’ wrt the argument z.

     For examples see ‘hankel_1’.

 -- Option variable: besselexpand
     Default value: ‘false’

     Controls expansion of the Bessel, Hankel and Struve functions when
     the order is half of an odd integer.  In this case, the functions
     can be expanded in terms of other elementary functions.  When
     ‘besselexpand’ is ‘true’, the Bessel function is expanded.

          (%i1) besselexpand: false$
          (%i2) bessel_j (3/2, z);
                                            3
          (%o2)                    bessel_j(-, z)
                                            2
          (%i3) besselexpand: true$
          (%i4) bessel_j (3/2, z);
                                           sin(z)   cos(z)
                          sqrt(2) sqrt(z) (------ - ------)
                                              2       z
                                             z
          (%o4)           ---------------------------------
                                      sqrt(%pi)
          (%i5) bessel_y(3/2,z);
                                            sin(z)   cos(z)
                         sqrt(2) sqrt(z) (- ------ - ------)
                                              z         2
                                                       z
          (%o5)          -----------------------------------
                                      sqrt(%pi)
          (%i6) bessel_i(3/2,z);
                                          cosh(z)   sinh(z)
                         sqrt(2) sqrt(z) (------- - -------)
                                             z         2
                                                      z
          (%o6)          -----------------------------------
                                      sqrt(%pi)
          (%i7) bessel_k(3/2,z);
                                          1        - z
                               sqrt(%pi) (- + 1) %e
                                          z
          (%o7)                -----------------------
                                   sqrt(2) sqrt(z)

 -- Function: scaled_bessel_i (<v>, <z>)

     The scaled modified Bessel function of the first kind of order v
     and argument z.  That is,

     scaled_bessel_i(v,z) = exp(-abs(z)) * bessel_i(v,z).

     This function is particularly useful for calculating bessel_i for
     large z, which is large.  However, maxima does not otherwise know
     much about this function.  For symbolic work, it is probably
     preferable to work with the expression ‘exp(-abs(z))*bessel_i(v,
     z)’.

 -- Function: scaled_bessel_i0 (<z>)

     Identical to ‘scaled_bessel_i(0,z)’.

 -- Function: scaled_bessel_i1 (<z>)

     Identical to ‘scaled_bessel_i(1,z)’.

 -- Function: %s [<u>,<v>] (<z>)
     Lommel’s little s[u,v](z) function.  (DLMF 11.9.E3
     (https://dlmf.nist.gov/11.9.E3))(G&R 8.570.1).

     This Lommel function is the particular solution of the
     inhomogeneous Bessel differential equation:

     diff(w,z,2)+1/z*diff(w,z)+(1-v^2/z^2)*w = z^(u-1)

     This can be defined by the series

     %s[u,v](z) = z^(u+1)*sum((-1)^k*z^(2*k)/a[k+1](u,v)

     where

     a[k](u,v) = product(((u+2*m-1)^2-v^2),m,1,k) =
     4^k*pochhammer((u-v+1)/2,k)*pochhammer((u+v+1)/2,k)

 -- Function: slommel [<u>,<v>] (<z>)
     Lommel’s big S[u,v](z) function.  (DLMF 11.9.E5
     (https://dlmf.nist.gov/11.9.E5))(G&R 8.570.2).

     Lommels big S function is another particular solution of the
     inhomogeneous Bessel differential equation (*note %s::) defined for
     all values of u and v, where

     slommel[u,v](z) = %s[u,v](z) +
     2^(u-1)*gamma(u/2+v/2+1/2)*gamma(u/2-v/2+1/2) *
     (sin(1/2*(u-v)*%pi)*bessel_j(v,z) -
     cos(1/2*(u-v)*%pi)*bessel_y(v,z))

     When u+/-v is an odd negative integer, the limit must be used.


File: maxima.info,  Node: Airy Functions,  Next: Gamma and Factorial Functions,  Prev: Bessel Functions,  Up: Special Functions

14.3 Airy Functions
===================

The Airy functions Ai(x) and Bi(x) are defined in Abramowitz and Stegun,
Handbook of Mathematical Functions, A&S Section 10.4
(https://personal.math.ubc.ca/~cbm/aands/page_446.htm) and DLMF 9
(https://dlmf.nist.gov/9).

   The Airy differential equation is:

   diff (y(x), x, 2) - x y(x) = 0

   The numerically satisfactory pair of solutions (DLMF 9.2#T1
(https://dlmf.nist.gov/9.2#T1)) on the real line are y = Ai(x) and y =
Bi(x). These two solutions are oscillatory for x < 0.  Ai(x) is the
solution subject to the condition that y->0 as x -> +inf, and Bi(x) is
the second solution with the same amplitude as Ai(x) as x->minf which
differs in phase by %pi/2. Also, Bi(x) is unbounded as x->+inf.

   If the argument x is a real or complex floating point number, the
numerical value of the function is returned.

 -- Function: airy_ai (<x>)
     The Airy function Ai(x). See A&S eqn 10.4.2
     (https://personal.math.ubc.ca/~cbm/aands/page_446.htm) and DLMF 9
     (https://dlmf.nist.gov/9).

     See also ‘airy_bi’, ‘airy_dai’, and ‘airy_dbi’.

 -- Function: airy_dai (<x>)
     The derivative of the Airy function Ai(x):

     airy_dai(x) = diff(airy_ai(x),x)

     See ‘airy_ai’.

 -- Function: airy_bi (<x>)
     The Airy function Bi(x). See A&S eqn 10.4.3
     (https://personal.math.ubc.ca/~cbm/aands/page_446.htm) and DLMF 9
     (https://dlmf.nist.gov/9).

     See ‘airy_ai’, and ‘airy_dbi’.

 -- Function: airy_dbi (<x>)
     The derivative of the Airy function Bi(x):

     airy_dbi(x) = diff(airy_bi(x),x)

     See ‘airy_ai’, and ‘airy_bi’.


File: maxima.info,  Node: Gamma and Factorial Functions,  Next: Exponential Integrals,  Prev: Airy Functions,  Up: Special Functions

14.4 Gamma and Factorial Functions
==================================

The gamma function and the related beta, psi and incomplete gamma
functions are defined in Abramowitz and Stegun, Handbook of Mathematical
Functions, Chapter 6.

 -- Function: bffac (<expr>, <n>)

     Bigfloat version of the factorial (shifted gamma) function.  The
     second argument is how many digits to retain and return, it’s a
     good idea to request a couple of extra.

          (%i1) bffac(1/2,16);
          (%o1)                 8.862269254527584b-1
          (%i2) (1/2)!,numer;
          (%o2)                   0.886226925452758
          (%i3) bffac(1/2,32);
          (%o3)          8.862269254527580136490837416707b-1

 -- Function: bfpsi (<n>, <z>, <fpprec>)
 -- Function: bfpsi0 (<z>, <fpprec>)

     ‘bfpsi’ is the polygamma function of real argument <z> and integer
     order <n>.  See *note psi: polygamma. for further information.
     ‘bfpsi0’ is the digamma function.  ‘bfpsi0(<z>, <fpprec>)’ is
     equivalent to ‘bfpsi(0, <z>, <fpprec>)’.

     These functions return bigfloat values.  <fpprec> is the bigfloat
     precision of the return value.

          (%i1) bfpsi0(1/3, 15);
          (%o1)                 - 3.13203378002081b0
          (%i2) bfpsi0(1/3, 32);
          (%o2)         - 3.1320337800208063229964190742873b0
          (%i3) bfpsi(0,1/3,32);
          (%o3)         - 3.1320337800208063229964190742873b0
          (%i4) psi[0](1/3);
                             3 log(3)      %pi
          (%o4)            - -------- - --------- - %gamma
                                2       2 sqrt(3)
          (%i5) float(%);
          (%o5)                  - 3.132033780020806

 -- Function: cbffac (<z>, <fpprec>)
     Complex bigfloat factorial.

     ‘load ("bffac")’ loads this function.

          (%i1) cbffac(1+%i,16);
          (%o1)    3.430658398165453b-1 %i + 6.529654964201666b-1
          (%i2) (1+%i)!,numer;
          (%o2)      0.3430658398165453 %i + 0.6529654964201667

 -- Function: gamma (<z>)

     The basic definition of the gamma function (DLMF 5.2.E1
     (https://dlmf.nist.gov/5.2.E1) and A&S eqn 6.1.1
     (https://personal.math.ubc.ca/~cbm/aands/page_255.htm)) is

                                   inf
                                  /
                                  [     z - 1   - t
                       gamma(z) = I    t      %e    dt
                                  ]
                                  /
                                   0

     Maxima simplifies ‘gamma’ for positive integer and positive and
     negative rational numbers.  For half integral values the result is
     a rational number times sqrt(%pi). The simplification for integer
     values is controlled by ‘factlim’.  For integers greater than
     ‘factlim’ the numerical result of the factorial function, which is
     used to calculate ‘gamma’, will overflow.  The simplification for
     rational numbers is controlled by ‘gammalim’ to avoid internal
     overflow.  See ‘factlim’ and ‘gammalim’.

     For negative integers ‘gamma’ is not defined.

     Maxima can evaluate ‘gamma’ numerically for real and complex values
     in float and bigfloat precision.

     ‘gamma’ has mirror symmetry.

     When ‘gamma_expand’ is ‘true’, Maxima expands ‘gamma’ for arguments
     ‘z+n’ and ‘z-n’ where ‘n’ is an integer.

     Maxima knows the derivative of ‘gamma’.

     Examples:

     Simplification for integer, half integral, and rational numbers:

          (%i1) map('gamma,[1,2,3,4,5,6,7,8,9]);
          (%o1)        [1, 1, 2, 6, 24, 120, 720, 5040, 40320]
          (%i2) map('gamma,[1/2,3/2,5/2,7/2]);
                              sqrt(%pi)  3 sqrt(%pi)  15 sqrt(%pi)
          (%o2)   [sqrt(%pi), ---------, -----------, ------------]
                                  2           4            8
          (%i3) map('gamma,[2/3,5/3,7/3]);
                                            2           1
                                    2 gamma(-)  4 gamma(-)
                                2           3           3
          (%o3)          [gamma(-), ----------, ----------]
                                3       3           9

     Numerical evaluation for real and complex values:

          (%i1) map('gamma,[2.5,2.5b0]);
          (%o1)       [1.329340388179137, 1.329340388179137b0]
          (%i2) map('gamma,[1.0+%i,1.0b0+%i]);
          (%o2) [0.49801566811835596 - 0.15494982830181073 %i,
                            4.980156681183561b-1 - 1.549498283018107b-1 %i]

     ‘gamma’ has mirror symmetry:

          (%i1) declare(z,complex)$
          (%i2) conjugate(gamma(z));
          (%o2)                  gamma(conjugate(z))

     Maxima expands ‘gamma(z+n)’ and ‘gamma(z-n)’, when ‘gamma_expand’
     is ‘true’:

          (%i1) gamma_expand:true$
          (%i2) [gamma(z+1),gamma(z-1),gamma(z+2)/gamma(z+1)];
                                         gamma(z)
          (%o2)             [z gamma(z), --------, z + 1]
                                          z - 1

     The derivative of ‘gamma’:

          (%i1) diff(gamma(z),z);
          (%o1)                   psi (z) gamma(z)
                                     0

     See also ‘makegamma’.

     The Euler-Mascheroni constant is ‘%gamma’.

 -- Function: log_gamma (<z>)

     The natural logarithm of the gamma function.

          (%i1) gamma(6);
          (%o1)                          120
          (%i2) log_gamma(6);
          (%o2)                       log(120)
          (%i3) log_gamma(0.5);
          (%o3)                  0.5723649429247004

 -- Function: gamma_incomplete_lower (<a>, <z>)

     The lower incomplete gamma function (DLMF 8.2.E1
     (https://dlmf.nist.gov/8.2.E1) and A&S eqn 6.5.2
     (https://personal.math.ubc.ca/~cbm/aands/page_260.htm)):

                                              z
                                             /
                                             [  a - 1   - t
              gamma_incomplete_lower(a, z) = I t      %e    dt
                                             ]
                                             /
                                              0

     See also ‘gamma_incomplete’ (upper incomplete gamma function).

 -- Function: gamma_incomplete (<a>, <z>)

     The incomplete upper gamma function (DLMF 8.2.E2
     (https://dlmf.nist.gov/8.2.E2) and A&S eqn 6.5.3
     (https://personal.math.ubc.ca/~cbm/aands/page_260.htm)):

                                        inf
                                       /
                                       [     a - 1   - t
              gamma_incomplete(a, z) = I    t      %e    dt
                                       ]
                                       /
                                        z

     See also ‘gamma_expand’ for controlling how ‘gamma_incomplete’ is
     expressed in terms of elementary functions and ‘erfc’.

     Also see the related functions ‘gamma_incomplete_regularized’ and
     ‘gamma_incomplete_generalized’.

 -- Function: gamma_incomplete_regularized (<a>, <z>)

     The regularized incomplete upper gamma function (DLMF 8.2.E4
     (https://dlmf.nist.gov/8.2.E4)):

          gamma_incomplete_regularized(a, z) =
                                                  gamma_incomplete(a, z)
                                                  ----------------------
                                                         gamma(a)

     See also ‘gamma_expand’ for controlling how ‘gamma_incomplete’ is
     expressed in terms of elementary functions and ‘erfc’.

     Also see ‘gamma_incomplete’.

 -- Function: gamma_incomplete_generalized (<a>, <z1>, <z1>)

     The generalized incomplete gamma function.

          gamma_incomplete_generalized(a, z1, z2) =
                                                         z2
                                                        /
                                                        [    a - 1   - t
                                                        I   t      %e    dt
                                                        ]
                                                        /
                                                         z1

     Also see ‘gamma_incomplete’ and ‘gamma_incomplete_regularized’.

 -- Option variable: gamma_expand
     Default value: ‘false’

     ‘gamma_expand’ controls expansion of ‘gamma_incomplete’.  When
     ‘gamma_expand’ is ‘true’, ‘gamma_incomplete(v,z)’ is expanded in
     terms of ‘z’, ‘exp(z)’, and ‘gamma_incomplete’ or ‘erfc’ when
     possible.

          (%i1) gamma_incomplete(2,z);
          (%o1)                gamma_incomplete(2, z)
          (%i2) gamma_expand:true;
          (%o2)                         true
          (%i3) gamma_incomplete(2,z);
                                              - z
          (%o3)                     (z + 1) %e
          (%i4) gamma_incomplete(3/2,z);
                                 - z   sqrt(%pi) erfc(sqrt(z))
          (%o4)        sqrt(z) %e    + -----------------------
                                                  2
          (%i5) gamma_incomplete(4/3,z);
                                                       1
                                      gamma_incomplete(-, z)
                          1/3   - z                    3
          (%o5)          z    %e    + ----------------------
                                                3
          (%i6) gamma_incomplete(a+2,z);
                 a               - z
          (%o6) z  (z + a + 1) %e    + a (a + 1) gamma_incomplete(a, z)
          (%i7) gamma_incomplete(a-2, z);
                gamma_incomplete(a, z)    a - 2         z            1
          (%o7) ---------------------- - z      (--------------- + -----)
                   (1 - a) (2 - a)               (a - 2) (a - 1)   a - 2
                                                                        - z
                                                                      %e

 -- Option variable: gammalim
     Default value: 10000

     ‘gammalim’ controls simplification of the gamma function for
     integral and rational number arguments.  If the absolute value of
     the argument is not greater than ‘gammalim’, then simplification
     will occur.  Note that the ‘factlim’ switch controls simplification
     of the result of ‘gamma’ of an integer argument as well.

 -- Function: makegamma (<expr>)
     Transforms instances of binomial, factorial, and beta functions in
     <expr> into gamma functions.

     See also ‘makefact’.

          (%i1) makegamma(binomial(n,k));
                                    gamma(n + 1)
          (%o1)             -----------------------------
                            gamma(k + 1) gamma(n - k + 1)
          (%i2) makegamma(x!);
          (%o2)                     gamma(x + 1)
          (%i3) makegamma(beta(a,b));
                                  gamma(a) gamma(b)
          (%o3)                   -----------------
                                    gamma(b + a)

 -- Function: beta (<a>, <b>)
     The beta function is defined as gamma(a) gamma(b)/gamma(a+b)

     (DLMF 5.12.E1 (https://dlmf.nist.gov/5.12.E1) and A&S eqn 6.2.1
     (https://personal.math.ubc.ca/~cbm/aands/page_258.htm)).

     Maxima simplifies the beta function for positive integers and
     rational numbers, which sum to an integer.  When
     ‘beta_args_sum_to_integer’ is ‘true’, Maxima simplifies also
     general expressions which sum to an integer.

     For <a> or <b> equal to zero the beta function is not defined.

     In general the beta function is not defined for negative integers
     as an argument.  The exception is for <a=-n>, <n> a positive
     integer and <b> a positive integer with ‘b<=n’, it is possible to
     define an analytic continuation.  Maxima gives for this case a
     result.

     When ‘beta_expand’ is ‘true’, expressions like ‘beta(a+n,b)’ and
     ‘beta(a-n,b)’ or ‘beta(a,b+n)’ and ‘beta(a,b-n)’ with ‘n’ an
     integer are simplified.

     Maxima can evaluate the beta function for real and complex values
     in float and bigfloat precision.  For numerical evaluation Maxima
     uses ‘log_gamma’:

                     - log_gamma(b + a) + log_gamma(b) + log_gamma(a)
                   %e

     Maxima knows that the beta function is symmetric and has mirror
     symmetry.

     Maxima knows the derivatives of the beta function with respect to
     <a> or <b>.

     To express the beta function as a ratio of gamma functions see
     ‘makegamma’.

     Examples:

     Simplification, when one of the arguments is an integer:

          (%i1) [beta(2,3),beta(2,1/3),beta(2,a)];
                                  1   9      1
          (%o1)                  [--, -, ---------]
                                  12  4  a (a + 1)

     Simplification for two rational numbers as arguments which sum to
     an integer:

          (%i1) [beta(1/2,5/2),beta(1/3,2/3),beta(1/4,3/4)];
                             3 %pi   2 %pi
          (%o1)             [-----, -------, sqrt(2) %pi]
                               8    sqrt(3)

     When setting ‘beta_args_sum_to_integer’ to ‘true’ more general
     expression are simplified, when the sum of the arguments is an
     integer:

          (%i1) beta_args_sum_to_integer:true$
          (%i2) beta(a+1,-a+2);
                                   %pi (a - 1) a
          (%o2)                  ------------------
                                 2 sin(%pi (2 - a))

     The possible results, when one of the arguments is a negative
     integer:

          (%i1) [beta(-3,1),beta(-3,2),beta(-3,3)];
                                       1  1    1
          (%o1)                     [- -, -, - -]
                                       3  6    3

     ‘beta(a+n,b)’ or ‘beta(a-n,b)’ with ‘n’ an integer simplifies when
     ‘beta_expand’ is ‘true’:

          (%i1) beta_expand:true$
          (%i2) [beta(a+1,b),beta(a-1,b),beta(a+1,b)/beta(a,b+1)];
                       a beta(a, b)  beta(a, b) (b + a - 1)  a
          (%o2)       [------------, ----------------------, -]
                          b + a              a - 1           b

     Beta is not defined, when one of the arguments is zero:

     beta: expected nonzero arguments; found 0, b – an error.  To debug
     this try: debugmode(true);
          (%i1) beta(0,b);

     Numerical evaluation for real and complex arguments in float or
     bigfloat precision:

          (%i1) beta(2.5,2.3);
          (%o1)                  0.08694748611299981
          (%i2) beta(2.5,1.4+%i);
          (%o2)     0.06401449507966957 - 0.15020780532864159 %i
          (%i3) beta(2.5b0,2.3b0);
          (%o3)                 8.694748611299965b-2
          (%i4) beta(2.5b0,1.4b0+%i);
          (%o4)    6.401449507966939b-2 - 1.502078053286414b-1 %i

     Beta is symmetric and has mirror symmetry:

          (%i1) beta(a,b)-beta(b,a);
          (%o1)                           0
          (%i2) declare(a,complex,b,complex)$
          (%i3) conjugate(beta(a,b));
          (%o3)           beta(conjugate(a), conjugate(b))

     The derivative of the beta function wrt ‘a’:

          (%i1) diff(beta(a,b),a);
          (%o1)         - beta(a, b) (psi (b + a) - psi (a))
                                         0             0

 -- Function: beta_incomplete (<a>, <b>, <z>)

     The basic definition of the incomplete beta function (DLMF 8.17.E1
     (https://dlmf.nist.gov/8.17.E1) and A&S eqn 6.6.1
     (https://personal.math.ubc.ca/~cbm/aands/page_263.htm)) is

                  z
                 /
                 [         b - 1  a - 1
                 I  (1 - t)      t      dt
                 ]
                 /
                  0

     This definition is possible for realpart(a)>0 and realpart(b)>0 and
     abs(z)<1. For other values the incomplete beta function can be
     defined through a generalized hypergeometric function:

             gamma(a) hypergeometric_generalized([a, 1 - b], [a + 1], z) z

     (See <https://functions.wolfram.com/GammaBetaErf/Beta3/> for a
     complete definition of the incomplete beta function.)

     For negative integers a = -n and positive integers b=m with m<=n
     the incomplete beta function is defined through

                                      m - 1           k
                                      ====  (1 - m)  z
                                n - 1 \            k
                               z       >    -----------
                                      /     k! (n - k)
                                      ====
                                      k = 0

     Maxima uses this definition to simplify ‘beta_incomplete’ for <a> a
     negative integer.

     For <a> a positive integer, ‘beta_incomplete’ simplifies for any
     argument <b> and <z> and for <b> a positive integer for any
     argument <a> and <z>, with the exception of <a> a negative integer.

     For z=0 and realpart(a)>0, ‘beta_incomplete’ has the specific value
     zero.  For z=1 and realpart(b)>0, ‘beta_incomplete’ simplifies to
     the beta function ‘beta(a,b)’.

     Maxima evaluates ‘beta_incomplete’ numerically for real and complex
     values in float or bigfloat precision.  For the numerical
     evaluation an expansion of the incomplete beta function in
     continued fractions is used.

     When the option variable ‘beta_expand’ is ‘true’, Maxima expands
     expressions like ‘beta_incomplete(a+n,b,z)’ and
     ‘beta_incomplete(a-n,b,z)’ where n is a positive integer.

     Maxima knows the derivatives of ‘beta_incomplete’ with respect to
     the variables <a>, <b> and <z> and the integral with respect to the
     variable <z>.

     Examples:

     Simplification for <a> a positive integer:

          (%i1) beta_incomplete(2,b,z);
                                          b
                               1 - (1 - z)  (b z + 1)
          (%o1)                ----------------------
                                     b (b + 1)

     Simplification for <b> a positive integer:

          (%i1) beta_incomplete(a,2,z);
                                                  a
                                 (a (1 - z) + 1) z
          (%o1)                  ------------------
                                     a (a + 1)

     Simplification for <a> and <b> a positive integer:

          (%i1) beta_incomplete(3,2,z);
                                                  3
                                 (3 (1 - z) + 1) z
          (%o1)                  ------------------
                                         12

     <a> is a negative integer and b<=(-a), Maxima simplifies:

          (%i1) beta_incomplete(-3,1,z);
                                          1
          (%o1)                        - ----
                                            3
                                         3 z

     For the specific values z=0 and z=1, Maxima simplifies:

          (%i1) assume(a>0,b>0)$
          (%i2) beta_incomplete(a,b,0);
          (%o2)                           0
          (%i3) beta_incomplete(a,b,1);
          (%o3)                      beta(a, b)

     Numerical evaluation in float or bigfloat precision:

          (%i1) beta_incomplete(0.25,0.50,0.9);
          (%o1)                   4.594959440269333
          (%i2) fpprec:25$
          (%i3) beta_incomplete(0.25,0.50,0.9b0);
          (%o3)             4.594959440269324086971216b0

     For abs(z)>1 ‘beta_incomplete’ returns a complex result:

          (%i1) beta_incomplete(0.25,0.50,1.7);
          (%o1)       5.244115108584249 - 1.4551804778784403 %i

     Results for more general complex arguments:

          (%i1) beta_incomplete(0.25+%i,1.0+%i,1.7+%i);
          (%o1)      2.7269606756625384 - 0.38311757042691896 %i
          (%i2) beta_incomplete(1/2,5/4*%i,2.8+%i);
          (%o2)      13.046496351687155 %i - 5.8020679562699975

     Expansion, when ‘beta_expand’ is ‘true’:

          (%i1) beta_incomplete(a+1,b,z),beta_expand:true;
                                                          b  a
                      a beta_incomplete(a, b, z)   (1 - z)  z
          (%o1)       -------------------------- - -----------
                                b + a                 b + a
          (%i2) beta_incomplete(a-1,b,z),beta_expand:true;
                                                                b  a - 1
                beta_incomplete(a, b, z) (- b - a + 1)   (1 - z)  z
          (%o2) -------------------------------------- - ---------------
                                1 - a                         1 - a

     Derivative and integral for ‘beta_incomplete’:

          (%i1) diff(beta_incomplete(a, b, z), z);
                                        b - 1  a - 1
          (%o1)                  (1 - z)      z
          (%i2) integrate(beta_incomplete(a, b, z), z);
          (%o2) beta_incomplete(a, b, z) z - beta_incomplete(a + 1, b, z)
          (%i3) factor(diff(%, z));
          (%o3)               beta_incomplete(a, b, z)

 -- Function: beta_incomplete_regularized (<a>, <b>, <z>)

     The regularized incomplete beta function (DLMF 8.17.E2
     (https://dlmf.nist.gov/8.17.E2) and A&S eqn 6.6.2
     (https://personal.math.ubc.ca/~cbm/aands/page_263.htm)), defined as

          beta_incomplete_regularized(a, b, z) =
                                                beta_incomplete(a, b, z)
                                                ------------------------
                                                       beta(a, b)

     As for ‘beta_incomplete’ this definition is not complete.  See
     <https://functions.wolfram.com/GammaBetaErf/BetaRegularized/> for a
     complete definition of ‘beta_incomplete_regularized’.

     ‘beta_incomplete_regularized’ simplifies <a> or <b> a positive
     integer.

     For z=0 and realpart(a) > 0, ‘beta_incomplete_regularized’ has the
     specific value 0.  For z=1 and realpart(b)>0,
     ‘beta_incomplete_regularized’ simplifies to 1.

     Maxima can evaluate ‘beta_incomplete_regularized’ for real and
     complex arguments in float and bigfloat precision.

     When ‘beta_expand’ is ‘true’, Maxima expands
     ‘beta_incomplete_regularized’ for arguments a+n or a-n, where n is
     an integer.

     Maxima knows the derivatives of ‘beta_incomplete_regularized’ with
     respect to the variables <a>, <b>, and <z> and the integral with
     respect to the variable <z>.

     Examples:

     Simplification for <a> or <b> a positive integer:

          (%i1) beta_incomplete_regularized(2,b,z);
                                          b
          (%o1)                1 - (1 - z)  (b z + 1)
          (%i2) beta_incomplete_regularized(a,2,z);
                                                  a
          (%o2)                  (a (1 - z) + 1) z
          (%i3) beta_incomplete_regularized(3,2,z);
                                                  3
          (%o3)                  (3 (1 - z) + 1) z

     For the specific values z=0 and z=1, Maxima simplifies:

          (%i1) assume(a>0,b>0)$
          (%i2) beta_incomplete_regularized(a,b,0);
          (%o2)                           0
          (%i3) beta_incomplete_regularized(a,b,1);
          (%o3)                           1

     Numerical evaluation for real and complex arguments in float and
     bigfloat precision:

          (%i1) beta_incomplete_regularized(0.12,0.43,0.9);
          (%o1)                  0.9114011367359802
          (%i2) fpprec:32$
          (%i3) beta_incomplete_regularized(0.12,0.43,0.9b0);
          (%o3)         9.1140113673598029169207248506439b-1
          (%i4) beta_incomplete_regularized(1+%i,3/3,1.5*%i);
          (%o4)      0.2865367499935405 %i - 0.12299596333468409
          (%i5) fpprec:20$
          (%i6) beta_incomplete_regularized(1+%i,3/3,1.5b0*%i);
          (%o6) 2.8653674999354031589b-1 %i - 1.2299596333468401976b-1

     Expansion, when ‘beta_expand’ is ‘true’:

          (%i1) beta_incomplete_regularized(a+1,b,z);
          (%o1)       beta_incomplete_regularized(a + 1, b, z)
          (%i2) beta_incomplete_regularized(a-1,b,z);
          (%o2)       beta_incomplete_regularized(a - 1, b, z)

     The derivative and the integral wrt <z>:

          (%i1) diff(beta_incomplete_regularized(a,b,z),z);
                                        b - 1  a - 1
                                 (1 - z)      z
          (%o1)                  -------------------
                                     beta(a, b)
          (%i2) integrate(beta_incomplete_regularized(a,b,z),z);
          (%o2) beta_incomplete_regularized(a, b, z) z
                                 a beta_incomplete_regularized(a + 1, b, z)
                               - ------------------------------------------
                                                   b + a

 -- Function: beta_incomplete_generalized (<a>, <b>, <z1>, <z2>)

     The basic definition of the generalized incomplete beta function is

                       z2
                     /
                     [          b - 1  a - 1
                     I   (1 - t)      t      dt
                     ]
                     /
                      z1

     Maxima simplifies ‘beta_incomplete_regularized’ for <a> and <b> a
     positive integer.

     For realpart(a)>0 and z1=0 or z2=0, Maxima simplifies
     ‘beta_incomplete_generalized’ to ‘beta_incomplete’.  For
     realpart(b)>0 and z1=1 or z2=1, Maxima simplifies to an expression
     with ‘beta’ and ‘beta_incomplete’.

     Maxima evaluates ‘beta_incomplete_regularized’ for real and complex
     values in float and bigfloat precision.

     When ‘beta_expand’ is ‘true’, Maxima expands
     ‘beta_incomplete_generalized’ for a+n and a-n, <n> a positive
     integer.

     Maxima knows the derivative of ‘beta_incomplete_generalized’ with
     respect to the variables <a>, <b>, <z1>, and <z2> and the integrals
     with respect to the variables <z1> and <z2>.

     Examples:

     Maxima simplifies ‘beta_incomplete_generalized’ for <a> and <b> a
     positive integer:

          (%i1) beta_incomplete_generalized(2,b,z1,z2);
                             b                      b
                     (1 - z1)  (b z1 + 1) - (1 - z2)  (b z2 + 1)
          (%o1)      -------------------------------------------
                                      b (b + 1)
          (%i2) beta_incomplete_generalized(a,2,z1,z2);
                                        a                      a
                     (a (1 - z2) + 1) z2  - (a (1 - z1) + 1) z1
          (%o2)      -------------------------------------------
                                      a (a + 1)
          (%i3) beta_incomplete_generalized(3,2,z1,z2);
                        2      2                       2      2
                (1 - z1)  (3 z1  + 2 z1 + 1) - (1 - z2)  (3 z2  + 2 z2 + 1)
          (%o3) -----------------------------------------------------------
                                            12

     Simplification for specific values z1=0, z2=0, z1=1, or z2=1:

          (%i1) assume(a > 0, b > 0)$
          (%i2) beta_incomplete_generalized(a,b,z1,0);
          (%o2)              - beta_incomplete(a, b, z1)
          (%i3) beta_incomplete_generalized(a,b,0,z2);
          (%o3)              - beta_incomplete(a, b, z2)
          (%i4) beta_incomplete_generalized(a,b,z1,1);
          (%o4)        beta(a, b) - beta_incomplete(a, b, z1)
          (%i5) beta_incomplete_generalized(a,b,1,z2);
          (%o5)        beta_incomplete(a, b, z2) - beta(a, b)

     Numerical evaluation for real arguments in float or bigfloat
     precision:

          (%i1) beta_incomplete_generalized(1/2,3/2,0.25,0.31);
          (%o1)                  0.09638178086368676
          (%i2) fpprec:32$
          (%i3) beta_incomplete_generalized(1/2,3/2,0.25,0.31b0);
          (%o3)         9.6381780863686935309170054689964b-2

     Numerical evaluation for complex arguments in float or bigfloat
     precision:

          (%i1) beta_incomplete_generalized(1/2+%i,3/2+%i,0.25,0.31);
          (%o1)   - 0.09625463003205387 %i - 0.0033238477353540463
          (%i2) fpprec:20$
          (%i3) beta_incomplete_generalized(1/2+%i,3/2+%i,0.25,0.31b0);
          (%o3) - 9.6254630032054178691b-2 %i - 3.3238477353543591914b-3

     Expansion for a+n or a-n, <n> a positive integer, when
     ‘beta_expand’ is ‘true’:

          (%i1) beta_expand:true$
          (%i2) beta_incomplete_generalized(a+1,b,z1,z2);
                        b   a           b   a
                (1 - z1)  z1  - (1 - z2)  z2
          (%o2) -----------------------------
                            b + a
                                a beta_incomplete_generalized(a, b, z1, z2)
                              + -------------------------------------------
                                                   b + a
          (%i3) beta_incomplete_generalized(a-1,b,z1,z2);
                beta_incomplete_generalized(a, b, z1, z2) (- b - a + 1)
          (%o3) -------------------------------------------------------
                                         1 - a
                                              b   a - 1           b   a - 1
                                      (1 - z2)  z2      - (1 - z1)  z1
                                    - -------------------------------------
                                                      1 - a

     Derivative wrt the variable <z1> and integrals wrt <z1> and <z2>:

          (%i1) diff(beta_incomplete_generalized(a,b,z1,z2),z1);
                                         b - 1   a - 1
          (%o1)                - (1 - z1)      z1
          (%i2) integrate(beta_incomplete_generalized(a,b,z1,z2),z1);
          (%o2) beta_incomplete_generalized(a, b, z1, z2) z1
                                            + beta_incomplete(a + 1, b, z1)
          (%i3) integrate(beta_incomplete_generalized(a,b,z1,z2),z2);
          (%o3) beta_incomplete_generalized(a, b, z1, z2) z2
                                            - beta_incomplete(a + 1, b, z2)

 -- Option variable: beta_expand
     Default value: false

     When ‘beta_expand’ is ‘true’, ‘beta(a,b)’ and related functions are
     expanded for arguments like a+n or a-n, where n is an integer.

     *Note beta:: for examples.

 -- Option variable: beta_args_sum_to_integer
     Default value: false

     When ‘beta_args_sum_to_integer’ is ‘true’, Maxima simplifies
     ‘beta(a,b)’, when the arguments <a> and <b> sum to an integer.

     *Note beta:: for examples.

 -- Function: psi [<n>](<x>)

     ‘psi[n](x)’ is the polygamma function (DLMF 5.2E2
     (https://dlmf.nist.gov/5.2E2), DLMF 5.15
     (https://dlmf.nist.gov/5.15), A&S eqn 6.3.1
     (https://personal.math.ubc.ca/~cbm/aands/page_258.htm) and A&S eqn
     6.4.1 (https://personal.math.ubc.ca/~cbm/aands/page_260.htm))
     defined by diff(log(gamma(x)), x, n+1)

     Thus, ‘psi[0](<x>)’ is the first derivative, ‘psi[1](<x>)’ is the
     second derivative, etc.

     Maxima can compute some exact values for rational args as well for
     float and bfloat args.  Several variables control what range of
     rational args psi[n](x) will return an exact value, if possible.
     See ‘maxpsiposint’, ‘maxpsinegint’, ‘maxpsifracnum’, and
     ‘maxpsifracdenom’.  That is, x must lie between ‘maxpsinegint’ and
     ‘maxpsiposint’.  If the absolute value of the fractional part of x
     is rational and has a numerator less than ‘maxpsifracnum’ and has a
     denominator less than ‘maxpsifracdenom’, psi[0](x) will return an
     exact value.

     The function ‘bfpsi’ in the ‘bffac’ package can compute numerical
     values.

          (%i1) psi[0](.25);
          (%o1)                  - 4.227453533376265
          (%i2) psi[0](1/4);
                                           %pi
          (%o2)               - 3 log(2) - --- - %gamma
                                            2
          (%i3) float(%);
          (%o3)                  - 4.227453533376265
          (%i4) psi[2](0.75);
          (%o4)                 - 5.3026332163376395
          (%i5) psi[2](3/4);
                                       1         3
          (%o5)                   psi (-) + 4 %pi
                                     2 4
          (%i6) float(%);
          (%o6)                 - 5.3026332163376395

 -- Option variable: maxpsiposint
     Default value: 20

     ‘maxpsiposint’ is the largest positive integer value for which
     psi[n](x) gives an exact value for rational x.

          (%i1) psi[0](20);
                                 275295799
          (%o1)                  --------- - %gamma
                                 77597520
          (%i2) psi[0](21);
          (%o2)                       psi (21)
                                         0
          (%i3) psi[2](20);
                          1683118856778495358491487
          (%o3)        2 (------------------------- - zeta(3))
                          1401731326612193601024000
          (%i4) psi[2](21);
          (%o4)                       psi (21)
                                         2

 -- Option variable: maxpsinegint
     Default value: -10

     ‘maxpsinegint’ is the most negative value for which psi[0](x) will
     try to compute an exact value for rational x.  That is if x is less
     than ‘maxpsinegint’, psi[n](x) will not return simplified answer,
     even if it could.

          (%i1) psi[0](-100/9);
                                            100
          (%o1)                      psi (- ---)
                                        0    9
          (%i2) psi[0](-100/11);
                             100 %pi         1     5231385863539
          (%o2)      %pi cot(-------) + psi (--) + -------------
                               11          0 11    381905105400
          (%i3) psi[2](-100/9);
                                            100
          (%o3)                      psi (- ---)
                                        2    9
          (%i4) psi[2](-100/11);
                     3     100 %pi     2 100 %pi         1
          (%o4) 2 %pi  cot(-------) csc (-------) + psi (--)
                             11            11          2 11
                                     74191313259470963498957651385614962459
                                   + --------------------------------------
                                      27850718060013605318710152732000000

 -- Option variable: maxpsifracnum
     Default value: 6

     Let x be a rational number of the form p/q.  If p is greater than
     ‘maxpsifracnum’, then ‘psi[0](x)’ will not try to return a
     simplified value.

          (%i1) psi[0](3/4);
                                           %pi
          (%o1)               - 3 log(2) + --- - %gamma
                                            2
          (%i2) psi[2](3/4);
                                       1         3
          (%o2)                   psi (-) + 4 %pi
                                     2 4
          (%i3) maxpsifracnum:2;
          (%o3)                           2
          (%i4) psi[0](3/4);
                                            3
          (%o4)                        psi (-)
                                          0 4
          (%i5) psi[2](3/4);
                                       1         3
          (%o5)                   psi (-) + 4 %pi
                                     2 4

 -- Option variable: maxpsifracdenom
     Default value: 6

     Let x be a rational number of the form p/q.  If q is greater than
     ‘maxpsifracdenom’, then ‘psi[<0>](<x>)’ will not try to return a
     simplified value.

          (%i1) psi[0](3/4);
                                           %pi
          (%o1)               - 3 log(2) + --- - %gamma
                                            2
          (%i2) psi[2](3/4);
                                       1         3
          (%o2)                   psi (-) + 4 %pi
                                     2 4
          (%i3) maxpsifracdenom:2;
          (%o3)                           2
          (%i4) psi[0](3/4);
                                            3
          (%o4)                        psi (-)
                                          0 4
          (%i5) psi[2](3/4);
                                       1         3
          (%o5)                   psi (-) + 4 %pi
                                     2 4

 -- Function: makefact (<expr>)
     Transforms instances of binomial, gamma, and beta functions in
     <expr> into factorials.

     See also ‘makegamma’.

          (%i1) makefact(binomial(n,k));
                                         n!
          (%o1)                      -----------
                                     k! (n - k)!
          (%i2) makefact(gamma(x));
          (%o2)                       (x - 1)!
          (%i3) makefact(beta(a,b));
                                  (a - 1)! (b - 1)!
          (%o3)                   -----------------
                                    (b + a - 1)!

 -- Function: numfactor (<expr>)
     Returns the numerical factor multiplying the expression <expr>,
     which should be a single term.

     ‘content’ returns the greatest common divisor (gcd) of all terms in
     a sum.

          (%i1) gamma (7/2);
                                    15 sqrt(%pi)
          (%o1)                     ------------
                                         8
          (%i2) numfactor (%);
                                         15
          (%o2)                          --
                                         8


File: maxima.info,  Node: Exponential Integrals,  Next: Error Function,  Prev: Gamma and Factorial Functions,  Up: Special Functions

14.5 Exponential Integrals
==========================

The Exponential Integral and related functions are defined in Abramowitz
and Stegun, Handbook of Mathematical Functions, A&S Chapter 5
(https://personal.math.ubc.ca/~cbm/aands/page_228.htm).

 -- Function: expintegral_e1 (<z>)
     The Exponential Integral E1(z) defined as

     integrate(exp(-t)/t, t, z, inf)

     with abs(arg z) < %pi. (A&S eqn 5.1.1
     (https://personal.math.ubc.ca/~cbm/aands/page_228.htm)) and (DLMF
     6.2E2 (https://dlmf.nist.gov/6.2E2))

     This can be written in terms of other functions.  *Note expintrep::
     for examples.

 -- Function: expintegral_ei (<x>)
     The Exponential Integral Ei(x) defined as

     -integrate(%e^(-t)/t, t, -x, inf) = integrate(%e^(t)/t, t, -inf, x)

     with x real and x > 0.  (A&S eqn 5.1.2
     (https://personal.math.ubc.ca/~cbm/aands/page_228.htm)) and (DLMF
     6.2E5 (https://dlmf.nist.gov/6.2E5))

     This can be written in terms of other functions.  *Note expintrep::
     for examples.

 -- Function: expintegral_li (<x>)
     The Exponential Integral li(x) defined as

     integrate(1/ln(t), t, 0, x)

     with x real and x > 1.  (A&S eqn 5.1.3
     (https://personal.math.ubc.ca/~cbm/aands/page_228.htm)) and (DLMF
     6.2E8 (https://dlmf.nist.gov/6.2E8))

     This can be written in terms of other functions.  *Note expintrep::
     for examples.

 -- Function: expintegral_e (<n>,<z>)
     The Exponential Integral En(z) (A&S eqn 5.1.4
     (https://personal.math.ubc.ca/~cbm/aands/page_228.htm)) defined as

     integrate(exp(-z*t)/t^n, t, 1, inf)

     with realpart(z) > 1 and n a non-negative integer.

     For half-integral orders, this can be written in terms of ‘erfc’ or
     ‘erf’.  *Note expintexpand:: for examples.

 -- Function: expintegral_si (<z>)
     The Exponential Integral Si(z) (A&S eqn 5.2.1
     (https://personal.math.ubc.ca/~cbm/aands/page_231.htm) and DLMF
     6.2#E9 (https://dlmf.nist.gov/6.2#E9)) defined as

     integrate(sin(t)/t, t, 0, z)

     This can be written in terms of other functions.  *Note expintrep::
     for examples.

 -- Function: expintegral_ci (<z>)
     The Exponential Integral Ci(z) (A&S eqn 5.2.2
     (https://personal.math.ubc.ca/~cbm/aands/page_231.htm) and DLMF
     6.2#E13 (https://dlmf.nist.gov/6.2#E13)) defined as

     %gamma + log(z) + integrate((cos(t) - 1)/t, t, 0, z)

     with abs(arg z) < %pi.

     This can be written in terms of other functions.  *Note expintrep::
     for examples.

 -- Function: expintegral_shi (<z>)
     The Exponential Integral Shi(z) (A&S eqn 5.2.3
     (https://personal.math.ubc.ca/~cbm/aands/page_231.htm) and DLMF
     6.2#E15 (https://dlmf.nist.gov/6.2#E15)) defined as

     integrate(sinh(t)/t, t, 0, z)

     This can be written in terms of other functions.  *Note expintrep::
     for examples.

 -- Function: expintegral_chi (<z>)
     The Exponential Integral Chi(z) (A&S eqn 5.2.4
     (https://personal.math.ubc.ca/~cbm/aands/page_231.htm) and DLMF
     6.2#E16 (https://dlmf.nist.gov/6.2#E16)) defined as

     %gamma + log(z) + integrate((cosh(t) - 1)/t, t, 0, z)

     with abs(arg z) < %pi.

     This can be written in terms of other functions.  *Note expintrep::
     for examples.

 -- Option variable: expintrep
     Default value: false

     Change the representation of one of the exponential integrals,
     ‘expintegral_e(m, z)’, ‘expintegral_e1’, or ‘expintegral_ei’ to an
     equivalent form if possible.

     Possible values for ‘expintrep’ are ‘false’, ‘gamma_incomplete’,
     ‘expintegral_e1’, ‘expintegral_ei’, ‘expintegral_li’,
     ‘expintegral_trig’, or ‘expintegral_hyp’.

     ‘false’ means that the representation is not changed.  Other values
     indicate the representation is to be changed to use the function
     specified where ‘expintegral_trig’ means ‘expintegral_si’,
     ‘expintegral_ci’; and ‘expintegral_hyp’ means ‘expintegral_shi’ or
     ‘expintegral_chi’.

     Here are some examples for ‘expintrep’ set to ‘gamma_incomplete’:
          (%i1) expintrep:'gamma_incomplete;
          (%o1)                   gamma_incomplete
          (%i2) expintegral_e1(z);
          (%o2)                gamma_incomplete(0, z)
          (%i3) expintegral_ei(z);
          (%o3)     log(z) - log(- z) - gamma_incomplete(0, - z)
          (%i4) expintegral_li(z);
          (%o4) log(log(z)) - log(- log(z)) - gamma_incomplete(0, - log(z))
          (%i5) expintegral_e(n,z);
                                                      n - 1
          (%o5)           gamma_incomplete(1 - n, z) z
          (%i6) expintegral_si(z);
          (%o6) (%i (- log(%i z) + log(- %i z) - gamma_incomplete(0, %i z)
                                          + gamma_incomplete(0, - %i z)))/2
          (%i7) expintegral_ci(z);
          (%o7) log(z) - (log(%i z) + log(- %i z)
               + gamma_incomplete(0, %i z) + gamma_incomplete(0, - %i z))/2
          (%i8) expintegral_shi(z);
          (%o8) (log(z) - log(- z) + gamma_incomplete(0, z)
                                              - gamma_incomplete(0, - z))/2
          (%i9) expintegral_chi(z);
          (%o9) - (- log(z) + log(- z) + gamma_incomplete(0, z)
                                              + gamma_incomplete(0, - z))/2

     For ‘expintrep’ set to ‘expintegral_e1’:

          (%i1) expintrep:'expintegral_e1;
          (%o1)                    expintegral_e1
          (%i2) expintegral_ei(z);
          (%o2)        log(z) - log(- z) - expintegral_e1(- z)
          (%i3) expintegral_li(z);
          (%o3) log(log(z)) - log(- log(z)) - expintegral_e1(- log(z))
          (%i4) expintegral_e(n,z);
          (%o4)                  expintegral_e(n, z)
          (%i5) expintegral_si(z);
          (%o5) (%i (- log(%i z) - expintegral_e1(%i z) + log(- %i z)
                                               + expintegral_e1(- %i z)))/2
          (%i6) expintegral_ci(z);
          (%o6) log(z) - (log(- %i z) (expintegral_e1(%i z)
                                     + expintegral_e1(- %i z)) log(%i z))/2
          (%i7) expintegral_shi(z);
                log(z) + expintegral_e1(z) - log(- z) - expintegral_e1(- z)
          (%o7) -----------------------------------------------------------
                                             2
          (%i8) expintegral_chi(z);
          (%o8)
              - log(z) + expintegral_e1(z) + log(- z) + expintegral_e1(- z)
            - -------------------------------------------------------------
                                            2

     For ‘expintrep’ set to ‘expintegral_ei’:

          (%i1) expintrep:'expintegral_ei;
          (%o1)                    expintegral_ei
          (%i2) expintegral_e1(z);
                                            1
                           log(- z) - log(- -)
                                            z
          (%o2) - log(z) + ------------------- - expintegral_ei(- z)
                                    2
          (%i3) expintegral_ei(z);
          (%o3)                   expintegral_ei(z)
          (%i4) expintegral_li(z);
          (%o4)                expintegral_ei(log(z))
          (%i5) expintegral_e(n,z);
          (%o5)                  expintegral_e(n, z)
          (%i6) expintegral_si(z);
          (%o6) (%i (log(%i z) + 2 (expintegral_ei(- %i z)
                                                        %i          %i
            - expintegral_ei(%i z)) - log(- %i z) + log(--) - log(- --)))/4
                                                        z           z
          (%i7) expintegral_ci(z);
          (%o7) (- log(%i z) + 2 (expintegral_ei(%i z)
                                                         %i          %i
           + expintegral_ei(- %i z)) - log(- %i z) + log(--) + log(- --))/4
                                                         z           z
           + log(z)
          (%i8) expintegral_shi(z);
          (%o8) (- 2 log(z) + 2 (expintegral_ei(z) - expintegral_ei(- z))
                                                                      1
                                                   + log(- z) - log(- -))/4
                                                                      z
          (%i9) expintegral_chi(z);
          (%o9) (2 log(z) + 2 (expintegral_ei(z) + expintegral_ei(- z))
                                                                      1
                                                   - log(- z) + log(- -))/4
                                                                      z

     For ‘expintrep’ set to ‘expintegral_li’:

          (%i1) expintrep:'expintegral_li;
          (%o1)                    expintegral_li
          (%i2) expintegral_e1(z);
                                                                    1
                                                   log(- z) - log(- -)
                                   - z                              z
          (%o2) - expintegral_li(%e   ) - log(z) + -------------------
                                                            2
          (%i3) expintegral_ei(z);
                                                  z
          (%o3)                  expintegral_li(%e )
          (%i4) expintegral_li(z);
          (%o4)                   expintegral_li(z)
          (%i5) expintegral_e(n,z);
          (%o5)                  expintegral_e(n, z)
          (%i6) expintegral_si(z);
                                        %i z                     - %e z
          (%o6) - (%i (expintegral_li(%e    ) - expintegral_li(%e      )
                                                          %pi signum(z)
                                                        - -------------))/2
                                                                2
          (%i7) expintegral_ci(z);
                                 %i z                     - %i z
                expintegral_li(%e    ) + expintegral_li(%e      )
          (%o7) -------------------------------------------------
                                        2
                                                            - signum(z) + 1
          (%i8) expintegral_shi(z);
                                      z                     - z
                     expintegral_li(%e ) - expintegral_li(%e   )
          (%o8)      -------------------------------------------
                                          2
          (%i9) expintegral_chi(z);
                                      z                     - z
                     expintegral_li(%e ) + expintegral_li(%e   )
          (%o9)      -------------------------------------------
                                          2

     For ‘expintrep’ set to ‘expintegral_trig’:

          (%i1) expintrep:'expintegral_trig;
          (%o1)                   expintegral_trig
          (%i2) expintegral_e1(z);
          (%o2) log(%i z) - %i expintegral_si(%i z) - expintegral_ci(%i z)
                                                                   - log(z)
          (%i3) expintegral_ei(z);
          (%o3) - log(%i z) - %i expintegral_si(%i z)
                                            + expintegral_ci(%i z) + log(z)
          (%i4) expintegral_li(z);
          (%o4) - log(%i log(z)) - %i expintegral_si(%i log(z))
                                  + expintegral_ci(%i log(z)) + log(log(z))
          (%i5) expintegral_e(n,z);
          (%o5)                  expintegral_e(n, z)
          (%i6) expintegral_si(z);
          (%o6)                   expintegral_si(z)
          (%i7) expintegral_ci(z);
          (%o7)                   expintegral_ci(z)
          (%i8) expintegral_shi(z);
          (%o8)               - %i expintegral_si(%i z)
          (%i9) expintegral_chi(z);
          (%o9)      - log(%i z) + expintegral_ci(%i z) + log(z)

     For ‘expintrep’ set to ‘expintegral_hyp’:

          (%i1) expintrep:'expintegral_hyp;
          (%o1)                    expintegral_hyp
          (%i2) expintegral_e1(z);
          (%o2)        expintegral_shi(z) - expintegral_chi(z)
          (%i3) expintegral_ei(z);
          (%o3)        expintegral_shi(z) + expintegral_chi(z)
          (%i4) expintegral_li(z);
          (%o4)   expintegral_shi(log(z)) + expintegral_chi(log(z))
          (%i5) expintegral_e(n,z);
          (%o5)                  expintegral_e(n, z)
          (%i6) expintegral_si(z);
          (%o6)              - %i expintegral_shi(%i z)
          (%i7) expintegral_ci(z);
          (%o7)     - log(%i z) + expintegral_chi(%i z) + log(z)
          (%i8) expintegral_shi(z);
          (%o8)                  expintegral_shi(z)
          (%i9) expintegral_chi(z);
          (%o9)                  expintegral_chi(z)

 -- Option variable: expintexpand
     Default value: false

     Expand ‘expintegral_e(n,z)’ for half integral values in terms of
     ‘erfc’ or ‘erf’ and for positive integers in terms of
     ‘expintegral_ei’.

          (%i1) expintegral_e(1/2,z);
                                               1
          (%o1)                  expintegral_e(-, z)
                                               2
          (%i2) expintegral_e(1,z);
          (%o2)                  expintegral_e(1, z)
          (%i3) expintexpand:true;
          (%o3)                         true
          (%i4) expintegral_e(1/2,z);
                               sqrt(%pi) erfc(sqrt(z))
          (%o4)                -----------------------
                                       sqrt(z)
          (%i5) expintegral_e(1,z);
                                 1
                           log(- -) - log(- z)
                                 z
          (%o5) - log(z) - ------------------- - expintegral_ei(- z)
                                    2


File: maxima.info,  Node: Error Function,  Next: Struve Functions,  Prev: Exponential Integrals,  Up: Special Functions

14.6 Error Function
===================

The Error function and related functions are defined in Abramowitz and
Stegun, Handbook of Mathematical Functions, A&S Chapter 7
(https://personal.math.ubc.ca/~cbm/aands/page_297.htm) and (DLMF 7
(https://dlmf.nist.gov/7))

 -- Function: erf (<z>)

     The Error Function erf(z): erf(z) =
     2/sqrt(%pi)*integrate(exp(-t^2), t, 0, z)

     (A&S eqn 7.1.1
     (https://personal.math.ubc.ca/~cbm/aands/page_297.htm)) and (DLMF
     7.2.E1 (https://dlmf.nist.gov/7.2.E1)).

     See also flag ‘erfflag’.  This can also be expressed in terms of a
     hypergeometric function.  *Note hypergeometric_representation::.

 -- Function: erfc (<z>)
     The Complementary Error Function erfc(z): erfc(z) = 1-erf(z)

     (A&S eqn 7.1.2
     (https://personal.math.ubc.ca/~cbm/aands/page_297.htm)) and (DLMF
     7.2.E2 (https://dlmf.nist.gov/7.2.E2)).

     This can also be expressed in terms of a hypergeometric function.
     *Note hypergeometric_representation::.

 -- Function: erfi (<z>)
     The Imaginary Error Function.  erfi(z) = -%i*erf(%i*z)

 -- Function: erf_generalized (<z1>,<z2>)
     Generalized Error function Erf(z1,z2): erf(z) =
     2/sqrt(%pi)*integrate(exp(-t^2), t, z1, z2)

     This can also be expressed in terms of a hypergeometric function.
     *Note hypergeometric_representation::.

 -- Function: fresnel_c (<z>)
     The Fresnel Integral

     C(z) = integrate(cos((%pi/2)*t^2),t,0,z)

     (A&S eqn 7.3.1
     (https://personal.math.ubc.ca/~cbm/aands/page_300.htm)) and (DLMF
     7.2.E7 (https://dlmf.nist.gov/7.2.E7)).

     The simplification ‘fresnel_c(-x) = -fresnel_c(x)’ is applied when
     flag ‘trigsign’ is true.

     The simplification ‘fresnel_c(%i*x) = %i*fresnel_c(x)’ is applied
     when flag ‘%iargs’ is true.

     See flags ‘erf_representation’ and ‘hypergeometric_representation’.

 -- Function: fresnel_s (<z>)
     The Fresnel Integral S(z) = integrate(sin((%pi/2)*t^2),t,0,z)

     (A&S eqn 7.3.2
     (https://personal.math.ubc.ca/~cbm/aands/page_300.htm)) and (DLMF
     7.2.E8 (https://dlmf.nist.gov/7.2.E8)).

     The simplification ‘fresnel_s(-x) = -fresnel_s(x)’ is applied when
     flag ‘trigsign’ is true.

     The simplification ‘fresnel_s(%i*x) = -%i*fresnel_s(x)’ is applied
     when flag ‘%iargs’ is true.

     See flags ‘erf_representation’ and ‘hypergeometric_representation’.

 -- Option variable: erf_representation
     Default value: false

     ‘erf_representation’ controls how the error functions are
     represented.  It must be set to one of ‘false’, ‘erf’, ‘erfc’, or
     ‘erfi’.  When set to ‘false’, the error functions are not modified.
     When set to ‘erf’, all error functions (‘erfc’, ‘erfi’,
     ‘erf_generalized’, ‘fresnel_s’ and ‘fresnel_c’) are converted to
     ‘erf’ functions.  Similarly, ‘erfc’ converts error functions to
     ‘erfc’.  Finally ‘erfi’ converts the functions to ‘erfi’.

     Converting to ‘erf’:
          (%i1) erf_representation:erf;
          (%o1)                          erf
          (%i2) erfc(z);
          (%o2)                      1 - erf(z)
          (%i3) erfi(z);
          (%o3)                    - %i erf(%i z)
          (%i4) erf_generalized(z1,z2);
          (%o4)                   erf(z2) - erf(z1)
          (%i5) fresnel_c(z);
                               sqrt(%pi) (%i + 1) z
          (%o5) ((1 - %i) (erf(--------------------)
                                        2
                                                  sqrt(%pi) (1 - %i) z
                                         + %i erf(--------------------)))/4
                                                           2
          (%i6) fresnel_s(z);
                               sqrt(%pi) (%i + 1) z
          (%o6) ((%i + 1) (erf(--------------------)
                                        2
                                                  sqrt(%pi) (1 - %i) z
                                         - %i erf(--------------------)))/4
                                                           2

     Converting to ‘erfc’:
          (%i1) erf_representation:erfc;
          (%o1)                         erfc
          (%i2) erf(z);
          (%o2)                      1 - erfc(z)
          (%i3) erfc(z);
          (%o3)                        erfc(z)
          (%i4) erf_generalized(z1,z2);
          (%o4)                  erfc(z1) - erfc(z2)
          (%i5) fresnel_s(c);
                                  sqrt(%pi) (%i + 1) c
          (%o5) ((%i + 1) (- erfc(--------------------)
                                           2
                                             sqrt(%pi) (1 - %i) c
                              - %i (1 - erfc(--------------------)) + 1))/4
                                                      2
          (%i6) fresnel_c(c);
                                  sqrt(%pi) (%i + 1) c
          (%o6) ((1 - %i) (- erfc(--------------------)
                                           2
                                             sqrt(%pi) (1 - %i) c
                              + %i (1 - erfc(--------------------)) + 1))/4
                                                      2

     Converting to ‘erfc’:

          (%i1) erf_representation:erfi;
          (%o1)                         erfi
          (%i2) erf(z);
          (%o2)                    - %i erfi(%i z)
          (%i3) erfc(z);
          (%o3)                   %i erfi(%i z) + 1
          (%i4) erfi(z);
          (%o4)                        erfi(z)
          (%i5) erf_generalized(z1,z2);
          (%o5)            %i erfi(%i z1) - %i erfi(%i z2)
          (%i6) fresnel_s(z);
                                     sqrt(%pi) %i (%i + 1) z
          (%o6) ((%i + 1) (- %i erfi(-----------------------)
                                                2
                                               sqrt(%pi) (1 - %i) %i z
                                        - erfi(-----------------------)))/4
                                                          2
          (%i7) fresnel_c(z);
                                sqrt(%pi) (1 - %i) %i z
          (%o7) ((1 - %i) (erfi(-----------------------)
                                           2
                                               sqrt(%pi) %i (%i + 1) z
                                     - %i erfi(-----------------------)))/4
                                                          2

 -- Option variable: hypergeometric_representation
     Default value: false

     Enables transformation to a Hypergeometric representation for
     ‘fresnel_s’ and ‘fresnel_c’ and other error functions.

          (%i1) hypergeometric_representation:true;
          (%o1)                         true
          (%i2) fresnel_s(z);
                                                         2  4
                                        3    3  7     %pi  z    3
                    %pi hypergeometric([-], [-, -], - -------) z
                                        4    2  4       16
          (%o2)     ---------------------------------------------
                                          6
          (%i3) fresnel_c(z);
                                                       2  4
                                      1    1  5     %pi  z
          (%o3)       hypergeometric([-], [-, -], - -------) z
                                      4    2  4       16
          (%i4) erf(z);
                                                             2
                                              3    2      - z
                       2 hypergeometric([1], [-], z ) z %e
                                              2
          (%o4)        ---------------------------------------
                                      sqrt(%pi)
          (%i5) erfi(z);
                                            1    3    2
                          2 hypergeometric([-], [-], z ) z
                                            2    2
          (%o5)           --------------------------------
                                     sqrt(%pi)
          (%i6) erfc(z);
                                                               2
                                                3    2      - z
                         2 hypergeometric([1], [-], z ) z %e
                                                2
          (%o6)      1 - ---------------------------------------
                                        sqrt(%pi)
          (%i7) erf_generalized(z1,z2);
                                                         2
                                       3     2       - z2
                2 hypergeometric([1], [-], z2 ) z2 %e
                                       2
          (%o7) ------------------------------------------
                                sqrt(%pi)
                                                                          2
                                                        3     2       - z1
                                 2 hypergeometric([1], [-], z1 ) z1 %e
                                                        2
                               - ------------------------------------------
                                                 sqrt(%pi)


File: maxima.info,  Node: Struve Functions,  Next: Hypergeometric Functions,  Prev: Error Function,  Up: Special Functions

14.7 Struve Functions
=====================

The Struve functions are defined in Abramowitz and Stegun, Handbook of
Mathematical Functions, A&S Chapter 12
(https://personal.math.ubc.ca/~cbm/aands/page_496.htm) and (DLMF 11
(https://dlmf.nist.gov/11)).  The Struve Function H[v](z) is a
particular solution of the differential equation: z^2*diff(w,z,2) +
z*diff(w,z)+(z^2-v^2)*w = 4*(z/2)^(v+1)/(sqrt(%pi)*gamma(v+1/2))

   which has the general soution w = a*bessel_j(v,z) + b*bessel_y(v,z) +
struve_h(v,z)

 -- Function: struve_h (<v>, <z>)
     The Struve Function H of order v and argument z:

     struve_h(v,z) =
     (z/2)^(v+1)*sum((-1)^k*(z/2)^(2*k)/(gamma(k+3/2)*gamma(k+v+3/2)),
     k, 0, inf)

     (A&S eqn 12.1.3
     (https://personal.math.ubc.ca/~cbm/aands/page_496.htm)) and (DLMF
     11.2.E1 (https://dlmf.nist.gov/11.2.E1)).

     When ‘besselexpand’ is ‘true’, ‘struve_h’ is expanded in terms of
     elementary functions when the order v is half of an odd integer.
     See ‘besselexpand’.

 -- Function: struve_l (<v>, <z>)
     The Modified Struve Function L of order v and argument z:
     struve_l(v,z) = %i*exp(-%i*v*%pi/2)*struve_h(v,z)

     (A&S eqn 12.2.1
     (https://personal.math.ubc.ca/~cbm/aands/page_498.htm)) and (DLMF
     11.2.E2 (https://dlmf.nist.gov/11.2.E2)).

     When ‘besselexpand’ is ‘true’, ‘struve_l’ is expanded in terms of
     elementary functions when the order v is half of an odd integer.
     See ‘besselexpand’.


File: maxima.info,  Node: Hypergeometric Functions,  Next: Parabolic Cylinder Functions,  Prev: Struve Functions,  Up: Special Functions

14.8 Hypergeometric Functions
=============================

The Hypergeometric Functions are defined in Abramowitz and Stegun,
Handbook of Mathematical Functions, A&S Chapters 13
(https://personal.math.ubc.ca/~cbm/aands/page_504.htm) and A&S 15
(https://personal.math.ubc.ca/~cbm/aands/page_555.htm).

   Maxima has very limited knowledge of these functions.  They can be
returned from function ‘hgfred’.

 -- Function: %m [<k>,<u>] (<z>)
     Whittaker M function (A&S eqn 13.1.32
     (https://personal.math.ubc.ca/~cbm/aands/page_505.htm)):

     %m[k,u](z) = exp(-z/2)*z^(1/2+u)*M(1/2+u-k,1+2*u,z)

     where M(a,b,z) is Kummer’s solution of the confluent hypergeometric
     equation.

     This can also be expressed by the series (DLMF 13.14.E6
     (https://dlmf.nist.gov/13.14.E6)): %m[k,u](z) =
     %e^(-z/2)*z^(1/2+u)*sum(pochhammer(1/2+u-k,s)/(pochhammer(1+2*u,s)*s!)*z^s,
     s, 0, inf)

 -- Function: %w [<k>,<u>] (<z>)
     Whittaker W function (A&S eqn 13.1.33
     (https://personal.math.ubc.ca/~cbm/aands/page_505.htm)): %w[k,v](z)
     = exp(-z/2)*z^(1/2+u)*U(1/2+u-k, 1+2*u, z)

     where U(a,b,z) is Kummer’s second solution of the confluent
     hypergeometric equation.

 -- Function: %f [<p>,<q>] (<[a],[b],z>)
     The pFq(a_1,a_2,...,a_p;b_1,b_2,...,b_q;z) hypergeometric function,
     where <a> a list of length <p> and <b> a list of length <q>.

 -- Function: hypergeometric ([<a1>, ..., <ap>],[<b1>, ... ,<bq>], x)
     The hypergeometric function.  Unlike Maxima’s ‘%f’ hypergeometric
     function, the function ‘hypergeometric’ is a simplifying function;
     also, ‘hypergeometric’ supports complex double and big floating
     point evaluation.  For the Gauss hypergeometric function, that is p
     = 2 and q = 1, floating point evaluation outside the unit circle is
     supported, but in general, it is not supported.

     When the option variable ‘expand_hypergeometric’ is true (default
     is false) and one of the arguments ‘a1’ through ‘ap’ is a negative
     integer (a polynomial case), ‘hypergeometric’ returns an expanded
     polynomial.

     Examples:

          (%i1)  hypergeometric([],[],x);
                                           x
          (%o1)                          %e

     Polynomial cases automatically expand when ‘expand_hypergeometric’
     is true:

          (%i1) hypergeometric([-3],[7],x);
          (%o1)             hypergeometric([- 3], [7], x)
          (%i2) hypergeometric([-3],[7],x), expand_hypergeometric : true;
                                  3       2
                                 x     3 x    3 x
          (%o2)                - --- + ---- - --- + 1
                                 504    56     7

     Both double float and big float evaluation is supported:

          (%i1) hypergeometric([5.1],[7.1 + %i],0.42);
          (%o1)      1.3462507863753337 - 0.0559061414208204 %i
          (%i2) hypergeometric([5,6],[8], 5.7 - %i);
          (%o2)    0.007375824009774945 - 0.0010498136885786736 %i
          (%i3) hypergeometric([5,6],[8], 5.7b0 - %i), fpprec : 30;
          (%o3) 7.37582400977494674506442010824b-3
                                    - 1.04981368857867315858055393376b-3 %i

 -- Function: hypergeometric_simp (<e>)

     ‘hypergeometric_simp’ simplifies hypergeometric functions by
     applying ‘hgfred’ to the arguments of any hypergeometric functions
     in the expression <e>.

     Only instances of ‘hypergeometric’ are affected; any ‘%f’, ‘%w’,
     and ‘%m’ in the expression <e> are not affected.  Any unsimplified
     hypergeometric functions are returned unchanged (instead of
     changing to ‘%f’ as ‘hgfred’ would).

     ‘load("hypergeometric");’ loads this function.

     See also ‘hgfred’.

     Examples:

          (%i1) load ("hypergeometric") $
          (%i2) foo : [hypergeometric([1,1], [2], z), hypergeometric([1/2], [1], z)];
          (%o2) [hypergeometric([1, 1], [2], z),
                                                               1
                                               hypergeometric([-], [1], z)]
                                                               2
          (%i3) hypergeometric_simp (foo);
                           log(1 - z)    z/2             z
          (%o3)         [- ----------, %e    bessel_i(0, -)]
                               z                         2
          (%i4) bar : hypergeometric([n], [m], z + 1);
          (%o4)            hypergeometric([n], [m], z + 1)
          (%i5) hypergeometric_simp (bar);
          (%o5)            hypergeometric([n], [m], z + 1)

 -- Function: hgfred (<a>, <b>, <t>)

     Simplify the generalized hypergeometric function in terms of other,
     simpler, forms.  <a> is a list of numerator parameters and <b> is a
     list of the denominator parameters.

     If ‘hgfred’ cannot simplify the hypergeometric function, it returns
     an expression of the form ‘%f[p,q]([a], [b], x)’ where <p> is the
     number of elements in <a>, and <q> is the number of elements in
     <b>.  This is the usual ‘pFq’ generalized hypergeometric function.

          (%i1) assume(not(equal(z,0)));
          (%o1)                   [notequal(z, 0)]
          (%i2) hgfred([v+1/2],[2*v+1],2*%i*z);
                        v/2                               %i z
                       4    bessel_j(v, z) gamma(v + 1) %e
          (%o2)        ---------------------------------------
                                          v
                                         z
          (%i3) hgfred([1,1],[2],z);
                                      log(1 - z)
          (%o3)                     - ----------
                                          z
          (%i4) hgfred([a,a+1/2],[3/2],z^2);
                                  1 - 2 a          1 - 2 a
                           (z + 1)        - (1 - z)
          (%o4)            -------------------------------
                                    2 (1 - 2 a) z

     It can be beneficial to load orthopoly too as the following example
     shows.  Note that <L> is the generalized Laguerre polynomial.

          (%i1) load("orthopoly")$
          (%i2) hgfred([-2],[a],z);
                                     2
                                    z        2 z
          (%o2)                  --------- - --- + 1
                                 a (a + 1)    a
          (%i3) ev(%);
                                     2
                                    z        2 z
          (%o3)                  --------- - --- + 1
                                 a (a + 1)    a


File: maxima.info,  Node: Parabolic Cylinder Functions,  Next: Functions and Variables for Special Functions,  Prev: Hypergeometric Functions,  Up: Special Functions

14.9 Parabolic Cylinder Functions
=================================

The Parabolic Cylinder Functions are defined in Abramowitz and Stegun,
Handbook of Mathematical Functions, A&S Chapter 19
(https://personal.math.ubc.ca/~cbm/aands/page_686.htm).

   Maxima has very limited knowledge of these functions.  They can be
returned from function ‘specint’.

 -- Function: parabolic_cylinder_d (<v>, <z>)
     The parabolic cylinder function ‘parabolic_cylinder_d(v,z)’.  (A&S
     eqn 19.3.1 (https://personal.math.ubc.ca/~cbm/aands/page_687.htm)).

     The solution of the Weber differential equation diff(y(z), z, 2) +
     (v+1/2-z^2/4)*y(z) = 0

     has two independent solutions, one of which is
     ‘parabolic_cylinder_d(v,z)’, the parabolic cylinder d function.

     Function ‘specint’ can return expressions containing
     ‘parabolic_cylinder_d(v,z)’ if the option variable ‘prefer_d’ is
     ‘true’.


File: maxima.info,  Node: Functions and Variables for Special Functions,  Prev: Parabolic Cylinder Functions,  Up: Special Functions

14.10 Functions and Variables for Special Functions
===================================================

 -- Function: lambert_w (<z>)
     The principal branch of Lambert’s W function W(z) (DLMF 4.13
     (https://dlmf.nist.gov/4.13)), the solution of z = W(z) * exp(W(z))

 -- Function: generalized_lambert_w (<k>, <z>)
     The <k>-th branch of Lambert’s W function W(z) (DLMF 4.13
     (https://dlmf.nist.gov/4.13)), the solution of z = W(z) *
     exp(W(z)).

     The principal branch, denoted Wp(z) in DLMF, is ‘lambert_w(z) =
     generalized_lambert_w(0,z)’.

     The other branch with real values, denoted Wm(z) in DLMF, is
     ‘generalized_lambert_w(-1,z)’.

 -- Function: kbateman [<v>] (<x>)
     The Bateman k function

     kbateman[v](x) = (2/%pi) integrate(cos(x*tan(t)-v*t),t,0,%pi/2)

     It is one solution of a differential equation which appears in the
     theory of turbulence:

                               2
                              d u
                              ─── x = u (x - v)
                                2
                              dx

     It is a special case of the confluent hypergeometric function for x
     > 0:

                              - x     v
                            %e    U(- ─, 0, 2 x)
                                      2
                            ────────────────────
                                      v
                                gamma(─ + 1)
                                      2

     where U is the confluent hypergeometric function.  Also, we have

                                %w      (2 z)
                                  v, 1/2
                      k   (z) = ─────────────
                       2 v      gamma(v + 1)

     where %w is the *note Whittaker W function: %w.

     Some examples:
          (%i1) assume(x > 0)$
          (%i2) makelist(kbateman[n](0),n,0,5);
                                2          2         2
          (%o2)            [0, ---, 0, - -----, 0, -----]
                               %pi       3 %pi     5 %pi
          (%i3) kbateman[0](x);
                                          - x
          (%o3)                         %e
          (%i4) kbateman[2](x);
                                          - x
          (%o4)                       2 %e    x
          (%i5) kbateman[4](x);
                                      - x
          (%o5)                   2 %e    (x - 1) x
          (%i6) kbateman[3](x);
          (%o6)                     kbateman (x)
                                            3

     Maxima can calculate the Laplace transform of ‘kbateman’ using
     ‘laplace’ or ‘specint’, as shown below:

          (%i1) assume(s>0)$
          (%i2) specint(kbateman[v](z)*exp(-s*z),z);
                                         v        v   s - 1
                        2 %f    ([2, 1 - -], [2 - -], -----)
                            2, 1         2        2   s + 1
          (%o2)         ------------------------------------
                                2           v        v
                         (s + 1)  gamma(2 - -) gamma(- + 1)
                                            2        2

 -- Function: nzeta (<z>)
     The Plasma Dispersion Function nzeta(z) =
     %i*sqrt(%pi)*exp(-z^2)*(1-erf(-%i*z))

 -- Function: nzetar (<z>)
     Returns ‘realpart(nzeta(z))’.

 -- Function: nzetai (<z>)
     Returns ‘imagpart(nzeta(z))’.


File: maxima.info,  Node: Эллиптические функции,  Next: Пределы,  Prev: Special Functions,  Up: Top

15 Эллиптические функции
************************

* Menu:

* Эллиптические функции и интегралы в Maxima::
* Функции и переменные для эллиптических функций::
* Функции и переменные для эллиптических интегралов::


File: maxima.info,  Node: Эллиптические функции и интегралы в Maxima,  Next: Функции и переменные для эллиптических функций,  Up: Top

15.1 Эллиптические функции и интегралы в Maxima
===============================================

Maxima поддерживает работу с эллиптическими функциями Якоби, а также
полными и неполными эллиптическими интегралами - как символьную
манипуляцию, так и численные расчеты.  Определение этих функций и
множество их свойств можно найти в главах 16, 17 справочника Abramowitz,
Stegun.  Мы используем определения и отношения из книги Абрамовица и
Стиган там, где это возможно.

   В частности, все эллиптические функции и нтегралы используют параметр
m вместо модуля k или амплитуды \alpha.  Это единственное расхождение с
Амбрамовицем и Стиган, которые используют для эллиптических функций
амплитуду.  Действуют следующие отношения: m = k^2 и k = \sin(\alpha)

   В первую очередь упор делался на символьные вычисления с
эллиптическими функциями и интегралами.  Поэтому известно большинство
производных для функций и интегралов.  Однако, если в какчестве
параметра заданы числа с плавающей точкой, то возвращается численное
значение.

   Поддержка большинства других свойств эллиптических функций и
интегралов, помимо выражения их производных, еще не реализована.

   Несколько примеров для эллиптических функций:
     (%i1) jacobi_sn (u, m);
     (%o1)                    jacobi_sn(u, m)
     (%i2) jacobi_sn (u, 1);
     (%o2)                        tanh(u)
     (%i3) jacobi_sn (u, 0);
     (%o3)                        sin(u)
     (%i4) diff (jacobi_sn (u, m), u);
     (%o4)            jacobi_cn(u, m) jacobi_dn(u, m)
     (%i5) diff (jacobi_sn (u, m), m);
     (%o5) jacobi_cn(u, m) jacobi_dn(u, m)

           elliptic_e(asin(jacobi_sn(u, m)), m)
      (u - ------------------------------------)/(2 m)
                          1 - m

                 2
        jacobi_cn (u, m) jacobi_sn(u, m)
      + --------------------------------
                   2 (1 - m)

   Несколько примеров для эллиптических интегралов:
     (%i1) elliptic_f (phi, m);
     (%o1)                  elliptic_f(phi, m)
     (%i2) elliptic_f (phi, 0);
     (%o2)                          phi
     (%i3) elliptic_f (phi, 1);
                                    phi   %pi
     (%o3)                  log(tan(--- + ---))
                                     2     4
     (%i4) elliptic_e (phi, 1);
     (%o4)                       sin(phi)
     (%i5) elliptic_e (phi, 0);
     (%o5)                          phi
     (%i6) elliptic_kc (1/2);
                                          1
     (%o6)                    elliptic_kc(-)
                                          2
     (%i7) makegamma (%);
                                      2 1
                                 gamma (-)
                                        4
     (%o7)                      -----------
                                4 sqrt(%pi)
     (%i8) diff (elliptic_f (phi, m), phi);
                                     1
     (%o8)                 ---------------------
                                         2
                           sqrt(1 - m sin (phi))
     (%i9) diff (elliptic_f (phi, m), m);
            elliptic_e(phi, m) - (1 - m) elliptic_f(phi, m)
     (%o9) (-----------------------------------------------
                                   m

                                      cos(phi) sin(phi)
                                  - ---------------------)/(2 (1 - m))
                                                  2
                                    sqrt(1 - m sin (phi))

   Поддержку эллиптических функций и интегралов реализовал Реймонд Той,
и его код доступен под лицензии GPL, как и весь код Maxima.


File: maxima.info,  Node: Функции и переменные для эллиптических функций,  Next: Функции и переменные для эллиптических интегралов,  Prev: Эллиптические функции и интегралы в Maxima,  Up: Top

15.2 Функции и переменные для эллиптических функций
===================================================

 -- Функция: jacobi_sn (<u>, <m>)
     Эллиптическая функция Якоби sn(u,m).

 -- Функция: jacobi_cn (<u>, <m>)
     Эллиптическая функция Якоби cn(u,m).

 -- Функция: jacobi_dn (<u>, <m>)
     Эллиптическая функция Якоби dn(u,m).

 -- Функция: jacobi_ns (<u>, <m>)
     Эллиптическая функция Якоби ns(u,m) = 1/sn(u,m).

 -- Функция: jacobi_sc (<u>, <m>)
     Эллиптическая функция Якоби sc(u,m) = sn(u,m)/cn(u,m).

 -- Функция: jacobi_sd (<u>, <m>)
     Эллиптическая функция Якоби sd(u,m) = sn(u,m)/dn(u,m).

 -- Функция: jacobi_nc (<u>, <m>)
     Эллиптическая функция Якоби nc(u,m) = 1/cn(u,m).

 -- Функция: jacobi_cs (<u>, <m>)
     Эллиптическая функция Якоби cs(u,m) = cn(u,m)/sn(u,m).

 -- Функция: jacobi_cd (<u>, <m>)
     Эллиптическая функция Якоби cd(u,m) = cn(u,m)/dn(u,m).

 -- Функция: jacobi_nd (<u>, <m>)
     Эллиптическая функция Якоби nc(u,m) = 1/cn(u,m).

 -- Функция: jacobi_ds (<u>, <m>)
     Эллиптическая функция Якоби ds(u,m) = dn(u,m)/sn(u,m).

 -- Функция: jacobi_dc (<u>, <m>)
     Эллиптическая функция Якоби dc(u,m) = dn(u,m)/cn(u,m).

 -- Функция: inverse_jacobi_sn (<u>, <m>)
     Обратная эллиптическая функция Якоби для sn(u,m).

 -- Функция: inverse_jacobi_cn (<u>, <m>)
     Обратная эллиптическая функция Якоби для cn(u,m).

 -- Функция: inverse_jacobi_dn (<u>, <m>)
     Обратная эллиптическая функция Якоби для dn(u,m).

 -- Функция: inverse_jacobi_ns (<u>, <m>)
     Обратная эллиптическая функция Якоби для ns(u,m).

 -- Функция: inverse_jacobi_sc (<u>, <m>)
     Обратная эллиптическая функция Якоби для sc(u,m).

 -- Функция: inverse_jacobi_sd (<u>, <m>)
     Обратная эллиптическая функция Якоби для sd(u,m).

 -- Функция: inverse_jacobi_nc (<u>, <m>)
     Обратная эллиптическая функция Якоби для nc(u,m).

 -- Функция: inverse_jacobi_cs (<u>, <m>)
     Обратная эллиптическая функция Якоби для cs(u,m).

 -- Функция: inverse_jacobi_cd (<u>, <m>)
     Обратная эллиптическая функция Якоби для cd(u,m).

 -- Функция: inverse_jacobi_nd (<u>, <m>)
     Обратная эллиптическая функция Якоби для nc(u,m).

 -- Функция: inverse_jacobi_ds (<u>, <m>)
     Обратная эллиптическая функция Якоби для ds(u,m).

 -- Функция: inverse_jacobi_dc (<u>, <m>)
     Обратная эллиптическая функция Якоби для dc(u,m).


File: maxima.info,  Node: Функции и переменные для эллиптических интегралов,  Next: Функции и переменные для эллиптических функций,  Prev: Top

15.3 Функции и переменные для эллиптических интегралов
======================================================

 -- Функция: elliptic_f (<phi>, <m>)
     Неполный эллиптический интеграл первого рода, заданный в виде

     integrate(1/sqrt(1 - m*sin(x)^2), x, 0, phi)

     См.  также *note elliptic_e:: и *note elliptic_kc::.

 -- Функция: elliptic_e (<phi>, <m>)
     Неполный эллиптический интеграл второго рода, заданный в виде

     elliptic_e(u, m) = integrate(sqrt(1 - m*sin(x)^2), x, 0, phi)

     См.  также *note elliptic_e:: и *note elliptic_ec::.

 -- Функция: elliptic_eu (<u>, <m>)
     Неполный эллиптический интеграл второго рода, заданный в виде

     integrate(dn(v,m)^2,v,0,u) = integrate(sqrt(1-m*t^2)/sqrt(1-t^2),
     t, 0, tau)

     где tau = sn(u,m)

     Это связано с elliptic_e отношением elliptic_eu(u, m) =
     elliptic_e(asin(sn(u,m)),m) См.  также *note elliptic_e::.

 -- Функция: elliptic_pi (<n>, <phi>, <m>)
     Неполный эллиптический интеграл третьего рода, заданный в виде

     integrate(1/(1-n*sin(x)^2)/sqrt(1 - m*sin(x)^2), x, 0, phi)

     Для Maxima известна только производная по phi.

 -- Функция: elliptic_kc (<m>)
     Полный эллиптический интеграл первого рода, заданный в виде

     integrate(1/sqrt(1 - m*sin(x)^2), x, 0, %pi/2)

     Для конкретных значений m значение интеграла выражается через
     гамма-функцию.  Для вычисления используйте ‘makegamma’.

 -- Функция: elliptic_ec (<m>)
     Полный эллиптический интеграл второго рода, заданный в виде

     integrate(sqrt(1 - m*sin(x)^2), x, 0, %pi/2)

     Для конкретных значений m значение интеграла выражается через
     гамма-функцию.  Для вычисления используйте ‘makegamma’.


File: maxima.info,  Node: Пределы,  Next: Differentiation,  Prev: Эллиптические функции,  Up: Top

16 Пределы
**********

* Menu:

* Функции для работы с пределами::


File: maxima.info,  Node: Функции для работы с пределами,  Prev: Пределы,  Up: Пределы

16.1 Функции для работы с пределами
===================================

 -- Управляющая переменная: lhospitallim
     Значение по умолчанию: 4

     ‘lhospitallim’ есть максимальное число применений правила Лопиталя
     в ‘limit’.  Это предотвращает зацикливание в случаях вроде ‘limit
     (cot(x)/csc(x), x, 0)’.

 -- Функция: limit (<expr>, <x>, <val>, <dir>)
 -- Функция: limit (<expr>, <x>, <val>)
 -- Функция: limit (<expr>)
     Рассчитывает предел <expr> при стремлении вещественной переменной
     <x> к <val> по направлению <dir>.  <dir> может иметь значение
     ‘plus’ для предела справа, ‘minus’ для предела слева, либо
     опускаться (будет рассчитан двусторонний предел).

     ‘limit’ использует специальные символы: ‘inf’ (плюс бесконечность)
     и ‘minf’ (минус бесконечность).  Вывод может использовать ‘und’
     (неопределенность), ‘ind’ (неопределенность, но ограниченность) и
     ‘infinity’ (комплексная бесконечность).

     ‘lhospitallim’ есть максимальное число применений правила Лопиталя
     в ‘limit’.  Это предотвращает зацикливание в случаях вроде ‘limit
     (cot(x)/csc(x), x, 0)’.

     Если ‘tlimswitch’ равно ‘true’, команда ‘limit’ использует
     разложение в ряды Тейлора там, где это возможно.

     ‘limsubst’ предотвращает подстановки над неизвестными формами в
     ‘limit’.  Это позволяет избежать ошибок, когда выражение вида
     ‘limit (f(n)/f(n+1), n, inf)’ дает 1.  Подобные подстановки будут
     использоваться, если ‘limsubst’ равно ‘true’.

     ‘limit’ с одним аргументом часто вызывается для упрощения
     константных выражений, например ‘limit (inf-1)’.

     ‘example (limit)’ выводит некоторые примеры.

     Относительно метода см.  Wang, P., "Evaluation of Definite
     Integrals by Symbolic Manipulation", Ph.D. thesis, MAC TR-92,
     October 1971.

 -- Управляющая переменная: limsubst
     Значение по умолчанию: ‘false’ – предотвращает подстановки над
     неизвестными формами в ‘limit’.  Это позволяет избежать ошибок,
     когда выражение вида ‘limit (f(n)/f(n+1), n, inf)’ дает 1.
     Подобные подстановки будут использоваться, если ‘limsubst’ равно
     ‘true’.

 -- Функция: tlimit (<expr>, <x>, <val>, <dir>)
 -- Функция: tlimit (<expr>, <x>, <val>)
 -- Функция: tlimit (<expr>)
     Вычисляет предел разложения выражения ‘expr’ в ряд Тейлора в точке
     ‘x’ равной ‘val’ с направления ‘dir’.

 -- Управляющая переменная: tlimswitch
     Значение по умолчанию: ‘true’

     Если значение ‘tlimswitch’ равно ‘true’, то команда ‘limit’ будет
     использовать разложение в ряд Тейлора, если предел выражения не
     может быть вычислен непосредственно.  Это позволяет вычислять
     пределы типа ‘limit(x/(x-1)-1/log(x),x,1,plus)’.  Если значение
     ‘tlimswitch’ равно ‘false’ и предел выражения не может быть
     вычислен непосредственно, то ‘limit’ возвращает исходное выражение
     предела невычисленным.


File: maxima.info,  Node: Differentiation,  Next: Integration,  Prev: Пределы,  Up: Top

17 Differentiation
******************

* Menu:

* Functions and Variables for Differentiation::


File: maxima.info,  Node: Functions and Variables for Differentiation,  Prev: Differentiation,  Up: Differentiation

17.1 Functions and Variables for Differentiation
================================================

 -- Function: antid (<expr>, <x>, <u(x)>)

     Returns a two-element list, such that an antiderivative of <expr>
     with respect to <x> can be constructed from the list.  The
     expression <expr> may contain an unknown function <u> and its
     derivatives.

     Let <L>, a list of two elements, be the return value of ‘antid’.
     Then ‘<L>[1] + 'integrate (<L>[2], <x>)’ is an antiderivative of
     <expr> with respect to <x>.

     When ‘antid’ succeeds entirely, the second element of the return
     value is zero.  Otherwise, the second element is nonzero, and the
     first element is nonzero or zero.  If ‘antid’ cannot make any
     progress, the first element is zero and the second nonzero.

     ‘load ("antid")’ loads this function.  The ‘antid’ package also
     defines the functions ‘nonzeroandfreeof’ and ‘linear’.

     ‘antid’ is related to ‘antidiff’ as follows.  Let <L>, a list of
     two elements, be the return value of ‘antid’.  Then the return
     value of ‘antidiff’ is equal to ‘<L>[1] + 'integrate (<L>[2], <x>)’
     where <x> is the variable of integration.

     Examples:

          (%i1) load ("antid")$
          (%i2) expr: exp (z(x)) * diff (z(x), x) * y(x);
                                 z(x)       d
          (%o2)                %e     y(x) (-- (z(x)))
                                            dx
          (%i3) a1: antid (expr, x, z(x));
                            z(x)           z(x)  d
          (%o3)          [%e     y(x), - %e     (-- (y(x)))]
                                                 dx
          (%i4) a2: antidiff (expr, x, z(x));
                                      /
                          z(x)        |   z(x)  d
          (%o4)         %e     y(x) - | %e     (-- (y(x))) dx
                                      |         dx
                                      /
          (%i5) a2 - (first (a1) + 'integrate (second (a1), x));
          (%o5)                           0
          (%i6) antid (expr, x, y(x));
                                  z(x)       d
          (%o6)             [0, %e     y(x) (-- (z(x)))]
                                             dx
          (%i7) antidiff (expr, x, y(x));
                            /
                            |   z(x)       d
          (%o7)             | %e     y(x) (-- (z(x))) dx
                            |              dx
                            /

 -- Function: antidiff (<expr>, <x>, <u>(<x>))

     Returns an antiderivative of <expr> with respect to <x>.  The
     expression <expr> may contain an unknown function <u> and its
     derivatives.

     When ‘antidiff’ succeeds entirely, the resulting expression is free
     of integral signs (that is, free of the ‘integrate’ noun).
     Otherwise, ‘antidiff’ returns an expression which is partly or
     entirely within an integral sign.  If ‘antidiff’ cannot make any
     progress, the return value is entirely within an integral sign.

     ‘load ("antid")’ loads this function.  The ‘antid’ package also
     defines the functions ‘nonzeroandfreeof’ and ‘linear’.

     ‘antidiff’ is related to ‘antid’ as follows.  Let <L>, a list of
     two elements, be the return value of ‘antid’.  Then the return
     value of ‘antidiff’ is equal to ‘<L>[1] + 'integrate (<L>[2], <x>)’
     where <x> is the variable of integration.

     Examples:

          (%i1) load ("antid")$
          (%i2) expr: exp (z(x)) * diff (z(x), x) * y(x);
                                 z(x)       d
          (%o2)                %e     y(x) (-- (z(x)))
                                            dx
          (%i3) a1: antid (expr, x, z(x));
                            z(x)           z(x)  d
          (%o3)          [%e     y(x), - %e     (-- (y(x)))]
                                                 dx
          (%i4) a2: antidiff (expr, x, z(x));
                                      /
                          z(x)        |   z(x)  d
          (%o4)         %e     y(x) - | %e     (-- (y(x))) dx
                                      |         dx
                                      /
          (%i5) a2 - (first (a1) + 'integrate (second (a1), x));
          (%o5)                           0
          (%i6) antid (expr, x, y(x));
                                  z(x)       d
          (%o6)             [0, %e     y(x) (-- (z(x)))]
                                             dx
          (%i7) antidiff (expr, x, y(x));
                            /
                            |   z(x)       d
          (%o7)             | %e     y(x) (-- (z(x))) dx
                            |              dx
                            /

 -- Function: at
          at (<expr>, [<eqn_1>, ..., <eqn_n>])
          at (<expr>, <eqn>)

     Evaluates the expression <expr> with the variables assuming the
     values as specified for them in the list of equations ‘[<eqn_1>,
     ..., <eqn_n>]’ or the single equation <eqn>.

     If a subexpression depends on any of the variables for which a
     value is specified but there is no ‘atvalue’ specified and it can’t
     be otherwise evaluated, then a noun form of the ‘at’ is returned
     which displays in a two-dimensional form.

     ‘at’ carries out multiple substitutions in parallel.

     See also ‘atvalue’.  For other functions which carry out
     substitutions, see also ‘subst’ and ‘ev’.

     Examples:

          (%i1) atvalue (f(x,y), [x = 0, y = 1], a^2);
                                          2
          (%o1)                          a
          (%i2) atvalue ('diff (f(x,y), x), x = 0, 1 + y);
          (%o2)                        @2 + 1
          (%i3) printprops (all, atvalue);
                                          |
                            d             |
                           --- (f(@1, @2))|       = @2 + 1
                           d@1            |
                                          |@1 = 0

                                               2
                                    f(0, 1) = a

          (%o3)                         done
          (%i4) diff (4*f(x, y)^2 - u(x, y)^2, x);
                            d                          d
          (%o4)  8 f(x, y) (-- (f(x, y))) - 2 u(x, y) (-- (u(x, y)))
                            dx                         dx
          (%i5) at (%, [x = 0, y = 1]);
                                                      |
                           2              d           |
          (%o5)        16 a  - 2 u(0, 1) (-- (u(x, 1))|     )
                                          dx          |
                                                      |x = 0

     Note that in the last line ‘y’ is treated differently to ‘x’ as ‘y’
     isn’t used as a differentiation variable.

     The difference between ‘subst’, ‘at’ and ‘ev’ can be seen in the
     following example:

          (%i1) e1:I(t)=C*diff(U(t),t)$
          (%i2) e2:U(t)=L*diff(I(t),t)$
          (%i3) at(e1,e2);
                                         |
                                d        |
          (%o3)       I(t) = C (-- (U(t))|                    )
                                dt       |          d
                                         |U(t) = L (-- (I(t)))
                                                    dt
          (%i4) subst(e2,e1);
                                      d      d
          (%o4)             I(t) = C (-- (L (-- (I(t)))))
                                      dt     dt
          (%i5) ev(e1,e2,diff);
                                            2
                                           d
          (%o5)                I(t) = C L (--- (I(t)))
                                             2
                                           dt

 -- Property: atomgrad

     ‘atomgrad’ is the atomic gradient property of an expression.  This
     property is assigned by ‘gradef’.

 -- Function: atvalue
          atvalue (<expr>, [<x_1> = <a_1>, ..., <x_m> = <a_m>], <c>)
          atvalue (<expr>, <x_1> = <a_1>, <c>)

     Assigns the value <c> to <expr> at the point ‘<x> = <a>’.
     Typically boundary values are established by this mechanism.

     <expr> is a function evaluation, ‘<f>(<x_1>, ..., <x_m>)’, or a
     derivative, ‘diff (<f>(<x_1>, ..., <x_m>), <x_1>, <n_1>, ...,
     <x_n>, <n_m>)’ in which the function arguments explicitly appear.
     <n_i> is the order of differentiation with respect to <x_i>.

     The point at which the atvalue is established is given by the list
     of equations ‘[<x_1> = <a_1>, ..., <x_m> = <a_m>]’.  If there is a
     single variable <x_1>, the sole equation may be given without
     enclosing it in a list.

     ‘printprops ([<f_1>, <f_2>, ...], atvalue)’ displays the atvalues
     of the functions ‘<f_1>, <f_2>, ...’ as specified by calls to
     ‘atvalue’.  ‘printprops (<f>, atvalue)’ displays the atvalues of
     one function <f>.  ‘printprops (all, atvalue)’ displays the
     atvalues of all functions for which atvalues are defined.

     The symbols ‘@1’, ‘@2’, ... represent the variables <x_1>, <x_2>,
     ... when atvalues are displayed.

     ‘atvalue’ evaluates its arguments.  ‘atvalue’ returns <c>, the
     atvalue.

     See also ‘at’.

     Examples:

          (%i1) atvalue (f(x,y), [x = 0, y = 1], a^2);
                                          2
          (%o1)                          a
          (%i2) atvalue ('diff (f(x,y), x), x = 0, 1 + y);
          (%o2)                        @2 + 1
          (%i3) printprops (all, atvalue);
                                          |
                            d             |
                           --- (f(@1, @2))|       = @2 + 1
                           d@1            |
                                          |@1 = 0

                                               2
                                    f(0, 1) = a

          (%o3)                         done
          (%i4) diff (4*f(x,y)^2 - u(x,y)^2, x);
                            d                          d
          (%o4)  8 f(x, y) (-- (f(x, y))) - 2 u(x, y) (-- (u(x, y)))
                            dx                         dx
          (%i5) at (%, [x = 0, y = 1]);
                                                      |
                           2              d           |
          (%o5)        16 a  - 2 u(0, 1) (-- (u(x, 1))|     )
                                          dx          |
                                                      |x = 0

 -- Function: del (<x>)

     ‘del (<x>)’ represents the differential of the variable x.

     ‘diff’ returns an expression containing ‘del’ if an independent
     variable is not specified.  In this case, the return value is the
     so-called "total differential".

     See also ‘diff’, ‘del’ and ‘derivdegree’.

     Examples:

          (%i1) diff (log (x));
                                       del(x)
          (%o1)                        ------
                                         x
          (%i2) diff (exp (x*y));
                             x y              x y
          (%o2)            %e    x del(y) + %e    y del(x)
          (%i3) diff (x*y*z);
          (%o3)         x y del(z) + x z del(y) + y z del(x)

 -- Function: delta (<t>)

     The Dirac Delta function.

     Currently only ‘laplace’ knows about the ‘delta’ function.

     Example:

          (%i1) assume(a > 0)$
          (%i2) laplace (delta (t - a) * sin(b*t), t, s);
                            2 %i a b        - a s - %i a b
                         (%e         - 1) %e               %i
          (%o2)        - ------------------------------------
                                          2

 -- System variable: dependencies
 -- Function: dependencies (<f_1>, ..., <f_n>)

     The variable ‘dependencies’ is the list of atoms which have
     functional dependencies, assigned by ‘depends’, the function
     ‘dependencies’, or ‘gradef’.  The ‘dependencies’ list is
     cumulative: each call to ‘depends’, ‘dependencies’, or ‘gradef’
     appends additional items.  The default value of ‘dependencies’ is
     ‘[]’.

     The function ‘dependencies(<f_1>, ..., <f_n>)’ appends <f_1>, ...,
     <f_n>, to the ‘dependencies’ list, where <f_1>, ..., <f_n> are
     expressions of the form ‘<f>(<x_1>, ..., <x_m>)’, and <x_1>, ...,
     <x_m> are any number of arguments.

     ‘dependencies(<f>(<x_1>, ..., <x_m>))’ is equivalent to
     ‘depends(<f>, [<x_1>, ..., <x_m>])’.

     See also ‘depends’ and ‘gradef’.

          (%i1) dependencies;
          (%o1)                          []
          (%i2) depends (foo, [bar, baz]);
          (%o2)                    [foo(bar, baz)]
          (%i3) depends ([g, h], [a, b, c]);
          (%o3)               [g(a, b, c), h(a, b, c)]
          (%i4) dependencies;
          (%o4)        [foo(bar, baz), g(a, b, c), h(a, b, c)]
          (%i5) dependencies (quux (x, y), mumble (u));
          (%o5)                [quux(x, y), mumble(u)]
          (%i6) dependencies;
          (%o6) [foo(bar, baz), g(a, b, c), h(a, b, c), quux(x, y),
                                                                 mumble(u)]
          (%i7) remove (quux, dependency);
          (%o7)                         done
          (%i8) dependencies;
          (%o8)  [foo(bar, baz), g(a, b, c), h(a, b, c), mumble(u)]

 -- Function: depends (<f_1>, <x_1>, ..., <f_n>, <x_n>)

     Declares functional dependencies among variables for the purpose of
     computing derivatives.  In the absence of declared dependence,
     ‘diff (f, x)’ yields zero.  If ‘depends (f, x)’ is declared, ‘diff
     (f, x)’ yields a symbolic derivative (that is, a ‘diff’ noun).

     Each argument <f_1>, <x_1>, etc., can be the name of a variable or
     array, or a list of names.  Every element of <f_i> (perhaps just a
     single element) is declared to depend on every element of <x_i>
     (perhaps just a single element).  If some <f_i> is the name of an
     array or contains the name of an array, all elements of the array
     depend on <x_i>.

     ‘diff’ recognizes indirect dependencies established by ‘depends’
     and applies the chain rule in these cases.

     ‘remove (<f>, dependency)’ removes all dependencies declared for
     <f>.

     ‘depends’ returns a list of the dependencies established.  The
     dependencies are appended to the global variable ‘dependencies’.
     ‘depends’ evaluates its arguments.

     ‘diff’ is the only Maxima command which recognizes dependencies
     established by ‘depends’.  Other functions (‘integrate’, ‘laplace’,
     etc.)  only recognize dependencies explicitly represented by their
     arguments.  For example, ‘integrate’ does not recognize the
     dependence of ‘f’ on ‘x’ unless explicitly represented as
     ‘integrate (f(x), x)’.

     ‘depends(<f>, [<x_1>, ..., <x_n>])’ is equivalent to
     ‘dependencies(<f>(<x_1>, ..., <x_n>))’.

     See also ‘diff’, ‘del’, ‘derivdegree’ and ‘derivabbrev’.

          (%i1) depends ([f, g], x);
          (%o1)                     [f(x), g(x)]
          (%i2) depends ([r, s], [u, v, w]);
          (%o2)               [r(u, v, w), s(u, v, w)]
          (%i3) depends (u, t);
          (%o3)                        [u(t)]
          (%i4) dependencies;
          (%o4)      [f(x), g(x), r(u, v, w), s(u, v, w), u(t)]
          (%i5) diff (r.s, u);
                                   dr            ds
          (%o5)                   (--) . s + r . --
                                   du            du

          (%i1) diff (r.s, t);
          (%o1)                           0

          (%i1) remove (r, dependency);
          (%o1)                         done
          (%i2) diff (r.s, t);
          (%o2)                           0

 -- Option variable: derivabbrev
     Default value: ‘false’

     When ‘derivabbrev’ is ‘true’, symbolic derivatives (that is, ‘diff’
     nouns) are displayed as subscripts.  Otherwise, derivatives are
     displayed in the Leibniz notation ‘dy/dx’.

 -- Function: derivdegree (<expr>, <y>, <x>)

     Returns the highest degree of the derivative of the dependent
     variable <y> with respect to the independent variable <x> occurring
     in <expr>.

     Example:

          (%i1) 'diff (y, x, 2) + 'diff (y, z, 3) + 'diff (y, x) * x^2;
                                   3     2
                                  d y   d y    2 dy
          (%o1)                   --- + --- + x  --
                                    3     2      dx
                                  dz    dx
          (%i2) derivdegree (%, y, x);
          (%o2)                           2

 -- Function: derivlist (<var_1>, ..., <var_k>)

     Causes only differentiations with respect to the indicated
     variables, within the ‘ev’ command.

 -- Option variable: derivsubst
     Default value: ‘false’

     When ‘derivsubst’ is ‘true’, a non-syntactic substitution such as
     ‘subst (x, 'diff (y, t), 'diff (y, t, 2))’ yields ‘'diff (x, t)’.

 -- Function: diff
          diff (<expr>, <x_1>, <n_1>, ..., <x_m>, <n_m>)
          diff (<expr>, <x>, <n>)
          diff (<expr>, <x>)
          diff (<expr>)

     Returns the derivative or differential of <expr> with respect to
     some or all variables in <expr>.

     ‘diff (<expr>, <x>, <n>)’ returns the <n>’th derivative of <expr>
     with respect to <x>.

     ‘diff (<expr>, <x_1>, <n_1>, ..., <x_m>, <n_m>)’ returns the mixed
     partial derivative of <expr> with respect to <x_1>, ..., <x_m>.  It
     is equivalent to ‘diff (... (diff (<expr>, <x_m>, <n_m>) ...),
     <x_1>, <n_1>)’.

     ‘diff (<expr>, <x>)’ returns the first derivative of <expr> with
     respect to the variable <x>.

     ‘diff (<expr>)’ returns the total differential of <expr>, that is,
     the sum of the derivatives of <expr> with respect to each its
     variables times the differential ‘del’ of each variable.  No
     further simplification of ‘del’ is offered.

     The noun form of ‘diff’ is required in some contexts, such as
     stating a differential equation.  In these cases, ‘diff’ may be
     quoted (as ‘'diff’) to yield the noun form instead of carrying out
     the differentiation.

     When ‘derivabbrev’ is ‘true’, derivatives are displayed as
     subscripts.  Otherwise, derivatives are displayed in the Leibniz
     notation, ‘dy/dx’.

     See also ‘depends’, ‘del’, ‘derivdegree’, ‘derivabbrev’, and
     ‘gradef’.

     Examples:

          (%i1) diff (exp (f(x)), x, 2);
                               2
                        f(x)  d               f(x)  d         2
          (%o1)       %e     (--- (f(x))) + %e     (-- (f(x)))
                                2                   dx
                              dx
          (%i2) derivabbrev: true$
          (%i3) 'integrate (f(x, y), y, g(x), h(x));
                                   h(x)
                                  /
                                  |
          (%o3)                   |     f(x, y) dy
                                  |
                                  /
                                   g(x)
          (%i4) diff (%, x);
                 h(x)
                /
                |
          (%o4) |     (f(x, y))  dy + f(x, h(x)) (h(x))
                |              x                       x
                /
                 g(x)
                                                       - f(x, g(x)) (g(x))
                                                                          x

     For the tensor package, the following modifications have been
     incorporated:

     (1) The derivatives of any indexed objects in <expr> will have the
     variables <x_i> appended as additional arguments.  Then all the
     derivative indices will be sorted.

     (2) The <x_i> may be integers from 1 up to the value of the
     variable ‘dimension’ [default value: 4].  This will cause the
     differentiation to be carried out with respect to the <x_i>’th
     member of the list ‘coordinates’ which should be set to a list of
     the names of the coordinates, e.g., ‘[x, y, z, t]’.  If
     ‘coordinates’ is bound to an atomic variable, then that variable
     subscripted by <x_i> will be used for the variable of
     differentiation.  This permits an array of coordinate names or
     subscripted names like ‘X[1]’, ‘X[2]’, ... to be used.  If
     ‘coordinates’ has not been assigned a value, then the variables
     will be treated as in (1) above.

 -- Special symbol: diff

     When ‘diff’ is present as an ‘evflag’ in call to ‘ev’, all
     differentiations indicated in ‘expr’ are carried out.

 -- Function: express (<expr>)

     Expands differential operator nouns into expressions in terms of
     partial derivatives.  ‘express’ recognizes the operators ‘grad’,
     ‘div’, ‘curl’, ‘laplacian’.  ‘express’ also expands the cross
     product ‘~’.

     Symbolic derivatives (that is, ‘diff’ nouns) in the return value of
     express may be evaluated by including ‘diff’ in the ‘ev’ function
     call or command line.  In this context, ‘diff’ acts as an ‘evfun’.

     ‘load ("vect")’ loads this function.

     Examples:

          (%i1) load ("vect")$
          (%i2) grad (x^2 + y^2 + z^2);
                                        2    2    2
          (%o2)                  grad (z  + y  + x )
          (%i3) express (%);
                 d    2    2    2   d    2    2    2   d    2    2    2
          (%o3) [-- (z  + y  + x ), -- (z  + y  + x ), -- (z  + y  + x )]
                 dx                 dy                 dz
          (%i4) ev (%, diff);
          (%o4)                    [2 x, 2 y, 2 z]
          (%i5) div ([x^2, y^2, z^2]);
                                        2   2   2
          (%o5)                   div [x , y , z ]
          (%i6) express (%);
                             d    2    d    2    d    2
          (%o6)              -- (z ) + -- (y ) + -- (x )
                             dz        dy        dx
          (%i7) ev (%, diff);
          (%o7)                    2 z + 2 y + 2 x
          (%i8) curl ([x^2, y^2, z^2]);
                                         2   2   2
          (%o8)                   curl [x , y , z ]
          (%i9) express (%);
                 d    2    d    2   d    2    d    2   d    2    d    2
          (%o9) [-- (z ) - -- (y ), -- (x ) - -- (z ), -- (y ) - -- (x )]
                 dy        dz       dz        dx       dx        dy
          (%i10) ev (%, diff);
          (%o10)                      [0, 0, 0]
          (%i11) laplacian (x^2 * y^2 * z^2);
                                            2  2  2
          (%o11)                laplacian (x  y  z )
          (%i12) express (%);
                   2                2                2
                  d     2  2  2    d     2  2  2    d     2  2  2
          (%o12)  --- (x  y  z ) + --- (x  y  z ) + --- (x  y  z )
                    2                2                2
                  dz               dy               dx
          (%i13) ev (%, diff);
                                2  2      2  2      2  2
          (%o13)             2 y  z  + 2 x  z  + 2 x  y
          (%i14) [a, b, c] ~ [x, y, z];
          (%o14)                [a, b, c] ~ [x, y, z]
          (%i15) express (%);
          (%o15)          [b z - c y, c x - a z, a y - b x]

 -- Function: gradef
          gradef (<f>(<x_1>, ..., <x_n>), <g_1>, ..., <g_m>)
          gradef (<a>, <x>, <expr>)

     Defines the partial derivatives (i.e., the components of the
     gradient) of the function <f> or variable <a>.

     ‘gradef (<f>(<x_1>, ..., <x_n>), <g_1>, ..., <g_m>)’ defines
     ‘d<f>/d<x_i>’ as <g_i>, where <g_i> is an expression; <g_i> may be
     a function call, but not the name of a function.  The number of
     partial derivatives <m> may be less than the number of arguments
     <n>, in which case derivatives are defined with respect to <x_1>
     through <x_m> only.

     ‘gradef (<a>, <x>, <expr>)’ defines the derivative of variable <a>
     with respect to <x> as <expr>.  This also establishes the
     dependence of <a> on <x> (via ‘depends (<a>, <x>)’).

     The first argument ‘<f>(<x_1>, ..., <x_n>)’ or <a> is quoted, but
     the remaining arguments <g_1>, ..., <g_m> are evaluated.  ‘gradef’
     returns the function or variable for which the partial derivatives
     are defined.

     ‘gradef’ can redefine the derivatives of Maxima’s built-in
     functions.  For example, ‘gradef (sin(x), sqrt (1 - sin(x)^2))’
     redefines the derivative of ‘sin’.

     ‘gradef’ cannot define partial derivatives for a subscripted
     function.

     ‘printprops ([<f_1>, ..., <f_n>], gradef)’ displays the partial
     derivatives of the functions <f_1>, ..., <f_n>, as defined by
     ‘gradef’.

     ‘printprops ([<a_n>, ..., <a_n>], atomgrad)’ displays the partial
     derivatives of the variables <a_n>, ..., <a_n>, as defined by
     ‘gradef’.

     ‘gradefs’ is the list of the functions for which partial
     derivatives have been defined by ‘gradef’.  ‘gradefs’ does not
     include any variables for which partial derivatives have been
     defined by ‘gradef’.

     Gradients are needed when, for example, a function is not known
     explicitly but its first derivatives are and it is desired to
     obtain higher order derivatives.

 -- System variable: gradefs
     Default value: ‘[]’

     ‘gradefs’ is the list of the functions for which partial
     derivatives have been defined by ‘gradef’.  ‘gradefs’ does not
     include any variables for which partial derivatives have been
     defined by ‘gradef’.


File: maxima.info,  Node: Integration,  Next: Equations,  Prev: Differentiation,  Up: Top

18 Integration
**************

* Menu:

* Introduction to Integration::
* Functions and Variables for Integration::
* Introduction to QUADPACK::
* Functions and Variables for QUADPACK::


File: maxima.info,  Node: Introduction to Integration,  Next: Functions and Variables for Integration,  Prev: Integration,  Up: Integration

18.1 Introduction to Integration
================================

Maxima has several routines for handling integration.  The ‘integrate’
function makes use of most of them.  There is also the ‘antid’ package,
which handles an unspecified function (and its derivatives, of course).
For numerical uses, there is a set of adaptive integrators from
QUADPACK, named ‘quad_qag’, ‘quad_qags’, etc., which are described under
the heading ‘QUADPACK’.  Hypergeometric functions are being worked on,
see ‘specint’ for details.  Generally speaking, Maxima only handles
integrals which are integrable in terms of the "elementary functions"
(rational functions, trigonometrics, logs, exponentials, radicals, etc.)
and a few extensions (error function, dilogarithm).  It does not handle
integrals in terms of unknown functions such as ‘g(x)’ and ‘h(x)’.


File: maxima.info,  Node: Functions and Variables for Integration,  Next: Introduction to QUADPACK,  Prev: Introduction to Integration,  Up: Integration

18.2 Functions and Variables for Integration
============================================

 -- Function: changevar (<expr>, <f(x,y)>, <y>, <x>)

     Makes the change of variable given by ‘<f(x,y)> = 0’ in all
     integrals occurring in <expr> with integration with respect to <x>.
     The new variable is <y>.

     The change of variable can also be written ‘<f(x)> = <g(y)>’.

          (%i1) assume(a > 0)$
          (%i2) 'integrate (%e**sqrt(a*y), y, 0, 4);
                                4
                               /
                               |    sqrt(a) sqrt(y)
          (%o2)                |  %e                dy
                               |
                               /
                                0
          (%i3) changevar (%, y-z^2/a, z, y);
                                0
                               /
                               |              abs(z)
                             2 |            %e       z dz
                               |
                               /
                                - 2 sqrt(a)
          (%o3)            - ----------------------------
                                          a

     An expression containing a noun form, such as the instances of
     ‘'integrate’ above, may be evaluated by ‘ev’ with the ‘nouns’ flag.
     For example, the expression returned by ‘changevar’ above may be
     evaluated by ‘ev (%o3, nouns)’.

     ‘changevar’ may also be used to make changes in the indices of a
     sum or product.  However, it must be realized that when a change is
     made in a sum or product, this change must be a shift, i.e., ‘i =
     j+ ...’, not a higher degree function.  E.g.,

          (%i1) sum (a[i]*x^(i-2), i, 0, inf);
                                   inf
                                   ____
                                   \         i - 2
          (%o1)                     >    a  x
                                   /      i
                                   ----
                                   i = 0
          (%i2) changevar (%, i-2-n, n, i);
                                  inf
                                  ____
                                  \               n
          (%o2)                    >      a      x
                                  /        n + 2
                                  ----
                                  n = - 2

 -- Function: dblint (<f>, <r>, <s>, <a>, <b>)

     A double-integral routine which was written in top-level Maxima and
     then translated and compiled to machine code.  Use ‘load
     ("dblint")’ to access this package.  It uses the Simpson’s rule
     method in both the x and y directions to calculate

          /b /s(x)
          |  |
          |  |    f(x,y) dy dx
          |  |
          /a /r(x)

     The function <f> must be a translated or compiled function of two
     variables, and <r> and <s> must each be a translated or compiled
     function of one variable, while <a> and <b> must be floating point
     numbers.  The routine has two global variables which determine the
     number of divisions of the x and y intervals: ‘dblint_x’ and
     ‘dblint_y’, both of which are initially 10, and can be changed
     independently to other integer values (there are ‘2*dblint_x+1’
     points computed in the x direction, and ‘2*dblint_y+1’ in the y
     direction).  The routine subdivides the X axis and then for each
     value of X it first computes ‘<r>(x)’ and ‘<s>(x)’; then the Y axis
     between ‘<r>(x)’ and ‘<s>(x)’ is subdivided and the integral along
     the Y axis is performed using Simpson’s rule; then the integral
     along the X axis is done using Simpson’s rule with the function
     values being the Y-integrals.  This procedure may be numerically
     unstable for a great variety of reasons, but is reasonably fast:
     avoid using it on highly oscillatory functions and functions with
     singularities (poles or branch points in the region).  The Y
     integrals depend on how far apart ‘<r>(x)’ and ‘<s>(x)’ are, so if
     the distance ‘<s>(x) - <r>(x)’ varies rapidly with X, there may be
     substantial errors arising from truncation with different
     step-sizes in the various Y integrals.  One can increase ‘dblint_x’
     and ‘dblint_y’ in an effort to improve the coverage of the region,
     at the expense of computation time.  The function values are not
     saved, so if the function is very time-consuming, you will have to
     wait for re-computation if you change anything (sorry).  It is
     required that the functions <f>, <r>, and <s> be either translated
     or compiled prior to calling ‘dblint’.  This will result in orders
     of magnitude speed improvement over interpreted code in many cases!

     ‘demo ("dblint")’ executes a demonstration of ‘dblint’ applied to
     an example problem.

 -- Function: defint (<expr>, <x>, <a>, <b>)

     Attempts to compute a definite integral.  ‘defint’ is called by
     ‘integrate’ when limits of integration are specified, i.e., when
     ‘integrate’ is called as ‘integrate (<expr>, <x>, <a>, <b>)’.  Thus
     from the user’s point of view, it is sufficient to call
     ‘integrate’.

     ‘defint’ returns a symbolic expression, either the computed
     integral or the noun form of the integral.  See ‘quad_qag’ and
     related functions for numerical approximation of definite
     integrals.

 -- Option variable: erfflag
     Default value: ‘true’

     When ‘erfflag’ is ‘false’, prevents ‘risch’ from introducing the
     ‘erf’ function in the answer if there were none in the integrand to
     begin with.

 -- Function: ilt (<expr>, <s>, <t>)

     Computes the inverse Laplace transform of <expr> with respect to
     <s> and parameter <t>.  <expr> must be a ratio of polynomials whose
     denominator has only linear and quadratic factors; there is an
     extension of ‘ilt’, called ‘pwilt’ (Piece-Wise Inverse Laplace
     Transform) that handles several other cases where ‘ilt’ fails.

     By using the functions ‘laplace’ and ‘ilt’ together with the
     ‘solve’ or ‘linsolve’ functions the user can solve a single
     differential or convolution integral equation or a set of them.

          (%i1) 'integrate (sinh(a*x)*f(t-x), x, 0, t) + b*f(t) = t**2;
                        t
                       /
                       |                                    2
          (%o1)        |  f(t - x) sinh(a x) dx + b f(t) = t
                       |
                       /
                        0
          (%i2) laplace (%, t, s);
                 a laplace(f(t), t, s)                           2
          (%o2)  --------------------- + b laplace(f(t), t, s) = --
                         2    2                                   3
                        s  - a                                   s
          (%i3) linsolve ([%], ['laplace(f(t), t, s)]);
                                                  2      2
                                               2 s  - 2 a
          (%o3)     [laplace(f(t), t, s) = --------------------]
                                              5         2     3
                                           b s  + (a - a  b) s
          (%i4) ilt (rhs (first (%)), s, t);
          Is a b (a b - 1) positive, negative or zero?
          pos;

                         sqrt(a b (a b - 1)) t
                  2 cosh(---------------------)       2
                                   b               a t
          (%o4) - ----------------------------- + -------
                        3  2      2               a b - 1
                       a  b  - 2 a  b + a
                                                                 2
                                                       + ------------------
                                                          3  2      2
                                                         a  b  - 2 a  b + a
          (%i5) pos;

 -- Option variable: intanalysis
     Default value: ‘true’

     When ‘true’, definite integration tries to find poles in the
     integrand in the interval of integration.  If there are, then the
     integral is evaluated appropriately as a principal value integral.
     If intanalysis is ‘false’, this check is not performed and
     integration is done assuming there are no poles.

     See also ‘ldefint’.

     Examples:

     Maxima can solve the following integrals, when ‘intanalysis’ is set
     to ‘false’:

          (%i1) intanalysis:false;
          (%o1)                         false
          (%i2) integrate(1/(sqrt(x+1)+1),x,0,1);
                                                        3/2
          (%o2)      - 2 log(sqrt(2) + 1) + 2 log(2) + 2    - 2
          (%i3) integrate(1/(sqrt(x)+1),x,0,1),intanalysis:false;
          (%o3)                     2 - 2 log(2)
          (%i4) integrate(cos(a)/sqrt((tan(a))^2+1),a,-%pi/2,%pi/2),intanalysis:false;
          (%o4)               %i log(2) - %i log(2 %i)
          (%i5) intanalysis:false$
          (%i6) integrate(cos(a)/sqrt((tan(a))^2 +1),a,-%pi/2,%pi/2);
          (%o6)               %i log(2) - %i log(2 %i)

 -- Function: integrate
          integrate (<expr>, <x>)
          integrate (<expr>, <x>, <a>, <b>)

     Attempts to symbolically compute the integral of <expr> with
     respect to <x>.  ‘integrate (<expr>, <x>)’ is an indefinite
     integral, while ‘integrate (<expr>, <x>, <a>, <b>)’ is a definite
     integral, with limits of integration <a> and <b>.  The limits
     should not contain <x>, although ‘integrate’ does not enforce this
     restriction.  <a> need not be less than <b>.  If <b> is equal to
     <a>, ‘integrate’ returns zero.

     See ‘quad_qag’ and related functions for numerical approximation of
     definite integrals.  See ‘residue’ for computation of residues
     (complex integration).  See ‘antid’ for an alternative means of
     computing indefinite integrals.

     The integral (an expression free of ‘integrate’) is returned if
     ‘integrate’ succeeds.  Otherwise the return value is the noun form
     of the integral (the quoted operator ‘'integrate’) or an expression
     containing one or more noun forms.  The noun form of ‘integrate’ is
     displayed with an integral sign.

     In some circumstances it is useful to construct a noun form by
     hand, by quoting ‘integrate’ with a single quote, e.g., ‘'integrate
     (<expr>, <x>)’.  For example, the integral may depend on some
     parameters which are not yet computed.  The noun may be applied to
     its arguments by ‘ev (<i>, nouns)’ where <i> is the noun form of
     interest.

     ‘integrate’ handles definite integrals separately from indefinite,
     and employs a range of heuristics to handle each case.  Special
     cases of definite integrals include limits of integration equal to
     zero or infinity (‘inf’ or ‘minf’), trigonometric functions with
     limits of integration equal to zero and ‘%pi’ or ‘2 %pi’, rational
     functions, integrals related to the definitions of the ‘beta’ and
     ‘psi’ functions, and some logarithmic and trigonometric integrals.
     Processing rational functions may include computation of residues.
     If an applicable special case is not found, an attempt will be made
     to compute the indefinite integral and evaluate it at the limits of
     integration.  This may include taking a limit as a limit of
     integration goes to infinity or negative infinity; see also
     ‘ldefint’.

     Special cases of indefinite integrals include trigonometric
     functions, exponential and logarithmic functions, and rational
     functions.  ‘integrate’ may also make use of a short table of
     elementary integrals.

     ‘integrate’ may carry out a change of variable if the integrand has
     the form ‘f(g(x)) * diff(g(x), x)’.  ‘integrate’ attempts to find a
     subexpression ‘g(x)’ such that the derivative of ‘g(x)’ divides the
     integrand.  This search may make use of derivatives defined by the
     ‘gradef’ function.  See also ‘changevar’ and ‘antid’.

     If none of the preceding heuristics find the indefinite integral,
     the Risch algorithm is executed.  The flag ‘risch’ may be set as an
     ‘evflag’, in a call to ‘ev’ or on the command line, e.g., ‘ev
     (integrate (<expr>, <x>), risch)’ or ‘integrate (<expr>, <x>),
     risch’.  If ‘risch’ is present, ‘integrate’ calls the ‘risch’
     function without attempting heuristics first.  See also ‘risch’.

     ‘integrate’ works only with functional relations represented
     explicitly with the ‘f(x)’ notation.  ‘integrate’ does not respect
     implicit dependencies established by the ‘depends’ function.

     ‘integrate’ may need to know some property of a parameter in the
     integrand.  ‘integrate’ will first consult the ‘assume’ database,
     and, if the variable of interest is not there, ‘integrate’ will ask
     the user.  Depending on the question, suitable responses are ‘yes;’
     or ‘no;’, or ‘pos;’, ‘zero;’, or ‘neg;’.

     ‘integrate’ is not, by default, declared to be linear.  See
     ‘declare’ and ‘linear’.

     ‘integrate’ attempts integration by parts only in a few special
     cases.

     Examples:

        • Elementary indefinite and definite integrals.

               (%i1) integrate (sin(x)^3, x);
                                          3
                                       cos (x)
               (%o1)                   ------- - cos(x)
                                          3
               (%i2) integrate (x/ sqrt (b^2 - x^2), x);
                                                2    2
               (%o2)                    - sqrt(b  - x )
               (%i3) integrate (cos(x)^2 * exp(x), x, 0, %pi);
                                              %pi
                                          3 %e      3
               (%o3)                      ------- - -
                                             5      5
               (%i4) integrate (x^2 * exp(-x^2), x, minf, inf);
                                           sqrt(%pi)
               (%o4)                       ---------
                                               2

        • Use of ‘assume’ and interactive query.

               (%i1) assume (a > 1)$
               (%i2) integrate (x**a/(x+1)**(5/2), x, 0, inf);
               Is a an integer?
               no;

               Is 2 a - 1 positive, negative or zero?
               neg;
                                           3
               (%o2)                  beta(- - a, a + 1)
                                           2
               Is 2 a - 1 positive, negative or zero?
               no;
                                           3
               (%o2)                  beta(- - a, a + 1)
                                           2
               (%i3) neg;

        • Change of variable.  There are two changes of variable in this
          example: one using a derivative established by ‘gradef’, and
          one using the derivation ‘diff(r(x))’ of an unspecified
          function ‘r(x)’.

               (%i1) gradef (q(x), sin(x**2));
               (%o1)                         q(x)
               (%i2) diff (log (q (r (x))), x);
                                     d               2
                                    (-- (r(x))) sin(r (x))
                                     dx
               (%o2)                ----------------------
                                           q(r(x))
               (%i3) integrate (%, x);
               (%o3)                     log(q(r(x)))

        • Return value contains the ‘'integrate’ noun form.  In this
          example, Maxima can extract one factor of the denominator of a
          rational function, but cannot factor the remainder or
          otherwise find its integral.  ‘grind’ shows the noun form
          ‘'integrate’ in the result.  See also ‘integrate_use_rootsof’
          for more on integrals of rational functions.

               (%i1) expand ((x-4) * (x^3+2*x+1));
                                   4      3      2
               (%o1)              x  - 4 x  + 2 x  - 7 x - 4
               (%i2) integrate (1/%, x);
                                             /  2
                                             | x  + 4 x + 18
                                             | ------------- dx
                                             |  3
                                log(x - 4)   / x  + 2 x + 1
               (%o2)            ---------- - ------------------
                                    73               73
               (%i3) grind (%);
               log(x-4)/73-('integrate((x^2+4*x+18)/(x^3+2*x+1),x))/73$
               (%o3)                         done

        • Defining a function in terms of an integral.  The body of a
          function is not evaluated when the function is defined.  Thus
          the body of ‘f_1’ in this example contains the noun form of
          ‘integrate’.  The quote-quote operator ‘''’ causes the
          integral to be evaluated, and the result becomes the body of
          ‘f_2’.

               (%i1) f_1 (a) := integrate (x^3, x, 1, a);
                                                    3
               (%o1)           f_1(a) := integrate(x , x, 1, a)
               (%i2) ev (f_1 (7), nouns);
               (%o2)                          600
               (%i3) /* Note parentheses around integrate(...) here */      f_2 (a) := ''(integrate (x^3, x, 1, a));
                                                  4
                                                 a    1
               (%o3)                   f_2(a) := -- - -
                                                 4    4
               (%i4) f_2 (7);
               (%o4)                          600

 -- System variable: integration_constant
     Default value: ‘%c’

     When a constant of integration is introduced by indefinite
     integration of an equation, the name of the constant is constructed
     by concatenating ‘integration_constant’ and
     ‘integration_constant_counter’.

     ‘integration_constant’ may be assigned any symbol.

     Examples:

          (%i1) integrate (x^2 = 1, x);
                                     3
                                    x
          (%o1)                     -- = x + %c1
                                    3
          (%i2) integration_constant : 'k;
          (%o2)                           k
          (%i3) integrate (x^2 = 1, x);
                                      3
                                     x
          (%o3)                      -- = x + k2
                                     3

 -- System variable: integration_constant_counter
     Default value: 0

     When a constant of integration is introduced by indefinite
     integration of an equation, the name of the constant is constructed
     by concatenating ‘integration_constant’ and
     ‘integration_constant_counter’.

     ‘integration_constant_counter’ is incremented before constructing
     the next integration constant.

     Examples:

          (%i1) integrate (x^2 = 1, x);
                                     3
                                    x
          (%o1)                     -- = x + %c1
                                    3
          (%i2) integrate (x^2 = 1, x);
                                     3
                                    x
          (%o2)                     -- = x + %c2
                                    3
          (%i3) integrate (x^2 = 1, x);
                                     3
                                    x
          (%o3)                     -- = x + %c3
                                    3
          (%i4) reset (integration_constant_counter);
          (%o4)            [integration_constant_counter]
          (%i5) integrate (x^2 = 1, x);
                                     3
                                    x
          (%o5)                     -- = x + %c1
                                    3

 -- Option variable: integrate_use_rootsof
     Default value: ‘false’

     When ‘integrate_use_rootsof’ is ‘true’ and the denominator of a
     rational function cannot be factored, ‘integrate’ returns the
     integral in a form which is a sum over the roots (not yet known) of
     the denominator.

     For example, with ‘integrate_use_rootsof’ set to ‘false’,
     ‘integrate’ returns an unsolved integral of a rational function in
     noun form:

          (%i1) integrate_use_rootsof: false$
          (%i2) integrate (1/(1+x+x^5), x);
                /  2
                | x  - 4 x + 5
                | ------------ dx                            2 x + 1
                |  3    2                2            5 atan(-------)
                / x  - x  + 1       log(x  + x + 1)          sqrt(3)
          (%o2) ----------------- - --------------- + ---------------
                        7                 14             7 sqrt(3)

     Now we set the flag to be true and the unsolved part of the
     integral will be expressed as a summation over the roots of the
     denominator of the rational function:

          (%i1) integrate_use_rootsof: true$
          (%i2) integrate (1/(1+x+x^5), x);
                 ____
                 \                                         2
          (%o2) ( >                                   ((%r1  - 4 %r1 + 5)
                 /
                 ----
                                   3      2
                 %r1 in rootsof(%r1  - %r1  + 1, %r1)
                                                    2
                               2               log(x  + x + 1)
           log(x - %r1))/(3 %r1  - 2 %r1))/7 - ---------------
                                                     14
                    2 x + 1
             5 atan(-------)
                    sqrt(3)
           + ---------------
                7 sqrt(3)

     Alternatively the user may compute the roots of the denominator
     separately, and then express the integrand in terms of these roots,
     e.g., ‘1/((x - a)*(x - b)*(x - c))’ or ‘1/((x^2 - (a+b)*x + a*b)*(x
     - c))’ if the denominator is a cubic polynomial.  Sometimes this
     will help Maxima obtain a more useful result.

 -- Function: laplace (<expr>, <t>, <s>)

     Attempts to compute the Laplace transform of <expr> with respect to
     the variable <t> and transform parameter <s>.  The Laplace
     transform of the function ‘f(t)’ is the one-sided transform defined
     by

          F(s) = integrate(f(t) * exp(-s*t), t, 0, inf)

     where F(s) is the transform of f(t), represented by <expr>.

     ‘laplace’ recognizes in <expr> the functions ‘delta’, ‘exp’, ‘log’,
     ‘sin’, ‘cos’, ‘sinh’, ‘cosh’, and ‘erf’, as well as ‘derivative’,
     ‘integrate’, ‘sum’, and ‘ilt’.  If ‘laplace’ fails to find a
     transform the function ‘specint’ is called.  ‘specint’ can find the
     laplace transform for expressions with special functions like the
     bessel functions ‘bessel_j’, ‘bessel_i’, ... and can handle the
     ‘unit_step’ function.  See also ‘specint’.

     If ‘specint’ cannot find a solution too, a noun ‘laplace’ is
     returned.

     <expr> may also be a linear, constant coefficient differential
     equation in which case ‘atvalue’ of the dependent variable is used.
     The required atvalue may be supplied either before or after the
     transform is computed.  Since the initial conditions must be
     specified at zero, if one has boundary conditions imposed elsewhere
     he can impose these on the general solution and eliminate the
     constants by solving the general solution for them and substituting
     their values back.

     ‘laplace’ recognizes convolution integrals of the form

          integrate (f(x) * g(t - x), x, 0, t)

     Other kinds of convolutions are not recognized.

     Functional relations must be explicitly represented in <expr>;
     implicit relations, established by ‘depends’, are not recognized.
     That is, if f depends on x and y, f (x, y) must appear in <expr>.

     See also ‘ilt’, the inverse Laplace transform.

     Examples:

          (%i1) laplace (exp (2*t + a) * sin(t) * t, t, s);
                                      a
                                    %e  (2 s - 4)
          (%o1)             -----------------------------
                             4      3       2
                            s  - 8 s  + 26 s  - 40 s + 25
          (%i2) laplace ('diff (f (x), x), x, s);
          (%o2)             s laplace(f(x), x, s) - f(0)
          (%i3) diff (diff (delta (t), t), t);
                                    2
                                   d
          (%o3)                    --- (delta(t))
                                     2
                                   dt
          (%i4) laplace (%, t, s);
                                      |
                         d            |         2
          (%o4)        - -- (delta(t))|      + s  - delta(0) s
                         dt           |
                                      |t = 0
          (%i5) assume(a>1)$
          (%i6) declare(a, integer)$
          (%i7) laplace(gamma_incomplete(a,t),t,s),gamma_expand:true;
                                                 - a - 1
                            gamma(a)   gamma(a) s
          (%o7)             -------- - -----------------
                               s            1     a
                                           (- + 1)
                                            s
          (%i8) factor(laplace(gamma_incomplete(1/2,t),t,s));
                                                 s + 1
                         sqrt(%pi) (sqrt(s) sqrt(-----) - 1)
                                                   s
          (%o8)          -----------------------------------
                                   3/2      s + 1
                                  s    sqrt(-----)
                                              s
          (%i9) assume(exp(%pi*s)>1, n > 0)$
          (%i10) laplace(sum((-1)^n*unit_step(t-n*%pi)*sin(t),n,0,inf),t,s),
            simpsum;
                                        %pi s
                                      %e
          (%o10)           ------------------------------
                              %pi s       2     %pi s
                           (%e      - 1) s  + %e      - 1

 -- Function: ldefint (<expr>, <x>, <a>, <b>)

     Attempts to compute the definite integral of <expr> by using
     ‘limit’ to evaluate the indefinite integral of <expr> with respect
     to <x> at the upper limit <b> and at the lower limit <a>.  If it
     fails to compute the definite integral, ‘ldefint’ returns an
     expression containing limits as noun forms.

     ‘ldefint’ is not called from ‘integrate’, so executing ‘ldefint
     (<expr>, <x>, <a>, <b>)’ may yield a different result than
     ‘integrate (<expr>, <x>, <a>, <b>)’.  ‘ldefint’ always uses the
     same method to evaluate the definite integral, while ‘integrate’
     may employ various heuristics and may recognize some special cases.

 -- Function: pwilt (<expr>, <s>, <t>)

     Computes the inverse Laplace transform of <expr> with respect to
     <s> and parameter <t>.  Unlike ‘ilt’, ‘pwilt’ is able to return
     piece-wise and periodic functions and can also handle some cases
     with polynomials of degree greater than 3 in the denominator.

     Two examples where ‘ilt’ fails:
          (%i1) pwilt (exp(-s)*s/(s^3-2*s-s+2), s, t);
                                  t - 1               - 2 (t - 1)
                                %e      (t - 1)   2 %e
          (%o1)   hstep(t - 1) (--------------- - ---------------)
                                       3                 9
          (%i2) pwilt ((s^2+2)/(s^2-1), s, t);
                                            t       - t
                                        3 %e    3 %e
          (%o2)              delta(t) + ----- - -------
                                          2        2

 -- Function: potential (<givengradient>)

     The calculation makes use of the global variable
     ‘potentialzeroloc[0]’ which must be ‘nonlist’ or of the form

          [indeterminatej=expressionj, indeterminatek=expressionk, ...]

     the former being equivalent to the nonlist expression for all
     right-hand sides in the latter.  The indicated right-hand sides are
     used as the lower limit of integration.  The success of the
     integrations may depend upon their values and order.
     ‘potentialzeroloc’ is initially set to 0.

 -- Option variable: prefer_d
     Default value: ‘false’

     When ‘prefer_d’ is ‘true’, ‘specint’ will prefer to express
     solutions using ‘parabolic_cylinder_d’ rather than hypergeometric
     functions.

     In the example below, the solution contains ‘parabolic_cylinder_d’
     when ‘prefer_d’ is ‘true’.

          (%i1) assume(s>0);
          (%o1)                        [s > 0]
          (%i2) factor(ex:specint(%e^-(t^2/8)*exp(-s*t),t));
                                  2
                               2 s
          (%o2)    - sqrt(2) %e     sqrt(%pi) (erf(sqrt(2) s) - 1)
          (%i3) specint(ex,t),prefer_d=true;
                                       2
                                    2 s
          (%o3) specint(- sqrt(2) %e     sqrt(%pi) erf(sqrt(2) s), t)
                                                            2
                                                         2 s
                                     + specint(sqrt(2) %e     sqrt(%pi), t)

 -- Function: residue (<expr>, <z>, <z_0>)

     Computes the residue in the complex plane of the expression <expr>
     when the variable <z> assumes the value <z_0>.  The residue is the
     coefficient of ‘(<z> - <z_0>)^(-1)’ in the Laurent series for
     <expr>.

          (%i1) residue (s/(s**2+a**2), s, a*%i);
                                          1
          (%o1)                           -
                                          2
          (%i2) residue (sin(a*x)/x**4, x, 0);
                                           3
                                          a
          (%o2)                         - --
                                          6

 -- Function: risch (<expr>, <x>)

     Integrates <expr> with respect to <x> using the transcendental case
     of the Risch algorithm.  (The algebraic case of the Risch algorithm
     has not been implemented.)  This currently handles the cases of
     nested exponentials and logarithms which the main part of
     ‘integrate’ can’t do.  ‘integrate’ will automatically apply ‘risch’
     if given these cases.

     ‘erfflag’, if ‘false’, prevents ‘risch’ from introducing the ‘erf’
     function in the answer if there were none in the integrand to begin
     with.

          (%i1) risch (x^2*erf(x), x);
                                       2
                       3            - x              2
                  %pi x  erf(x) + %e     (sqrt(%pi) x  + sqrt(%pi))
          (%o1)   -------------------------------------------------
                                        3 %pi
          (%i2) diff(%, x), ratsimp;
                                       2
          (%o2)                       x  erf(x)

 -- Function: specint (exp(- s*<t>) * <expr>, <t>)

     Compute the Laplace transform of <expr> with respect to the
     variable <t>.  The integrand <expr> may contain special functions.
     The parameter <s> maybe be named something else; it is determined
     automatically, as the examples below show where <p> is used in some
     places.

     The following special functions are handled by ‘specint’:
     incomplete gamma function, error functions (but not the error
     function ‘erfi’, it is easy to transform ‘erfi’ e.g.  to the error
     function ‘erf’), exponential integrals, bessel functions (including
     products of bessel functions), hankel functions, hermite and the
     laguerre polynomials.

     Furthermore, ‘specint’ can handle the hypergeometric function
     ‘%f[p,q]([],[],z)’, the Whittaker function of the first kind
     ‘%m[u,k](z)’ and of the second kind ‘%w[u,k](z)’.

     The result may be in terms of special functions and can include
     unsimplified hypergeometric functions.  If variable ‘prefer_d’ is
     ‘true’ then the ‘parabolic_cylinder_d’ function may be used in the
     result in preference to hypergeometric functions.

     When ‘laplace’ fails to find a Laplace transform, ‘specint’ is
     called.  Because ‘laplace’ knows more general rules for Laplace
     transforms, it is preferable to use ‘laplace’ and not ‘specint’.

     ‘demo("hypgeo")’ displays several examples of Laplace transforms
     computed by ‘specint’.

     Examples:
          (%i1) assume (p > 0, a > 0)$
          (%i2) specint (t^(1/2) * exp(-a*t/4) * exp(-p*t), t);
                                     sqrt(%pi)
          (%o2)                     ------------
                                           a 3/2
                                    2 (p + -)
                                           4
          (%i3) specint (t^(1/2) * bessel_j(1, 2 * a^(1/2) * t^(1/2))
                        * exp(-p*t), t);
                                     - a/p
                                   %e      sqrt(a)
          (%o3)                    ---------------
                                          2
                                         p

     Examples for exponential integrals:

          (%i1) assume(s>0,a>0,s-a>0)$
          (%i2) ratsimp(specint(%e^(a*t)*(log(a)+expintegral_e1(a*t))*%e^(-s*t),t));
                                       log(s)
          (%o2)                        ------
                                       s - a
          (%i3) logarc:true$
          (%i4) gamma_expand:true$
          (%i5) radcan(specint((cos(t)*expintegral_si(t) -sin(t)*expintegral_ci(t))*%e^(-s*t),t));
                                       log(s)
          (%o5)                        ------
                                        2
                                       s  + 1
          (%i6) ratsimp(specint((2*t*log(a)+2/a*sin(a*t) -2*t*expintegral_ci(a*t))*%e^(-s*t),t));
                                         2    2
                                    log(s  + a )
          (%o6)                     ------------
                                          2
                                         s

     Results when using the expansion of ‘gamma_incomplete’ and when
     changing the representation to ‘expintegral_e1’:

          (%i1) assume(s>0)$
          (%i2) specint(1/sqrt(%pi*t)*unit_step(t-k)*%e^(-s*t),t);
                                               1
                              gamma_incomplete(-, k s)
                                               2
          (%o2)               ------------------------
                                 sqrt(%pi) sqrt(s)
          (%i3) gamma_expand:true$
          (%i4) specint(1/sqrt(%pi*t)*unit_step(t-k)*%e^(-s*t),t);
                                erfc(sqrt(k) sqrt(s))
          (%o4)                 ---------------------
                                       sqrt(s)
          (%i5) expintrep:expintegral_e1$
          (%i6) ratsimp(specint(1/(t+a)^2*%e^(-s*t),t));
                                 a s
                           a s %e    expintegral_e1(a s) - 1
          (%o6)          - ---------------------------------
                                           a

 -- Function: tldefint (<expr>, <x>, <a>, <b>)

     Equivalent to ‘ldefint’ with ‘tlimswitch’ set to ‘true’.


File: maxima.info,  Node: Introduction to QUADPACK,  Next: Functions and Variables for QUADPACK,  Prev: Functions and Variables for Integration,  Up: Integration

18.3 Introduction to QUADPACK
=============================

QUADPACK is a collection of functions for the numerical computation of
one-dimensional definite integrals.  It originated from a joint project
of R. Piessens (1), E. de Doncker (2), C. Ueberhuber (3), and D. Kahaner
(4).

   The QUADPACK library included in Maxima is an automatic translation
(via the program ‘f2cl’) of the Fortran source code of QUADPACK as it
appears in the SLATEC Common Mathematical Library, Version 4.1 (5).  The
SLATEC library is dated July 1993, but the QUADPACK functions were
written some years before.  There is another version of QUADPACK at
Netlib (6); it is not clear how that version differs from the SLATEC
version.

   The QUADPACK functions included in Maxima are all automatic, in the
sense that these functions attempt to compute a result to a specified
accuracy, requiring an unspecified number of function evaluations.
Maxima’s Lisp translation of QUADPACK also includes some non-automatic
functions, but they are not exposed at the Maxima level.

   Further information about QUADPACK can be found in the QUADPACK book
(7).

18.3.1 Overview
---------------

‘quad_qag’
     Integration of a general function over a finite interval.
     ‘quad_qag’ implements a simple globally adaptive integrator using
     the strategy of Aind (Piessens, 1973).  The caller may choose among
     6 pairs of Gauss-Kronrod quadrature formulae for the rule
     evaluation component.  The high-degree rules are suitable for
     strongly oscillating integrands.

‘quad_qags’
     Integration of a general function over a finite interval.
     ‘quad_qags’ implements globally adaptive interval subdivision with
     extrapolation (de Doncker, 1978) by the Epsilon algorithm (Wynn,
     1956).

‘quad_qagi’
     Integration of a general function over an infinite or semi-infinite
     interval.  The interval is mapped onto a finite interval and then
     the same strategy as in ‘quad_qags’ is applied.

‘quad_qawo’

     Integration of cos(omega x) f(x) or sin(omega x) f(x) over a finite
     interval, where omega is a constant.  The rule evaluation component
     is based on the modified Clenshaw-Curtis technique.  ‘quad_qawo’
     applies adaptive subdivision with extrapolation, similar to
     ‘quad_qags’.

‘quad_qawf’
     Calculates a Fourier cosine or Fourier sine transform on a
     semi-infinite interval.  The same approach as in ‘quad_qawo’ is
     applied on successive finite intervals, and convergence
     acceleration by means of the Epsilon algorithm (Wynn, 1956) is
     applied to the series of the integral contributions.

‘quad_qaws’
     Integration of w(x) f(x) over a finite interval [a, b], where w is
     a function of the form (x - a)^alpha (b - x)^beta v(x) and v(x) is
     1 or log(x - a) or log(b - x) or log(x - a) log(b - x), and alpha >
     -1 and beta > -1.

     A globally adaptive subdivision strategy is applied, with modified
     Clenshaw-Curtis integration on the subintervals which contain a or
     b.

‘quad_qawc’
     Computes the Cauchy principal value of f(x)/(x - c) over a finite
     interval (a, b) and specified c.  The strategy is globally
     adaptive, and modified Clenshaw-Curtis integration is used on the
     subranges which contain the point x = c.

‘quad_qagp’
     Basically the same as ‘quad_qags’ but points of singularity or
     discontinuity of the integrand must be supplied.  This makes it
     easier for the integrator to produce a good solution.

   ---------- Footnotes ----------

   (1) Applied Mathematics and Programming Division, K.U. Leuven

   (2) Applied Mathematics and Programming Division, K.U. Leuven

   (3) Institut für Mathematik, T.U. Wien

   (4) National Bureau of Standards, Washington, D.C., U.S.A

   (5) <https://www.netlib.org/slatec>

   (6) <https://www.netlib.org/quadpack>

   (7) R. Piessens, E. de Doncker-Kapenga, C.W. Uberhuber, and D.K.
Kahaner.  QUADPACK: A Subroutine Package for Automatic Integration.
Berlin: Springer-Verlag, 1983, ISBN 0387125531.


File: maxima.info,  Node: Functions and Variables for QUADPACK,  Prev: Introduction to QUADPACK,  Up: Integration

18.4 Functions and Variables for QUADPACK
=========================================

 -- Function: quad_qag
          quad_qag (<f(x)>, <x>, <a>, <b>, <key>, [<epsrel>, <epsabs>,
          <limit>])
          quad_qag (<f>, <x>, <a>, <b>, <key>, [<epsrel>, <epsabs>,
          <limit>])

     Integration of a general function over a finite interval.
     ‘quad_qag’ implements a simple globally adaptive integrator using
     the strategy of Aind (Piessens, 1973).  The caller may choose among
     6 pairs of Gauss-Kronrod quadrature formulae for the rule
     evaluation component.  The high-degree rules are suitable for
     strongly oscillating integrands.

     ‘quad_qag’ computes the integral

     integrate (f(x), x, a, b)>>>

     The function to be integrated is f(x), with dependent variable x,
     and the function is to be integrated between the limits a and b.
     <key> is the integrator to be used and should be an integer between
     1 and 6, inclusive.  The value of <key> selects the order of the
     Gauss-Kronrod integration rule.  High-order rules are suitable for
     strongly oscillating integrands.

     The integrand may be specified as the name of a Maxima or Lisp
     function or operator, a Maxima lambda expression, or a general
     Maxima expression.

     The numerical integration is done adaptively by subdividing the
     integration region into sub-intervals until the desired accuracy is
     achieved.

     The keyword arguments are optional and may be specified in any
     order.  They all take the form ‘key=val’.  The keyword arguments
     are:

     ‘epsrel’
          Desired relative error of approximation.  Default is 1d-8.
     ‘epsabs’
          Desired absolute error of approximation.  Default is 0.
     ‘limit’
          Size of internal work array.  <limit> is the maximum number of
          subintervals to use.  Default is 200.

     ‘quad_qag’ returns a list of four elements:

        • an approximation to the integral,
        • the estimated absolute error of the approximation,
        • the number integrand evaluations,
        • an error code.

     The error code (fourth element of the return value) can have the
     values:

     ‘0’
          if no problems were encountered;
     ‘1’
          if too many sub-intervals were done;
     ‘2’
          if excessive roundoff error is detected;
     ‘3’
          if extremely bad integrand behavior occurs;
     ‘6’
          if the input is invalid.

     Examples:

          (%i1) quad_qag (x^(1/2)*log(1/x), x, 0, 1, 3, 'epsrel=5d-8);
          (%o1)  [0.44444444445742953, 8.737223570614865e-9, 899, 0]
          (%i2) integrate (x^(1/2)*log(1/x), x, 0, 1);
                                          4
          (%o2)                           -
                                          9

 -- Function: quad_qags
          quad_qags (<f(x)>, <x>, <a>, <b>, [<epsrel>, <epsabs>,
          <limit>])
          quad_qags (<f>, <x>, <a>, <b>, [<epsrel>, <epsabs>, <limit>])

     Integration of a general function over a finite interval.
     ‘quad_qags’ implements globally adaptive interval subdivision with
     extrapolation (de Doncker, 1978) by the Epsilon algorithm (Wynn,
     1956).

     ‘quad_qags’ computes the integral

     integrate (f(x), x, a, b)>>>

     The function to be integrated is f(x), with dependent variable x,
     and the function is to be integrated between the limits a and b.

     The integrand may be specified as the name of a Maxima or Lisp
     function or operator, a Maxima lambda expression, or a general
     Maxima expression.

     The keyword arguments are optional and may be specified in any
     order.  They all take the form ‘key=val’.  The keyword arguments
     are:

     ‘epsrel’
          Desired relative error of approximation.  Default is 1d-8.
     ‘epsabs’
          Desired absolute error of approximation.  Default is 0.
     ‘limit’
          Size of internal work array.  <limit> is the maximum number of
          subintervals to use.  Default is 200.

     ‘quad_qags’ returns a list of four elements:

        • an approximation to the integral,
        • the estimated absolute error of the approximation,
        • the number integrand evaluations,
        • an error code.

     The error code (fourth element of the return value) can have the
     values:

     ‘0’
          no problems were encountered;
     ‘1’
          too many sub-intervals were done;
     ‘2’
          excessive roundoff error is detected;
     ‘3’
          extremely bad integrand behavior occurs;
     ‘4’
          failed to converge
     ‘5’
          integral is probably divergent or slowly convergent
     ‘6’
          if the input is invalid.

     Examples:

          (%i1) quad_qags (x^(1/2)*log(1/x), x, 0, 1, 'epsrel=1d-10);
          (%o1) [0.44444444444444475, 1.1102230246251565e-15, 315, 0]

     Note that ‘quad_qags’ is more accurate and efficient than
     ‘quad_qag’ for this integrand.

 -- Function: quad_qagi
          quad_qagi (<f(x)>, <x>, <a>, <b>, [<epsrel>, <epsabs>,
          <limit>])
          quad_qagi (<f>, <x>, <a>, <b>, [<epsrel>, <epsabs>, <limit>])

     Integration of a general function over an infinite or semi-infinite
     interval.  The interval is mapped onto a finite interval and then
     the same strategy as in ‘quad_qags’ is applied.

     ‘quad_qagi’ evaluates one of the following integrals

     integrate (f(x), x, a, inf)

     integrate (f(x), x, minf, a)

     integrate (f(x), x, minf, inf)

     using the Quadpack QAGI routine.  The function to be integrated is
     f(x), with dependent variable x, and the function is to be
     integrated over an infinite range.

     The integrand may be specified as the name of a Maxima or Lisp
     function or operator, a Maxima lambda expression, or a general
     Maxima expression.

     One of the limits of integration must be infinity.  If not, then
     ‘quad_qagi’ will just return the noun form.

     The keyword arguments are optional and may be specified in any
     order.  They all take the form ‘key=val’.  The keyword arguments
     are:

     ‘epsrel’
          Desired relative error of approximation.  Default is 1d-8.
     ‘epsabs’
          Desired absolute error of approximation.  Default is 0.
     ‘limit’
          Size of internal work array.  <limit> is the maximum number of
          subintervals to use.  Default is 200.

     ‘quad_qagi’ returns a list of four elements:

        • an approximation to the integral,
        • the estimated absolute error of the approximation,
        • the number integrand evaluations,
        • an error code.

     The error code (fourth element of the return value) can have the
     values:

     ‘0’
          no problems were encountered;
     ‘1’
          too many sub-intervals were done;
     ‘2’
          excessive roundoff error is detected;
     ‘3’
          extremely bad integrand behavior occurs;
     ‘4’
          failed to converge
     ‘5’
          integral is probably divergent or slowly convergent
     ‘6’
          if the input is invalid.

     Examples:

          (%i1) quad_qagi (x^2*exp(-4*x), x, 0, inf, 'epsrel=1d-8);
          (%o1)       [0.03125, 2.9591610299500215e-11, 105, 0]
          (%i2) integrate (x^2*exp(-4*x), x, 0, inf);
                                         1
          (%o2)                          --
                                         32

 -- Function: quad_qawc
          quad_qawc (<f(x)>, <x>, <c>, <a>, <b>, [<epsrel>, <epsabs>,
          <limit>])
          quad_qawc (<f>, <x>, <c>, <a>, <b>, [<epsrel>, <epsabs>,
          <limit>])

     Computes the Cauchy principal value of f(x)/(x - c) over a finite
     interval.  The strategy is globally adaptive, and modified
     Clenshaw-Curtis integration is used on the subranges which contain
     the point x = c.

     ‘quad_qawc’ computes the Cauchy principal value of

     integrate (f(x)/(x - c), x, a, b)

     using the Quadpack QAWC routine.  The function to be integrated is
     f(x)/(x-c), with dependent variable x, and the function is to be
     integrated over the interval a to b.

     The integrand may be specified as the name of a Maxima or Lisp
     function or operator, a Maxima lambda expression, or a general
     Maxima expression.

     The keyword arguments are optional and may be specified in any
     order.  They all take the form ‘key=val’.  The keyword arguments
     are:

     ‘epsrel’
          Desired relative error of approximation.  Default is 1d-8.
     ‘epsabs’
          Desired absolute error of approximation.  Default is 0.
     ‘limit’
          Size of internal work array.  <limit> is the maximum number of
          subintervals to use.  Default is 200.

     ‘quad_qawc’ returns a list of four elements:

        • an approximation to the integral,
        • the estimated absolute error of the approximation,
        • the number integrand evaluations,
        • an error code.

     The error code (fourth element of the return value) can have the
     values:

     ‘0’
          no problems were encountered;
     ‘1’
          too many sub-intervals were done;
     ‘2’
          excessive roundoff error is detected;
     ‘3’
          extremely bad integrand behavior occurs;
     ‘6’
          if the input is invalid.

     Examples:

          (%i1) quad_qawc (2^(-5)*((x-1)^2+4^(-5))^(-1), x, 2, 0, 5, 'epsrel=1d-7);
          (%o1) [- 3.130120337415925, 1.3068301402495579e-8, 495, 0]
          (%i2) integrate (2^(-alpha)*(((x-1)^2 + 4^(-alpha))*(x-2))^(-1), x, 0, 5);
          Principal Value
                    2 alpha - 1      2 alpha + 4
                   2            log(2            + 1)
          (%o2) (- ----------------------------------
                               2 alpha
                              2        + 1
              3 alpha       alpha + 2     2 alpha - 1      2 alpha
             2        atan(2         )   2            log(2        + 1)
           - ------------------------- + ------------------------------
                    2 alpha                        2 alpha
                   2        + 1                   2        + 1
              3 alpha + 1       alpha     3 alpha       alpha
             2            atan(2     )   2        atan(2     )
           - ------------------------- + ---------------------
                    2 alpha                   2 alpha
                   2        + 1              2        + 1
              2 alpha           2 alpha
             2        log(3)   2        log(2)   alpha
           + --------------- - ---------------)/2
               2 alpha           2 alpha
              2        + 1      2        + 1
          (%i3) ev (%, alpha=5, numer);
          (%o3)                 - 3.1301203374159177

 -- Function: quad_qawf
          quad_qawf (<f(x)>, <x>, <a>, <omega>, <trig>, [<epsabs>,
          <limit>, <maxp1>, <limlst>])
          quad_qawf (<f>, <x>, <a>, <omega>, <trig>, [<epsabs>, <limit>,
          <maxp1>, <limlst>])

     Calculates a Fourier cosine or Fourier sine transform on a
     semi-infinite interval using the Quadpack QAWF function.  The same
     approach as in ‘quad_qawo’ is applied on successive finite
     intervals, and convergence acceleration by means of the Epsilon
     algorithm (Wynn, 1956) is applied to the series of the integral
     contributions.

     ‘quad_qawf’ computes the integral

     integrate (f(x)*w(x), x, a, inf)

     The weight function w is selected by <trig>:

     ‘cos’
          w(x) = cos (omega x)
     ‘sin’
          w(x) = sin (omega x)

     The integrand may be specified as the name of a Maxima or Lisp
     function or operator, a Maxima lambda expression, or a general
     Maxima expression.

     The keyword arguments are optional and may be specified in any
     order.  They all take the form ‘key=val’.  The keyword arguments
     are:

     ‘epsabs’
          Desired absolute error of approximation.  Default is 1d-10.
     ‘limit’
          Size of internal work array.  (<limit> - <limlst>)/2 is the
          maximum number of subintervals to use.  Default is 200.
     ‘maxp1’
          Maximum number of Chebyshev moments.  Must be greater than 0.
          Default is 100.
     ‘limlst’
          Upper bound on the number of cycles.  Must be greater than or
          equal to 3.  Default is 10.

     ‘quad_qawf’ returns a list of four elements:

        • an approximation to the integral,
        • the estimated absolute error of the approximation,
        • the number integrand evaluations,
        • an error code.

     The error code (fourth element of the return value) can have the
     values:

     ‘0’
          no problems were encountered;
     ‘1’
          too many sub-intervals were done;
     ‘2’
          excessive roundoff error is detected;
     ‘3’
          extremely bad integrand behavior occurs;
     ‘6’
          if the input is invalid.

     Examples:

          (%i1) quad_qawf (exp(-x^2), x, 0, 1, 'cos, 'epsabs=1d-9);
          (%o1)  [0.6901942235215714, 2.848463002545743e-11, 215, 0]
          (%i2) integrate (exp(-x^2)*cos(x), x, 0, inf);
                                    - 1/4
                                  %e      sqrt(%pi)
          (%o2)                   -----------------
                                          2
          (%i3) ev (%, numer);
          (%o3)                  0.6901942235215714

 -- Function: quad_qawo
          quad_qawo (<f(x)>, <x>, <a>, <b>, <omega>, <trig>, [<epsrel>,
          <epsabs>, <limit>, <maxp1>, <limlst>])
          quad_qawo (<f>, <x>, <a>, <b>, <omega>, <trig>, [<epsrel>,
          <epsabs>, <limit>, <maxp1>, <limlst>])

     Integration of cos (omega x) f(x) or sin (omega x) f(x) over a
     finite interval, where omega is a constant.  The rule evaluation
     component is based on the modified Clenshaw-Curtis technique.
     ‘quad_qawo’ applies adaptive subdivision with extrapolation,
     similar to ‘quad_qags’.

     ‘quad_qawo’ computes the integral using the Quadpack QAWO routine:

     integrate (f(x)*w(x), x, a, b)

     The weight function w is selected by <trig>:

     ‘cos’
          w(x) = cos (omega x)
     ‘sin’
          w(x) = sin (omega x)

     The integrand may be specified as the name of a Maxima or Lisp
     function or operator, a Maxima lambda expression, or a general
     Maxima expression.

     The keyword arguments are optional and may be specified in any
     order.  They all take the form ‘key=val’.  The keyword arguments
     are:

     ‘epsrel’
          Desired relative error of approximation.  Default is 1d-8.
     ‘epsabs’
          Desired absolute error of approximation.  Default is 0.
     ‘limit’
          Size of internal work array.  <limit>/2 is the maximum number
          of subintervals to use.  Default is 200.
     ‘maxp1’
          Maximum number of Chebyshev moments.  Must be greater than 0.
          Default is 100.
     ‘limlst’
          Upper bound on the number of cycles.  Must be greater than or
          equal to 3.  Default is 10.

     ‘quad_qawo’ returns a list of four elements:

        • an approximation to the integral,
        • the estimated absolute error of the approximation,
        • the number integrand evaluations,
        • an error code.

     The error code (fourth element of the return value) can have the
     values:

     ‘0’
          no problems were encountered;
     ‘1’
          too many sub-intervals were done;
     ‘2’
          excessive roundoff error is detected;
     ‘3’
          extremely bad integrand behavior occurs;
     ‘6’
          if the input is invalid.

     Examples:

          (%i1) quad_qawo (x^(-1/2)*exp(-2^(-2)*x), x, 1d-8, 20*2^2, 1, cos);
          (%o1) [1.3760433898776214, 4.7271075942489915e-11, 765, 0]
          (%i2) rectform (integrate (x^(-1/2)*exp(-2^(-alpha)*x) * cos(x), x, 0, inf));
                   alpha + 1
                   --------- - 1
                       2                    2 alpha
                  2              sqrt(sqrt(2        + 1) %pi + %pi)
          (%o2)   -------------------------------------------------
                                       2 alpha
                                 sqrt(2        + 1)
          (%i3) ev (%, alpha=2, numer);
          (%o3)                   1.376043390090716
          (%i4) ev (%, alpha=2, numer);

 -- Function: quad_qaws
          quad_qaws (<f(x)>, <x>, <a>, <b>, <alpha>, <beta>, <wfun>,
          [<epsrel>, <epsabs>, <limit>])
          quad_qaws (<f>, <x>, <a>, <b>, <alpha>, <beta>, <wfun>,
          [<epsrel>, <epsabs>, <limit>])

     Integration of w(x) f(x) over a finite interval, where w(x) is a
     certain algebraic or logarithmic function.  A globally adaptive
     subdivision strategy is applied, with modified Clenshaw-Curtis
     integration on the subintervals which contain the endpoints of the
     interval of integration.

     ‘quad_qaws’ computes the integral using the Quadpack QAWS routine:

     integrate (f(x)*w(x), x, a, b)

     The weight function w is selected by <wfun>:

     ‘1’
          w(x) = (x - a)^alpha (b - x)^beta
     ‘2’
          w(x) = (x - a)^alpha (b - x)^beta log(x - a)
     ‘3’
          w(x) = (x - a)^alpha (b - x)^beta log(b - x)
     ‘4’
          w(x) = (x - a)^alpha (b - x)^beta log(x - a) log(b - x)

     The integrand may be specified as the name of a Maxima or Lisp
     function or operator, a Maxima lambda expression, or a general
     Maxima expression.

     The keyword arguments are optional and may be specified in any
     order.  They all take the form ‘key=val’.  The keyword arguments
     are:

     ‘epsrel’
          Desired relative error of approximation.  Default is 1d-8.
     ‘epsabs’
          Desired absolute error of approximation.  Default is 0.
     ‘limit’
          Size of internal work array.  <limit>is the maximum number of
          subintervals to use.  Default is 200.

     ‘quad_qaws’ returns a list of four elements:

        • an approximation to the integral,
        • the estimated absolute error of the approximation,
        • the number integrand evaluations,
        • an error code.

     The error code (fourth element of the return value) can have the
     values:

     ‘0’
          no problems were encountered;
     ‘1’
          too many sub-intervals were done;
     ‘2’
          excessive roundoff error is detected;
     ‘3’
          extremely bad integrand behavior occurs;
     ‘6’
          if the input is invalid.

     Examples:

          (%i1) quad_qaws (1/(x+1+2^(-4)), x, -1, 1, -0.5, -0.5, 1, 'epsabs=1d-9);
          (%o1)  [8.750097361672843, 1.2761903591126173e-8, 130, 0]
          (%i2) integrate ((1-x*x)^(-1/2)/(x+1+2^(-alpha)), x, -1, 1);
                                      alpha
                                     2      %pi
          (%o2)                 --------------------
                                      alpha + 1
                                sqrt(2          + 1)
          (%i3) ev (%, alpha=4, numer);
          (%o3)                   8.75009736167283

 -- Function: quad_qagp
          quad_qagp (<f(x)>, <x>, <a>, <b>, <points>, [<epsrel>,
          <epsabs>, <limit>])
          quad_qagp (<f>, <x>, <a>, <b>, <points>, [<epsrel>, <epsabs>,
          <limit>])

     Integration of a general function over a finite interval.
     ‘quad_qagp’ implements globally adaptive interval subdivision with
     extrapolation (de Doncker, 1978) by the Epsilon algorithm (Wynn,
     1956).

     ‘quad_qagp’ computes the integral

     integrate (f(x), x, a, b)

     The function to be integrated is f(x), with dependent variable x,
     and the function is to be integrated between the limits a and b.

     The integrand may be specified as the name of a Maxima or Lisp
     function or operator, a Maxima lambda expression, or a general
     Maxima expression.

     To help the integrator, the user must supply a list of points where
     the integrand is singular or discontinuous.  The list is provided
     by <points>.  It may be an empty list.  The elements of the list
     must be between <a> and <b>, exclusive.  An error is thrown if
     there are elements out of range.  The list points may be in any
     order.

     The keyword arguments are optional and may be specified in any
     order.  They all take the form ‘key=val’.  The keyword arguments
     are:

     ‘epsrel’
          Desired relative error of approximation.  Default is 1d-8.
     ‘epsabs’
          Desired absolute error of approximation.  Default is 0.
     ‘limit’
          Size of internal work array.  <limit> is the maximum number of
          subintervals to use.  Default is 200.

     ‘quad_qagp’ returns a list of four elements:

        • an approximation to the integral,
        • the estimated absolute error of the approximation,
        • the number integrand evaluations,
        • an error code.

     The error code (fourth element of the return value) can have the
     values:

     ‘0’
          no problems were encountered;
     ‘1’
          too many sub-intervals were done;
     ‘2’
          excessive roundoff error is detected;
     ‘3’
          extremely bad integrand behavior occurs;
     ‘4’
          failed to converge
     ‘5’
          integral is probably divergent or slowly convergent
     ‘6’
          if the input is invalid.

     Examples:

          (%i1) quad_qagp(x^3*log(abs((x^2-1)*(x^2-2))),x,0,3,[1,sqrt(2)]);
          (%o1) [52.740748383471434, 2.6247632689546663e-7, 1029, 0]
          (%i2) quad_qags(x^3*log(abs((x^2-1)*(x^2-2))), x, 0, 3);
          (%o2)  [52.74074847951494, 4.088443219529836e-7, 1869, 0]

     The integrand has singularities at ‘1’ and ‘sqrt(2)’ so we supply
     these points to ‘quad_qagp’.  We also note that ‘quad_qagp’ is more
     accurate and more efficient that ‘quad_qags’.

 -- Function: quad_control (<parameter>, [<value>])

     Control error handling for quadpack.  The parameter should be one
     of the following symbols:

     ‘current_error’
          The current error number
     ‘control’
          Controls if messages are printed or not.  If it is set to zero
          or less, messages are suppressed.
     ‘max_message’
          The maximum number of times any message is to be printed.

     If <value> is not given, then the current value of the <parameter>
     is returned.  If <value> is given, the value of <parameter> is set
     to the given value.


File: maxima.info,  Node: Equations,  Next: Дифференциальные уравнения,  Prev: Integration,  Up: Top

19 Equations
************

* Menu:

* Functions and Variables for Equations::
* Examples for algsys::
* References for equations::


File: maxima.info,  Node: Functions and Variables for Equations,  Prev: Equations,  Up: Equations

19.1 Functions and Variables for Equations
==========================================

 -- System variable: %rnum
     Default value: ‘0’

     ‘%rnum’ is the counter for the ‘%r’ variables introduced in
     solutions by ‘solve’ and ‘algsys’..  The next ‘%r’ variable is
     numbered ‘%rnum+1’.

     See also ‘%rnum_list’.

 -- System variable: %rnum_list
     Default value: ‘[]’

     ‘%rnum_list’ is the list of variables introduced in solutions by
     ‘solve’ and ‘algsys’.  ‘%r’ variables are added to ‘%rnum_list’ in
     the order they are created.  This is convenient for doing
     substitutions into the solution later on.

     See also ‘%rnum’.

     It’s recommended to use this list rather than doing ‘concat ('%r,
     j)’.

          (%i1) solve ([x + y = 3], [x,y]);
          (%o1)               [[x = 3 - %r1, y = %r1]]
          (%i2) %rnum_list;
          (%o2)                         [%r1]
          (%i3) sol : solve ([x + 2*y + 3*z = 4], [x,y,z]);
          (%o3)     [[x = - 2 %r3 - 3 %r2 + 4, y = %r3, z = %r2]]
          (%i4) %rnum_list;
          (%o4)                      [%r2, %r3]
          (%i5) for i : 1 thru length (%rnum_list) do
            sol : subst (t[i], %rnum_list[i], sol)$
          (%i6) sol;
          (%o6)       [[x = - 2 t  - 3 t  + 4, y = t , z = t ]]
                                 2      1           2       1

 -- Option variable: algepsilon
     Default value: 10^8

     ‘algepsilon’ is used by ‘algsys’.

 -- Option variable: algexact
     Default value: ‘false’

     ‘algexact’ affects the behavior of ‘algsys’ as follows:

     If ‘algexact’ is ‘true’, ‘algsys’ always calls ‘solve’ and then
     uses ‘realroots’ on ‘solve’’s failures.

     If ‘algexact’ is ‘false’, ‘solve’ is called only if the eliminant
     was not univariate, or if it was a quadratic or biquadratic.

     Thus ‘algexact: true’ does not guarantee only exact solutions, just
     that ‘algsys’ will first try as hard as it can to give exact
     solutions, and only yield approximations when all else fails.

 -- Function: algsys
          algsys ([<expr_1>, ..., <expr_m>], [<x_1>, ..., <x_n>])
          algsys ([<eqn_1>, ..., <eqn_m>], [<x_1>, ..., <x_n>])

     Solves the simultaneous polynomials <expr_1>, ..., <expr_m> or
     polynomial equations <eqn_1>, ..., <eqn_m> for the variables <x_1>,
     ..., <x_n>.  An expression <expr> is equivalent to an equation
     ‘<expr> = 0’.  There may be more equations than variables or vice
     versa.

     ‘algsys’ returns a list of solutions, with each solution given as a
     list of equations stating values of the variables <x_1>, ..., <x_n>
     which satisfy the system of equations.  If ‘algsys’ cannot find a
     solution, an empty list ‘[]’ is returned.

     The symbols ‘%r1’, ‘%r2’, ..., are introduced as needed to
     represent arbitrary parameters in the solution; these variables are
     also appended to the list ‘%rnum_list’.

     The method is as follows:

       1. First the equations are factored and split into subsystems.

       2. For each subsystem <S_i>, an equation <E> and a variable <x>
          are selected.  The variable is chosen to have lowest nonzero
          degree.  Then the resultant of <E> and <E_j> with respect to
          <x> is computed for each of the remaining equations <E_j> in
          the subsystem <S_i>.  This yields a new subsystem <S_i’> in
          one fewer variables, as <x> has been eliminated.  The process
          now returns to (1).

       3. Eventually, a subsystem consisting of a single equation is
          obtained.  If the equation is multivariate and no
          approximations in the form of floating point numbers have been
          introduced, then ‘solve’ is called to find an exact solution.

          In some cases, ‘solve’ is not be able to find a solution, or
          if it does the solution may be a very large expression.

          If the equation is univariate and is either linear, quadratic,
          or biquadratic, then again ‘solve’ is called if no
          approximations have been introduced.  If approximations have
          been introduced or the equation is not univariate and neither
          linear, quadratic, or biquadratic, then if the switch
          ‘realonly’ is ‘true’, the function ‘realroots’ is called to
          find the real-valued solutions.  If ‘realonly’ is ‘false’,
          then ‘allroots’ is called which looks for real and
          complex-valued solutions.

          If ‘algsys’ produces a solution which has fewer significant
          digits than required, the user can change the value of
          ‘algepsilon’ to a higher value.

          If ‘algexact’ is set to ‘true’, ‘solve’ will always be called.

       4. Finally, the solutions obtained in step (3) are substituted
          into previous levels and the solution process returns to (1).

     When ‘algsys’ encounters a multivariate equation which contains
     floating point approximations (usually due to its failing to find
     exact solutions at an earlier stage), then it does not attempt to
     apply exact methods to such equations and instead prints the
     message: "‘algsys’ cannot solve - system too complicated."

     Interactions with ‘radcan’ can produce large or complicated
     expressions.  In that case, it may be possible to isolate parts of
     the result with ‘pickapart’ or ‘reveal’.

     Occasionally, ‘radcan’ may introduce an imaginary unit ‘%i’ into a
     solution which is actually real-valued.

     Examples:

          (%i1) e1: 2*x*(1 - a1) - 2*(x - 1)*a2;
          (%o1)              2 (1 - a1) x - 2 a2 (x - 1)
          (%i2) e2: a2 - a1;
          (%o2)                        a2 - a1
          (%i3) e3: a1*(-y - x^2 + 1);
                                             2
          (%o3)                   a1 (- y - x  + 1)
          (%i4) e4: a2*(y - (x - 1)^2);
                                                 2
          (%o4)                   a2 (y - (x - 1) )
          (%i5) algsys ([e1, e2, e3, e4], [x, y, a1, a2]);
          (%o5) [[x = 0, y = %r1, a1 = 0, a2 = 0],
                                            [x = 1, y = 0, a1 = 1, a2 = 1]]
          (%i6) e1: x^2 - y^2;
                                        2    2
          (%o6)                        x  - y
          (%i7) e2: -1 - y + 2*y^2 - x + x^2;
                                   2        2
          (%o7)                 2 y  - y + x  - x - 1
          (%i8) algsys ([e1, e2], [x, y]);
                           1            1
          (%o8) [[x = - -------, y = -------],
                        sqrt(3)      sqrt(3)
                  1              1             1        1
          [x = -------, y = - -------], [x = - -, y = - -], [x = 1, y = 1]]
               sqrt(3)        sqrt(3)          3        3

 -- Function: allroots
          allroots (<expr>)
          allroots (<eqn>)

     Computes numerical approximations of the real and complex roots of
     the polynomial <expr> or polynomial equation <eqn> of one variable.

     The flag ‘polyfactor’ when ‘true’ causes ‘allroots’ to factor the
     polynomial over the real numbers if the polynomial is real, or over
     the complex numbers, if the polynomial is complex.

     ‘allroots’ may give inaccurate results in case of multiple roots.
     If the polynomial is real, ‘allroots (%i*<p>)’ may yield more
     accurate approximations than ‘allroots (<p>)’, as ‘allroots’
     invokes a different algorithm in that case.

     ‘allroots’ rejects non-polynomials.  It requires that the numerator
     after ‘rat’’ing should be a polynomial, and it requires that the
     denominator be at most a complex number.  As a result of this
     ‘allroots’ will always return an equivalent (but factored)
     expression, if ‘polyfactor’ is ‘true’.

     For complex polynomials an algorithm by Jenkins and Traub is used
     (Algorithm 419, Comm.  ACM, vol.  15, (1972), p.  97).  For real
     polynomials the algorithm used is due to Jenkins (Algorithm 493,
     ACM TOMS, vol.  1, (1975), p.178).

     Examples:

          (%i1) eqn: (1 + 2*x)^3 = 13.5*(1 + x^5);
                                      3          5
          (%o1)              (2 x + 1)  = 13.5 (x  + 1)
          (%i2) soln: allroots (eqn);
          (%o2) [x = 0.8296749902129361, x = - 1.0157555438281212,
          x = 0.9659625152196369 %i - 0.4069597231924075,
          x = - 0.9659625152196369 %i - 0.4069597231924075, x = 1.0]
          (%i3) for e in soln
                  do (e2: subst (e, eqn), disp (expand (lhs(e2) - rhs(e2))));
                               - 3.552713678800501e-15

                               - 8.43769498715119e-15

                  2.6645352591003757e-15 %i - 6.217248937900877e-15

                 - 2.6645352591003757e-15 %i - 6.217248937900877e-15

                                         0.0

          (%o3)                         done
          (%i4) polyfactor: true$
          (%i5) allroots (eqn);
          (%o5) - 13.5 (x - 1.0) (x - 0.8296749902129361)
                                      2
           (x + 1.0157555438281212) (x  + 0.813919446384815 x
           + 1.0986997971102883)

 -- Function: bfallroots
          bfallroots (<expr>)
          bfallroots (<eqn>)

     Computes numerical approximations of the real and complex roots of
     the polynomial <expr> or polynomial equation <eqn> of one variable.

     In all respects, ‘bfallroots’ is identical to ‘allroots’ except
     that ‘bfallroots’ computes the roots using bigfloats.  See
     ‘allroots’ for more information.

 -- Option variable: backsubst
     Default value: ‘true’

     When ‘backsubst’ is ‘false’, prevents back substitution in
     ‘linsolve’ after the equations have been triangularized.  This may
     be helpful in very big problems where back substitution would cause
     the generation of extremely large expressions.

          (%i1) eq1 : x + y + z = 6$
          (%i2) eq2 : x - y + z = 2$
          (%i3) eq3 : x + y - z = 0$
          (%i4) backsubst : false$
          (%i5) linsolve ([eq1, eq2, eq3], [x,y,z]);
          (%o5)               [x = z - y, y = 2, z = 3]
          (%i6) backsubst : true$
          (%i7) linsolve ([eq1, eq2, eq3], [x,y,z]);
          (%o7)                 [x = 1, y = 2, z = 3]

 -- Option variable: breakup
     Default value: ‘true’

     When ‘breakup’ is ‘true’, ‘solve’ expresses solutions of cubic and
     quartic equations in terms of common subexpressions, which are
     assigned to intermediate expression labels (‘%t1’, ‘%t2’, etc.).
     Otherwise, common subexpressions are not identified.

     ‘breakup: true’ has an effect only when ‘programmode’ is ‘false’.

     Examples:

          (%i1) programmode: false$
          (%i2) breakup: true$
          (%i3) solve (x^3 + x^2 - 1);
                                  sqrt(23)   25 1/3
          (%t3)                  (-------- + --)
                                      3/2    54
                                   2 3
          solve: solution:

                                              sqrt(3) %i   - 1
                                              ---------- + ---
                      - 1   sqrt(3) %i            2         2    - 1
          (%t4)  x = (--- - ----------) %t3 + ---------------- + ---
                       2        2                  9 %t3          3

                                              - 1   sqrt(3) %i
                                              --- - ----------
                      sqrt(3) %i   - 1         2        2        - 1
          (%t5)  x = (---------- + ---) %t3 + ---------------- + ---
                          2         2              9 %t3          3

                                            1     - 1
          (%t6)                 x = %t3 + ----- + ---
                                          9 %t3    3
          (%o6)                    [%t4, %t5, %t6]
          (%i7) breakup: false$
          (%i8) solve (x^3 + x^2 - 1);
          solve: solution:

                      sqrt(3) %i   - 1
                      ---------- + ---
                          2         2       sqrt(23)   25 1/3
          (%t8) x = -------------------- + (-------- + --)
                       sqrt(23)   25 1/3        3/2    54
                    9 (-------- + --)        2 3
                           3/2    54
                        2 3
                                                    - 1   sqrt(3) %i    - 1
                                                   (--- - ----------) + ---
                                                     2        2          3

                     sqrt(23)   25 1/3  sqrt(3) %i   - 1
          (%t9) x = (-------- + --)    (---------- + ---)
                         3/2    54          2         2
                      2 3
                                                   - 1   sqrt(3) %i
                                                   --- - ----------
                                                    2        2          - 1
                                               + -------------------- + ---
                                                    sqrt(23)   25 1/3    3
                                                 9 (-------- + --)
                                                        3/2    54
                                                     2 3

                      sqrt(23)   25 1/3            1             - 1
          (%t10) x = (-------- + --)    + -------------------- + ---
                          3/2    54          sqrt(23)   25 1/3    3
                       2 3                9 (-------- + --)
                                                 3/2    54
                                              2 3
          (%o10)                  [%t8, %t9, %t10]

 -- Function: dimension
          dimension (<eqn>)
          dimension (<eqn_1>, ..., <eqn_n>)

     ‘dimen’ is a package for dimensional analysis.  ‘load ("dimen")’
     loads this package.  ‘demo ("dimen")’ displays a short
     demonstration.

 -- Option variable: dispflag
     Default value: ‘true’

     If set to ‘false’ within a ‘block’ will inhibit the display of
     output generated by the solve functions called from within the
     ‘block’.  Termination of the ‘block’ with a dollar sign, ‘$’, sets
     ‘dispflag’ to ‘false’.

 -- Function: funcsolve (<eqn>, <g>(<t>))

     Returns ‘[<g>(<t>) = ...]’ or ‘[]’, depending on whether or not
     there exists a rational function ‘<g>(<t>)’ satisfying <eqn>, which
     must be a first order, linear polynomial in (for this case)
     ‘<g>(<t>)’ and ‘<g>(<t>+1)’

          (%i1) eqn: (n + 1)*f(n) - (n + 3)*f(n + 1)/(n + 1) =
               (n - 1)/(n + 2);
                                      (n + 3) f(n + 1)   n - 1
          (%o1)        (n + 1) f(n) - ---------------- = -----
                                           n + 1         n + 2
          (%i2) funcsolve (eqn, f(n));
          solve: dependent equations eliminated: (4 3)
                                             n
          (%o2)                f(n) = ---------------
                                      (n + 1) (n + 2)

     Warning: this is a very rudimentary implementation – many safety
     checks and obvious generalizations are missing.

 -- Option variable: globalsolve
     Default value: ‘false’

     When ‘globalsolve’ is ‘true’, solved-for variables are assigned the
     solution values found by ‘linsolve’, and by ‘solve’ when solving
     two or more linear equations.

     When ‘globalsolve’ is ‘false’, solutions found by ‘linsolve’ and by
     ‘solve’ when solving two or more linear equations are expressed as
     equations, and the solved-for variables are not assigned.

     When solving anything other than two or more linear equations,
     ‘solve’ ignores ‘globalsolve’.  Other functions which solve
     equations (e.g., ‘algsys’) always ignore ‘globalsolve’.

     Examples:

          (%i1) globalsolve: true$
          (%i2) solve ([x + 3*y = 2, 2*x - y = 5], [x, y]);
                                       17        1
          (%o2)                  [[x : --, y : - -]]
                                       7         7
          (%i3) x;
                                         17
          (%o3)                          --
                                         7
          (%i4) y;
                                           1
          (%o4)                          - -
                                           7
          (%i5) globalsolve: false$
          (%i6) kill (x, y)$
          (%i7) solve ([x + 3*y = 2, 2*x - y = 5], [x, y]);
                                       17        1
          (%o7)                  [[x = --, y = - -]]
                                       7         7
          (%i8) x;
          (%o8)                           x
          (%i9) y;
          (%o9)                           y

 -- Function: ieqn (<ie>, <unk>, <tech>, <n>, <guess>)

     ‘inteqn’ is a package for solving integral equations.  ‘load
     ("inteqn")’ loads this package.

     <ie> is the integral equation; <unk> is the unknown function;
     <tech> is the technique to be tried from those given in the lists
     below; (<tech> = ‘first’ means: try the first technique which finds
     a solution; <tech> = ‘all’ means: try all applicable techniques);
     <n> is the maximum number of terms to take for ‘taylor’, ‘neumann’,
     ‘firstkindseries’, or ‘fredseries’ (it is also the maximum depth of
     recursion for the differentiation method); <guess> is the initial
     guess for ‘neumann’ or ‘firstkindseries’.

     Two types of equations are considered.  A second-kind equation of
     the following form,
                                     b(x)
                                    /
                                    [
                  p(x) = q(x, p(x), I     w(x, u, p(x), p(u)) du)
                                    ]
                                    /
                                     a(x)

     and a first-kind equation with the form
                                   b(x)
                                  /
                                  [
                           f(x) = I     w(x, u, p(u)) du
                                  ]
                                  /
                                   a(x)

     The different solution techniques used require particular forms of
     the expressions <q> and <w>.  The techniques available are the
     following:

     Second-kind equations
        • ‘flfrnk2nd’: For fixed-limit, finite-rank integrands.
        • ‘vlfrnk’: For variable-limit, finite-rank integrands.
        • ‘transform’: Laplace transform for convolution types.
        • ‘fredseries’: Fredholm-Carleman series for linear equations.
        • ‘tailor’: Taylor series for quasi-linear variable-limit
          equations.
        • ‘neumann’: Neumann series for quasi-second kind equations.
        • ‘collocate’: Collocation using a power series form for p(x)
          evaluated at equally spaced points.

     First-kind equations
        • ‘flfrnk1st’: For fixed-limit, finite-rank integrands.
        • ‘vlfrnk’: For variable-limit, finite-rank integrands.
        • ‘abel’: For singular integrands
        • ‘transform’: See above
        • ‘collocate’: See above
        • ‘firstkindseries’: Iteration technique similar to neumann
          series.

     The default values for the 2nd thru 5th parameters in the calling
     form are:

     <unk>: ‘<p>(<x>)’, where <p> is the first function encountered in
     an integrand which is unknown to Maxima and <x> is the variable
     which occurs as an argument to the first occurrence of <p> found
     outside of an integral in the case of ‘secondkind’ equations, or is
     the only other variable besides the variable of integration in
     ‘firstkind’ equations.  If the attempt to search for <x> fails, the
     user will be asked to supply the independent variable.  <tech>:
     ‘first’.  <n>: 1.  <guess>: ‘none’ which will cause ‘neumann’ and
     ‘firstkindseries’ to use ‘<f>(<x>)’ as an initial guess.

     Examples:
          (%i1) load("inteqn")$

          (%i2) e: p(x) - 1 -x + cos(x) + 'integrate(cos(x-u)*p(u),u,0,x)$

          (%i3) ieqn(e, p(x), 'transform);
          default 4th arg, number of iterations or coll. parms.:  1
          default 5th arg, initial guess:  none

          (%t3)                           [x, transform]
          (%o3)                               [%t3]
          (%i4) e: 2*'integrate(p(x*sin(u)), u, 0, %pi/2) - a*x - b$

          (%i5) ieqn(e, p(x), 'firstkindseries);
          default 4th arg, number of iterations or coll. parms.:  1
          default 5th arg, initial guess:  none

          (%t5)          [2 a x + %pi b, firstkindseries, 1, approximate]
          (%o5)                               [%t5]

 -- Option variable: ieqnprint
     Default value: ‘true’

     ‘ieqnprint’ governs the behavior of the result returned by the
     ‘ieqn’ command.  When ‘ieqnprint’ is ‘false’, the lists returned by
     the ‘ieqn’ function are of the form

     [<solution>, <technique used>, <nterms>, <flag>]

     where <flag> is absent if the solution is exact.

     Otherwise, it is the word ‘approximate’ or ‘incomplete’
     corresponding to an inexact or non-closed form solution,
     respectively.  If a series method was used, <nterms> gives the
     number of terms taken (which could be less than the n given to
     ‘ieqn’ if an error prevented generation of further terms).

 -- Function: lhs (<expr>)

     Returns the left-hand side (that is, the first argument) of the
     expression <expr>, when the operator of <expr> is one of the
     relational operators ‘< <= = # equal notequal >= >’, one of the
     assignment operators ‘:= ::= : ::’, or a user-defined binary infix
     operator, as declared by ‘infix’.

     When <expr> is an atom or its operator is something other than the
     ones listed above, ‘lhs’ returns <expr>.

     See also ‘rhs’.

     Examples:

          (%i1) e: aa + bb = cc;
          (%o1)                     bb + aa = cc
          (%i2) lhs (e);
          (%o2)                        bb + aa
          (%i3) rhs (e);
          (%o3)                          cc
          (%i4) [lhs (aa < bb), lhs (aa <= bb), lhs (aa >= bb),
                 lhs (aa > bb)];
          (%o4)                   [aa, aa, aa, aa]
          (%i5) [lhs (aa = bb), lhs (aa # bb), lhs (equal (aa, bb)),
                 lhs (notequal (aa, bb))];
          (%o5)                   [aa, aa, aa, aa]
          (%i6) e1: '(foo(x) := 2*x);
          (%o6)                     foo(x) := 2 x
          (%i7) e2: '(bar(y) ::= 3*y);
          (%o7)                    bar(y) ::= 3 y
          (%i8) e3: '(x : y);
          (%o8)                         x : y
          (%i9) e4: '(x :: y);
          (%o9)                        x :: y
          (%i10) [lhs (e1), lhs (e2), lhs (e3), lhs (e4)];
          (%o10)               [foo(x), bar(y), x, x]
          (%i11) infix ("][");
          (%o11)                         ][
          (%i12) lhs (aa ][ bb);
          (%o12)                         aa

 -- Function: linsolve ([<expr_1>, ..., <expr_m>], [<x_1>, ..., <x_n>])

     Solves the list of simultaneous linear equations for the list of
     variables.  The expressions must each be polynomials in the
     variables and may be equations.  If the length of the list of
     variables doesn’t match the number of linearly-independent
     equations to solve the result will be an empty list.

     When ‘globalsolve’ is ‘true’, each solved-for variable is bound to
     its value in the solution of the equations.

     When ‘backsubst’ is ‘false’, ‘linsolve’ does not carry out back
     substitution after the equations have been triangularized.  This
     may be necessary in very big problems where back substitution would
     cause the generation of extremely large expressions.

     When ‘linsolve_params’ is ‘true’, ‘linsolve’ also generates the
     ‘%r’ symbols used to represent arbitrary parameters described in
     the manual under ‘algsys’.  Otherwise, ‘linsolve’ solves an
     under-determined system of equations with some variables expressed
     in terms of others.

     When ‘programmode’ is ‘false’, ‘linsolve’ displays the solution
     with intermediate expression (‘%t’) labels, and returns the list of
     labels.

     See also ‘algsys’, ‘eliminate’.  and ‘solve’.

     Examples:
          (%i1) e1: x + z = y;
          (%o1)                       z + x = y
          (%i2) e2: 2*a*x - y = 2*a^2;
                                                 2
          (%o2)                   2 a x - y = 2 a
          (%i3) e3: y - 2*z = 2;
          (%o3)                      y - 2 z = 2
          (%i4) [globalsolve: false, programmode: true];
          (%o4)                     [false, true]
          (%i5) linsolve ([e1, e2, e3], [x, y, z]);
          (%o5)            [x = a + 1, y = 2 a, z = a - 1]
          (%i6) [globalsolve: false, programmode: false];
          (%o6)                    [false, false]
          (%i7) linsolve ([e1, e2, e3], [x, y, z]);
          Solution:

          (%t7)                       z = a - 1

          (%t8)                        y = 2 a

          (%t9)                       x = a + 1
          (%o9)                    [%t7, %t8, %t9]
          (%i10) ''%;
          (%o10)           [z = a - 1, y = 2 a, x = a + 1]
          (%i11) [globalsolve: true, programmode: false];
          (%o11)                    [true, false]
          (%i12) linsolve ([e1, e2, e3], [x, y, z]);
          Solution:

          (%t12)                      z : a - 1

          (%t13)                       y : 2 a

          (%t14)                      x : a + 1
          (%o14)                 [%t12, %t13, %t14]
          (%i15) ''%;
          (%o15)           [z : a - 1, y : 2 a, x : a + 1]
          (%i16) [x, y, z];
          (%o16)                 [a + 1, 2 a, a - 1]
          (%i17) [globalsolve: true, programmode: true];
          (%o17)                    [true, true]
          (%i18) linsolve ([e1, e2, e3], '[x, y, z]);
          (%o18)           [x : a + 1, y : 2 a, z : a - 1]
          (%i19) [x, y, z];
          (%o19)                 [a + 1, 2 a, a - 1]

 -- Option variable: linsolvewarn
     Default value: ‘true’

     When ‘linsolvewarn’ is ‘true’, ‘linsolve’ prints a message
     "Dependent equations eliminated".

 -- Option variable: linsolve_params
     Default value: ‘true’

     When ‘linsolve_params’ is ‘true’, ‘linsolve’ also generates the
     ‘%r’ symbols used to represent arbitrary parameters described in
     the manual under ‘algsys’.  Otherwise, ‘linsolve’ solves an
     under-determined system of equations with some variables expressed
     in terms of others.

 -- System variable: multiplicities
     Default value: ‘not_set_yet’

     ‘multiplicities’ is set to a list of the multiplicities of the
     individual solutions returned by ‘solve’ or ‘realroots’.

 -- Function: nroots (<p>, <low>, <high>)

     Returns the number of real roots of the real univariate polynomial
     <p> in the half-open interval ‘(<low>, <high>]’.  The endpoints of
     the interval may be ‘minf’ or ‘inf’.

     ‘nroots’ uses the method of Sturm sequences.

          (%i1) p: x^10 - 2*x^4 + 1/2$
          (%i2) nroots (p, -6, 9.1);
          (%o2)                           4

 -- Function: nthroot (<p>, <n>)

     where <p> is a polynomial with integer coefficients and <n> is a
     positive integer returns ‘q’, a polynomial over the integers, such
     that ‘q^n = p’ or prints an error message indicating that <p> is
     not a perfect nth power.  This routine is much faster than ‘factor’
     or even ‘sqfr’.

 -- Option variable: polyfactor
     Default value: ‘false’

     The option variable ‘polyfactor’ when ‘true’ causes ‘allroots’ and
     ‘bfallroots’ to factor the polynomial over the real numbers if the
     polynomial is real, or over the complex numbers, if the polynomial
     is complex.

     See ‘allroots’ for an example.

 -- Option variable: programmode
     Default value: ‘true’

     When ‘programmode’ is ‘true’, ‘solve’, ‘realroots’, ‘allroots’, and
     ‘linsolve’ return solutions as elements in a list.  (Except when
     ‘backsubst’ is set to ‘false’, in which case ‘programmode: false’
     is assumed.)

     When ‘programmode’ is ‘false’, ‘solve’, etc.  create intermediate
     expression labels ‘%t1’, ‘%t2’, etc., and assign the solutions to
     them.

 -- Option variable: realonly
     Default value: ‘false’

     When ‘realonly’ is ‘true’, ‘algsys’ returns only those solutions
     which are free of ‘%i’.

 -- Function: realroots
          realroots (<expr>, <bound>)
          realroots (<eqn>, <bound>)
          realroots (<expr>)
          realroots (<eqn>)

     Computes rational approximations of the real roots of the
     polynomial <expr> or polynomial equation <eqn> of one variable, to
     within a tolerance of <bound>.  Coefficients of <expr> or <eqn>
     must be literal numbers; symbol constants such as ‘%pi’ are
     rejected.

     ‘realroots’ assigns the multiplicities of the roots it finds to the
     global variable ‘multiplicities’.

     ‘realroots’ constructs a Sturm sequence to bracket each root, and
     then applies bisection to refine the approximations.  All
     coefficients are converted to rational equivalents before searching
     for roots, and computations are carried out by exact rational
     arithmetic.  Even if some coefficients are floating-point numbers,
     the results are rational (unless coerced to floats by the ‘float’
     or ‘numer’ flags).

     When <bound> is less than 1, all integer roots are found exactly.
     When <bound> is unspecified, it is assumed equal to the global
     variable ‘rootsepsilon’.

     When the global variable ‘programmode’ is ‘true’, ‘realroots’
     returns a list of the form ‘[x = <x_1>, x = <x_2>, ...]’.  When
     ‘programmode’ is ‘false’, ‘realroots’ creates intermediate
     expression labels ‘%t1’, ‘%t2’, ..., assigns the results to them,
     and returns the list of labels.

     See also ‘allroots’, ‘bfallroots’, ‘guess_exact_value’, and ‘lhs’.

     Examples:

          (%i1) realroots (-1 - x + x^5, 5e-6);
                                         612003
          (%o1)                     [x = ------]
                                         524288
          (%i2) ev (%[1], float);
          (%o2)                x = 1.1673030853271484
          (%i3) ev (-1 - x + x^5, %);
          (%o3)                - 7.396496210176906e-6

          (%i1) realroots (expand ((1 - x)^5 * (2 - x)^3 * (3 - x)), 1e-20);
          (%o1)                 [x = 1, x = 2, x = 3]
          (%i2) multiplicities;
          (%o2)                       [5, 3, 1]

 -- Function: rhs (<expr>)

     Returns the right-hand side (that is, the second argument) of the
     expression <expr>, when the operator of <expr> is one of the
     relational operators ‘< <= = # equal notequal >= >’, one of the
     assignment operators ‘:= ::= : ::’, or a user-defined binary infix
     operator, as declared by ‘infix’.

     When <expr> is an atom or its operator is something other than the
     ones listed above, ‘rhs’ returns 0.

     See also ‘lhs’.

     Examples:

          (%i1) e: aa + bb = cc;
          (%o1)                     bb + aa = cc
          (%i2) lhs (e);
          (%o2)                        bb + aa
          (%i3) rhs (e);
          (%o3)                          cc
          (%i4) [rhs (aa < bb), rhs (aa <= bb), rhs (aa >= bb),
                 rhs (aa > bb)];
          (%o4)                   [bb, bb, bb, bb]
          (%i5) [rhs (aa = bb), rhs (aa # bb), rhs (equal (aa, bb)),
                 rhs (notequal (aa, bb))];
          (%o5)                   [bb, bb, bb, bb]
          (%i6) e1: '(foo(x) := 2*x);
          (%o6)                     foo(x) := 2 x
          (%i7) e2: '(bar(y) ::= 3*y);
          (%o7)                    bar(y) ::= 3 y
          (%i8) e3: '(x : y);
          (%o8)                         x : y
          (%i9) e4: '(x :: y);
          (%o9)                        x :: y
          (%i10) [rhs (e1), rhs (e2), rhs (e3), rhs (e4)];
          (%o10)                  [2 x, 3 y, y, y]
          (%i11) infix ("][");
          (%o11)                         ][
          (%i12) rhs (aa ][ bb);
          (%o12)                         bb

 -- Option variable: rootsconmode
     Default value: ‘true’

     ‘rootsconmode’ governs the behavior of the ‘rootscontract’ command.
     See ‘rootscontract’ for details.

 -- Function: rootscontract (<expr>)

     Converts products of roots into roots of products.  For example,
     ‘rootscontract (sqrt(x)*y^(3/2))’ yields ‘sqrt(x*y^3)’.

     When ‘radexpand’ is ‘true’ and ‘domain’ is ‘real’, ‘rootscontract’
     converts ‘abs’ into ‘sqrt’, e.g., ‘rootscontract (abs(x)*sqrt(y))’
     yields ‘sqrt(x^2*y)’.

     There is an option ‘rootsconmode’ affecting ‘rootscontract’ as
     follows:

          Problem            Value of        Result of applying
                            rootsconmode        rootscontract

          x^(1/2)*y^(3/2)      false          (x*y^3)^(1/2)
          x^(1/2)*y^(1/4)      false          x^(1/2)*y^(1/4)
          x^(1/2)*y^(1/4)      true           (x*y^(1/2))^(1/2)
          x^(1/2)*y^(1/3)      true           x^(1/2)*y^(1/3)
          x^(1/2)*y^(1/4)      all            (x^2*y)^(1/4)
          x^(1/2)*y^(1/3)      all            (x^3*y^2)^(1/6)

     When ‘rootsconmode’ is ‘false’, ‘rootscontract’ contracts only with
     respect to rational number exponents whose denominators are the
     same.  The key to the ‘rootsconmode: true’ examples is simply that
     2 divides into 4 but not into 3.  ‘rootsconmode: all’ involves
     taking the least common multiple of the denominators of the
     exponents.

     ‘rootscontract’ uses ‘ratsimp’ in a manner similar to
     ‘logcontract’.

     Examples:

          (%i1) rootsconmode: false$
          (%i2) rootscontract (x^(1/2)*y^(3/2));
                                             3
          (%o2)                      sqrt(x y )
          (%i3) rootscontract (x^(1/2)*y^(1/4));
                                             1/4
          (%o3)                     sqrt(x) y
          (%i4) rootsconmode: true$
          (%i5) rootscontract (x^(1/2)*y^(1/4));
          (%o5)                    sqrt(x sqrt(y))
          (%i6) rootscontract (x^(1/2)*y^(1/3));
                                             1/3
          (%o6)                     sqrt(x) y
          (%i7) rootsconmode: all$
          (%i8) rootscontract (x^(1/2)*y^(1/4));
                                        2   1/4
          (%o8)                       (x  y)
          (%i9) rootscontract (x^(1/2)*y^(1/3));
                                       3  2 1/6
          (%o9)                      (x  y )
          (%i10) rootsconmode: false$
          (%i11) rootscontract (sqrt(sqrt(x) + sqrt(1 + x))
                              *sqrt(sqrt(1 + x) - sqrt(x)));
          (%o11)                          1
          (%i12) rootsconmode: true$
          (%i13) rootscontract (sqrt(5 + sqrt(5)) - 5^(1/4)*sqrt(1 + sqrt(5)));
          (%o13)                          0

 -- Option variable: rootsepsilon
     Default value: 1.0e-7

     ‘rootsepsilon’ is the tolerance which establishes the confidence
     interval for the roots found by the ‘realroots’ function.

 -- Function: solve
          solve (<expr>, <x>)
          solve (<expr>)
          solve ([<eqn_1>, ..., <eqn_n>], [<x_1>, ..., <x_n>])

     Solves the algebraic equation <expr> for the variable <x> and
     returns a list of solution equations in <x>.  If <expr> is not an
     equation, the equation ‘<expr> = 0’ is assumed in its place.  <x>
     may be a function (e.g.  ‘f(x)’), or other non-atomic expression
     except a sum or product.  <x> may be omitted if <expr> contains
     only one variable.  <expr> may be a rational expression, and may
     contain trigonometric functions, exponentials, etc.

     The following method is used:

     Let <E> be the expression and <X> be the variable.  If <E> is
     linear in <X> then it is trivially solved for <X>.  Otherwise if
     <E> is of the form ‘A*X^N + B’ then the result is ‘(-B/A)^1/N)’
     times the ‘N’’th roots of unity.

     If <E> is not linear in <X> then the gcd of the exponents of <X> in
     <E> (say <N>) is divided into the exponents and the multiplicity of
     the roots is multiplied by <N>.  Then ‘solve’ is called again on
     the result.  If <E> factors then ‘solve’ is called on each of the
     factors.  Finally ‘solve’ will use the quadratic, cubic, or quartic
     formulas where necessary.

     In the case where <E> is a polynomial in some function of the
     variable to be solved for, say ‘F(X)’, then it is first solved for
     ‘F(X)’ (call the result <C>), then the equation ‘F(X)=C’ can be
     solved for <X> provided the inverse of the function <F> is known.

     ‘breakup’ if ‘false’ will cause ‘solve’ to express the solutions of
     cubic or quartic equations as single expressions rather than as
     made up of several common subexpressions which is the default.

     ‘multiplicities’ - will be set to a list of the multiplicities of
     the individual solutions returned by ‘solve’, ‘realroots’, or
     ‘allroots’.  Try ‘apropos (solve)’ for the switches which affect
     ‘solve’.  ‘describe’ may then by used on the individual switch
     names if their purpose is not clear.

     ‘solve ([<eqn_1>, ..., <eqn_n>], [<x_1>, ..., <x_n>])’ solves a
     system of simultaneous (linear or non-linear) polynomial equations
     by calling ‘linsolve’ or ‘algsys’ and returns a list of the
     solution lists in the variables.  In the case of ‘linsolve’ this
     list would contain a single list of solutions.  It takes two lists
     as arguments.  The first list represents the equations to be
     solved; the second list is a list of the unknowns to be determined.
     If the total number of variables in the equations is equal to the
     number of equations, the second argument-list may be omitted.

     When ‘programmode’ is ‘false’, ‘solve’ displays solutions with
     intermediate expression (‘%t’) labels, and returns the list of
     labels.

     When ‘globalsolve’ is ‘true’ and the problem is to solve two or
     more linear equations, each solved-for variable is bound to its
     value in the solution of the equations.

     Examples:

          (%i1) solve (asin (cos (3*x))*(f(x) - 1), x);
          solve: using arc-trig functions to get a solution.
          Some solutions will be lost.
                                      %pi
          (%o1)                  [x = ---, f(x) = 1]
                                       6
          (%i2) ev (solve (5^f(x) = 125, f(x)), solveradcan);
                                          log(125)
          (%o2)                   [f(x) = --------]
                                           log(5)
          (%i3) [4*x^2 - y^2 = 12, x*y - x = 2];
                                2    2
          (%o3)             [4 x  - y  = 12, x y - x = 2]
          (%i4) solve (%, [x, y]);
          (%o4) [[x = 2, y = 2], [x = 0.5202594388652008 %i
           - 0.1331240357358706, y = 0.07678378523787788
           - 3.608003221870287 %i], [x = - 0.5202594388652008 %i
           - 0.1331240357358706, y = 3.608003221870287 %i
           + 0.07678378523787788], [x = - 1.733751846381093,
          y = - 0.15356757100196963]]
          (%i5) solve (1 + a*x + x^3, x);
                                                 3
                      - 1   sqrt(3) %i   sqrt(4 a  + 27)   1 1/3
          (%o5) [x = (--- - ----------) (--------------- - -)
                       2        2               3/2        2
                                             2 3
                 sqrt(3) %i   - 1
                (---------- + ---) a
                     2         2
           - --------------------------, x =
                        3
                sqrt(4 a  + 27)   1 1/3
             3 (--------------- - -)
                       3/2        2
                    2 3
                                      3
           sqrt(3) %i   - 1   sqrt(4 a  + 27)   1 1/3
          (---------- + ---) (--------------- - -)
               2         2           3/2        2
                                  2 3
                 - 1   sqrt(3) %i
                (--- - ----------) a
                  2        2
           - --------------------------, x =
                        3
                sqrt(4 a  + 27)   1 1/3
             3 (--------------- - -)
                       3/2        2
                    2 3
                   3
           sqrt(4 a  + 27)   1 1/3               a
          (--------------- - -)    - --------------------------]
                  3/2        2                  3
               2 3                      sqrt(4 a  + 27)   1 1/3
                                     3 (--------------- - -)
                                               3/2        2
                                            2 3
          (%i6) solve (x^3 - 1);
                       sqrt(3) %i - 1        sqrt(3) %i + 1
          (%o6)   [x = --------------, x = - --------------, x = 1]
                             2                     2
          (%i7) solve (x^6 - 1);
                     sqrt(3) %i + 1      sqrt(3) %i - 1
          (%o7) [x = --------------, x = --------------, x = - 1,
                           2                   2
                               sqrt(3) %i + 1        sqrt(3) %i - 1
                         x = - --------------, x = - --------------, x = 1]
                                     2                     2
          (%i8) ev (x^6 - 1, %[1]);
                                                6
                                (sqrt(3) %i + 1)
          (%o8)                 ----------------- - 1
                                       64
          (%i9) expand (%);
          (%o9)                           0
          (%i10) x^2 - 1;
                                        2
          (%o10)                       x  - 1
          (%i11) solve (%, x);
          (%o11)                  [x = - 1, x = 1]
          (%i12) ev (%th(2), %[1]);
          (%o12)                          0

     The symbols ‘%r’ are used to denote arbitrary constants in a
     solution.

          (%i1) solve([x+y=1,2*x+2*y=2],[x,y]);
          solve: dependent equations eliminated: (2)
          (%o1)               [[x = 1 - %r1, y = %r1]]

     See ‘algsys’ and ‘%rnum_list’ for more information.

 -- Option variable: solvedecomposes
     Default value: ‘true’

     When ‘solvedecomposes’ is ‘true’, ‘solve’ calls ‘polydecomp’ if
     asked to solve polynomials.

 -- Option variable: solveexplicit
     Default value: ‘false’

     When ‘solveexplicit’ is ‘true’, inhibits ‘solve’ from returning
     implicit solutions, that is, solutions of the form ‘F(x) = 0’ where
     ‘F’ is some function.

 -- Option variable: solvefactors
     Default value: ‘true’

     When ‘solvefactors’ is ‘false’, ‘solve’ does not try to factor the
     expression.  The ‘false’ setting may be desired in some cases where
     factoring is not necessary.

 -- Option variable: solvenullwarn
     Default value: ‘true’

     When ‘solvenullwarn’ is ‘true’, ‘solve’ prints a warning message if
     called with either a null equation list or a null variable list.
     For example, ‘solve ([], [])’ would print two warning messages and
     return ‘[]’.

 -- Option variable: solveradcan
     Default value: ‘false’

     When ‘solveradcan’ is ‘true’, ‘solve’ calls ‘radcan’ which makes
     ‘solve’ slower but will allow certain problems containing
     exponentials and logarithms to be solved.

 -- Option variable: solvetrigwarn
     Default value: ‘true’

     When ‘solvetrigwarn’ is ‘true’, ‘solve’ may print a message saying
     that it is using inverse trigonometric functions to solve the
     equation, and thereby losing solutions.


File: maxima.info,  Node: Examples for algsys,  Next: References for equations,  Prev: Functions and Variables for Equations,  Up: Equations

19.2 Examples for algsys
========================

<algsys> often fails to solve problems that have solutions.  The
following examples provide some solution strategies.

19.2.1 Strategies
-----------------

Many users try to solve the most general problem imaginable, with
multiple free parameters.  Unfortunately the size and complexity of
individual solutions increases rapidly with the number of parameters, as
can be seen in the examples below.  This ’expression swell’ makes it
difficult for a computer algebra system to confirm symbolically that
solutions satisfy the input equations so solutions can be incorrectly
rejected by a solver.  Every effort should be made to reduce the
complexity of, and number of parameters in, the equations to be solved.

19.2.2 Example 1: Intersection of two circles
---------------------------------------------

We wish to find the intersection points of two circles: one centered at
(a,b) with radius r and the second centered at (c,d) with radius s.

   <algsys> does not find a solution to the original problem.
     (%i1) eq1: (x-a)^2+(y-b)^2-r^2;
                                2          2    2
     (%o1)               (y - b)  + (x - a)  - r
     (%i2) eq2: (x-c)^2+(y-d)^2-s^2;
                                2          2    2
     (%o2)               (y - d)  + (x - c)  - s
     (%i3) algsys([eq1,eq2],[x,y]);
     (%o3)                          []

Simplify the problem
....................

This problem can be transformed to eliminate parameters by: translating
the center of the first circle to the origin; scaling so that the first
circle has radius 1; and, rotating about the new origin so that the
center of the second circle is located on the positive x-axis.

     (%i1) eq1a:x^2+y^2-1;
                                 2    2
     (%o1)                      y  + x  - 1
     (%i2) eq2a:(x-C)^2+y^2-S^2;
                             2          2    2
     (%o2)                  y  + (x - C)  - S
     (%i3) algsys([eq1a,eq2a],[x,y]);
                    2    2
                   S  - C  - 1
     (%o3) [[x = - -----------, y =
                       2 C
               4       2       2    4      2
       sqrt(- S  + (2 C  + 2) S  - C  + 2 C  - 1)
     - ------------------------------------------],
                          2 C
             2    2
            S  - C  - 1
     [x = - -----------, y =
                2 C
             4       2       2    4      2
     sqrt(- S  + (2 C  + 2) S  - C  + 2 C  - 1)
     ------------------------------------------]]
                        2 C

   It is not necessary to rescale these equations to obtain a solution.

     (%i1) eq1b:x^2+y^2-r^2;
                                2    2    2
     (%o1)                     y  + x  - r
     (%i2) eq2b:(x-C)^2+y^2-s^2;
                             2          2    2
     (%o2)                  y  + (x - C)  - s
     (%i3) algsys([eq1b,eq2b],[x,y]);
                    2    2    2
                   s  - r  - C
     (%o3) [[x = - ------------, y =
                       2 C
               4       2      2   2    4      2  2    4
       sqrt(- s  + (2 r  + 2 C ) s  - r  + 2 C  r  - C )
     - -------------------------------------------------],
                              2 C
             2    2    2
            s  - r  - C
     [x = - ------------, y =
                2 C
             4       2      2   2    4      2  2    4
     sqrt(- s  + (2 r  + 2 C ) s  - r  + 2 C  r  - C )
     -------------------------------------------------]]
                            2 C

Simplify the equations
......................

Another strategy is to simplify the equations.  The expression <eq1-eq2>
is linear in unknowns <x> and <y>.  <algsys> can solve the simpler
system of equations <[eq1,eq1-eq2]>.

   Note the complexity of the solution at (%o4).

     (%i1) eq1: (x-a)^2+(y-b)^2-r^2;
                                2          2    2
     (%o1)               (y - b)  + (x - a)  - r
     (%i2) eq2: (x-c)^2+(y-d)^2-s^2;
                                2          2    2
     (%o2)               (y - d)  + (x - c)  - s
     (%i3) eq3: expand(eq1-eq2);
                                            2    2    2    2    2    2
     (%o3) 2 d y - 2 b y + 2 c x - 2 a x + s  - r  - d  - c  + b  + a
     (%i4) soln:algsys([eq1,eq3],[x,y]);
                                    4
     (%o4) [[x = - ((d - b) sqrt(- s
            2      2              2              2      2   2    4
      + (2 r  + 2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a ) s  - r
            2              2              2      2   2    4        3
      + (2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a ) r  - d  + 4 b d
              2              2      2   2
      + (- 2 c  + 4 a c - 6 b  - 2 a ) d
              2                3      2         4        3
      + (4 b c  - 8 a b c + 4 b  + 4 a  b) d - c  + 4 a c
              2      2   2         2      3       4      2  2    4
      + (- 2 b  - 6 a ) c  + (4 a b  + 4 a ) c - b  - 2 a  b  - a )
                 2            2              2
      + (c - a) s  + (a - c) r  + (- c - a) d  + (2 b c + 2 a b) d
         3      2     2    2         2    3
      - c  + a c  + (a  - b ) c - a b  - a )
          2              2              2      2
     /(2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a ),
                          4       2      2              2
     y = ((c - a) sqrt(- s  + (2 r  + 2 d  - 4 b d + 2 c  - 4 a c
           2      2   2    4       2              2              2
      + 2 b  + 2 a ) s  - r  + (2 d  - 4 b d + 2 c  - 4 a c + 2 b
           2   2    4        3         2              2      2   2
      + 2 a ) r  - d  + 4 b d  + (- 2 c  + 4 a c - 6 b  - 2 a ) d
              2                3      2         4        3
      + (4 b c  - 8 a b c + 4 b  + 4 a  b) d - c  + 4 a c
              2      2   2         2      3       4      2  2    4
      + (- 2 b  - 6 a ) c  + (4 a b  + 4 a ) c - b  - 2 a  b  - a )
                 2            2    3      2     2            2    2
      + (b - d) s  + (d - b) r  + d  - b d  + (c  - 2 a c - b  + a ) d
           2              3    2        2              2
      + b c  - 2 a b c + b  + a  b)/(2 d  - 4 b d + 2 c  - 4 a c
           2      2                          4
      + 2 b  + 2 a )], [x = ((d - b) sqrt(- s
            2      2              2              2      2   2    4
      + (2 r  + 2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a ) s  - r
            2              2              2      2   2    4        3
      + (2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a ) r  - d  + 4 b d
              2              2      2   2
      + (- 2 c  + 4 a c - 6 b  - 2 a ) d
              2                3      2         4        3
      + (4 b c  - 8 a b c + 4 b  + 4 a  b) d - c  + 4 a c
              2      2   2         2      3       4      2  2    4
      + (- 2 b  - 6 a ) c  + (4 a b  + 4 a ) c - b  - 2 a  b  - a )
                 2            2            2
      + (a - c) s  + (c - a) r  + (c + a) d  + (- 2 b c - 2 a b) d
         3      2     2    2         2    3
      + c  - a c  + (b  - a ) c + a b  + a )
          2              2              2      2
     /(2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a ),
                            4       2      2              2
     y = - ((c - a) sqrt(- s  + (2 r  + 2 d  - 4 b d + 2 c  - 4 a c
           2      2   2    4       2              2              2
      + 2 b  + 2 a ) s  - r  + (2 d  - 4 b d + 2 c  - 4 a c + 2 b
           2   2    4        3         2              2      2   2
      + 2 a ) r  - d  + 4 b d  + (- 2 c  + 4 a c - 6 b  - 2 a ) d
              2                3      2         4        3
      + (4 b c  - 8 a b c + 4 b  + 4 a  b) d - c  + 4 a c
              2      2   2         2      3       4      2  2    4
      + (- 2 b  - 6 a ) c  + (4 a b  + 4 a ) c - b  - 2 a  b  - a )
                 2            2    3      2
      + (d - b) s  + (b - d) r  - d  + b d
            2            2    2         2              3    2
      + (- c  + 2 a c + b  - a ) d - b c  + 2 a b c - b  - a  b)
          2              2              2      2
     /(2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a )]]
     (%i5) ratsimp(subst(soln[1],[eq1,eq2]));
     (%o5)                        [0, 0]
     (%i6) ratsimp(subst(soln[2],[eq1,eq2]));
     (%o6)                        [0, 0]

Simplify the equations using poly_reduced_grobner
.................................................

Sometimes the system of equations can be solved after preprocessing with
the function ‘poly_reduced_grobner’ from the <grobner> package.

   The reduced Gröbner basis returned at (%o4) consists of two
polynomials in unknowns <x> and <y>: the first is bilinear in the
unknowns; the second is quadratic in <y> only.  This confirms there are
two (perhaps multiple) solutions, as we know geometrically.

     (%i1) eq1: (x-a)^2+(y-b)^2-r^2;
                                2          2    2
     (%o1)               (y - b)  + (x - a)  - r
     (%i2) eq2: (x-c)^2+(y-d)^2-s^2;
                                2          2    2
     (%o2)               (y - d)  + (x - c)  - s
     (%i3) /* load grobner package */
      load("grobner")$
     (%i4) poly_reduced_grobner([eq1,eq2],[x,y]);
                                             2    2    2    2    2
     (%o4) [(2 d - 2 b) y + (2 c - 2 a) x + s  - r  - d  - c  + b
         2      2              2              2      2   2
      + a , (4 d  - 8 b d + 4 c  - 8 a c + 4 b  + 4 a ) y
               2      2      2          2      2       3        2
      + (d (4 s  - 4 r  + 4 b ) + b (4 r  - 4 s ) - 4 d  + 4 b d
                           2                  2                    3
      + a c (8 d + 8 b) + c  (- 4 d - 4 b) + a  (- 4 d - 4 b) - 4 b )
           4            2      2      2      2       3
      y + s  + c (a (4 s  + 4 r  - 4 d  - 4 b ) - 4 a )
         2     2      2       2  2    2       2      2      2
      + b  (2 s  - 2 r ) - 2 r  s  + d  (- 2 s  + 2 r  - 2 b )
         2       2      2      2      2      2
      + c  (- 2 s  - 2 r  + 2 d  + 2 b  + 6 a )
         2       2      2      2      2     4    4    4        3    4
      + a  (- 2 s  - 2 r  + 2 d  + 2 b ) + r  + d  + c  - 4 a c  + b
         4
      + a ]
     (%i5) soln:algsys(%,[x,y]);
                                    4
     (%o5) [[x = - ((d - b) sqrt(- s
            2      2              2              2      2   2    4
      + (2 r  + 2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a ) s  - r
            2              2              2      2   2    4        3
      + (2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a ) r  - d  + 4 b d
              2              2      2   2
      + (- 2 c  + 4 a c - 6 b  - 2 a ) d
              2                3      2         4        3
      + (4 b c  - 8 a b c + 4 b  + 4 a  b) d - c  + 4 a c
              2      2   2         2      3       4      2  2    4
      + (- 2 b  - 6 a ) c  + (4 a b  + 4 a ) c - b  - 2 a  b  - a )
                 2            2              2
      + (c - a) s  + (a - c) r  + (- c - a) d  + (2 b c + 2 a b) d
         3      2     2    2         2    3
      - c  + a c  + (a  - b ) c - a b  - a )
          2              2              2      2
     /(2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a ),
                          4       2      2              2
     y = ((c - a) sqrt(- s  + (2 r  + 2 d  - 4 b d + 2 c  - 4 a c
           2      2   2    4       2              2              2
      + 2 b  + 2 a ) s  - r  + (2 d  - 4 b d + 2 c  - 4 a c + 2 b
           2   2    4        3         2              2      2   2
      + 2 a ) r  - d  + 4 b d  + (- 2 c  + 4 a c - 6 b  - 2 a ) d
              2                3      2         4        3
      + (4 b c  - 8 a b c + 4 b  + 4 a  b) d - c  + 4 a c
              2      2   2         2      3       4      2  2    4
      + (- 2 b  - 6 a ) c  + (4 a b  + 4 a ) c - b  - 2 a  b  - a )
                 2            2    3      2     2            2    2
      + (b - d) s  + (d - b) r  + d  - b d  + (c  - 2 a c - b  + a ) d
           2              3    2        2              2
      + b c  - 2 a b c + b  + a  b)/(2 d  - 4 b d + 2 c  - 4 a c
           2      2                          4
      + 2 b  + 2 a )], [x = ((d - b) sqrt(- s
            2      2              2              2      2   2    4
      + (2 r  + 2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a ) s  - r
            2              2              2      2   2    4        3
      + (2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a ) r  - d  + 4 b d
              2              2      2   2
      + (- 2 c  + 4 a c - 6 b  - 2 a ) d
              2                3      2         4        3
      + (4 b c  - 8 a b c + 4 b  + 4 a  b) d - c  + 4 a c
              2      2   2         2      3       4      2  2    4
      + (- 2 b  - 6 a ) c  + (4 a b  + 4 a ) c - b  - 2 a  b  - a )
                 2            2            2
      + (a - c) s  + (c - a) r  + (c + a) d  + (- 2 b c - 2 a b) d
         3      2     2    2         2    3
      + c  - a c  + (b  - a ) c + a b  + a )
          2              2              2      2
     /(2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a ),
                            4       2      2              2
     y = - ((c - a) sqrt(- s  + (2 r  + 2 d  - 4 b d + 2 c  - 4 a c
           2      2   2    4       2              2              2
      + 2 b  + 2 a ) s  - r  + (2 d  - 4 b d + 2 c  - 4 a c + 2 b
           2   2    4        3         2              2      2   2
      + 2 a ) r  - d  + 4 b d  + (- 2 c  + 4 a c - 6 b  - 2 a ) d
              2                3      2         4        3
      + (4 b c  - 8 a b c + 4 b  + 4 a  b) d - c  + 4 a c
              2      2   2         2      3       4      2  2    4
      + (- 2 b  - 6 a ) c  + (4 a b  + 4 a ) c - b  - 2 a  b  - a )
                 2            2    3      2
      + (d - b) s  + (b - d) r  - d  + b d
            2            2    2         2              3    2
      + (- c  + 2 a c + b  - a ) d - b c  + 2 a b c - b  - a  b)
          2              2              2      2
     /(2 d  - 4 b d + 2 c  - 4 a c + 2 b  + 2 a )]]
     (%i6) ratsimp(subst(soln[1],[eq1,eq2]));
     (%o6)                        [0, 0]
     (%i7) ratsimp(subst(soln[2],[eq1,eq2]));
     (%o7)                        [0, 0]

19.2.3 Example 2: Equations with irrational coefficients
--------------------------------------------------------

The presence of irrational coefficients can prevent <algsys> from
finding solutions.  Replacing the constant with a symbol allows a
solution to be found.

     (%i1) eq1: %pi*y + x - 1;
     (%o1)                     %pi y + x - 1
     (%i2) eq2: 1 - x^2*y;
                                      2
     (%o2)                       1 - x  y
     (%i3) algsys([eq1,eq2],[x,y]);
     (%o3)                          []
     (%i4) /* Substitute p for %p and magically algsys finds solutions */
      eq1a:subst(p,%pi,eq1);
     (%o4)                      p y + x - 1
     (%i5) s:algsys([eq1a,eq2],[x,y]);
                      5/3               5/3
     (%o5) [[x = - ((2    sqrt(3) %i + 2   )
        3/2          2                   1/3
      (3    sqrt(27 p  - 4 p) - 27 p + 2)
          3/2          2                   2/3
      + (3    sqrt(27 p  - 4 p) - 27 p + 2)
           1/3       1/3  3/2           2
      ((9 2    %i - 2    3   ) sqrt(27 p  - 4 p)
          1/3  7/2          1/3       4/3               4/3
      + (2    3    %i - 27 2   ) p - 2    sqrt(3) %i + 2   ) - 8)/24,
            5/3               5/3
     y = ((2    sqrt(3) %i + 2   )
        3/2          2                   1/3
      (3    sqrt(27 p  - 4 p) - 27 p + 2)
          3/2          2                   2/3
      + (3    sqrt(27 p  - 4 p) - 27 p + 2)
           1/3       1/3  3/2           2
      ((9 2    %i - 2    3   ) sqrt(27 p  - 4 p)
          1/3  7/2          1/3       4/3               4/3
      + (2    3    %i - 27 2   ) p - 2    sqrt(3) %i + 2   ) + 16)
                       5/3               5/3
     /(24 p)], [x = ((2    sqrt(3) %i - 2   )
        3/2          2                   1/3
      (3    sqrt(27 p  - 4 p) - 27 p + 2)
          3/2          2                   2/3
      + (3    sqrt(27 p  - 4 p) - 27 p + 2)
           1/3       1/3  3/2           2
      ((9 2    %i + 2    3   ) sqrt(27 p  - 4 p)
          1/3  7/2          1/3       4/3               4/3
      + (2    3    %i + 27 2   ) p - 2    sqrt(3) %i - 2   ) + 8)/24,
              5/3               5/3
     y = - ((2    sqrt(3) %i - 2   )
        3/2          2                   1/3
      (3    sqrt(27 p  - 4 p) - 27 p + 2)
          3/2          2                   2/3
      + (3    sqrt(27 p  - 4 p) - 27 p + 2)
           1/3       1/3  3/2           2
      ((9 2    %i + 2    3   ) sqrt(27 p  - 4 p)
          1/3  7/2          1/3       4/3               4/3
      + (2    3    %i + 27 2   ) p - 2    sqrt(3) %i - 2   ) - 16)
                          5/3   3/2          2                   1/3
     /(24 p)], [x = - (- 2    (3    sqrt(27 p  - 4 p) - 27 p + 2)
          3/2          2                   2/3
      + (3    sqrt(27 p  - 4 p) - 27 p + 2)
        1/3  3/2          2              1/3      4/3
      (2    3    sqrt(27 p  - 4 p) + 27 2    p - 2   ) - 4)/12,
             5/3   3/2          2                   1/3
     y = (- 2    (3    sqrt(27 p  - 4 p) - 27 p + 2)
          3/2          2                   2/3
      + (3    sqrt(27 p  - 4 p) - 27 p + 2)
        1/3  3/2          2              1/3      4/3
      (2    3    sqrt(27 p  - 4 p) + 27 2    p - 2   ) + 8)/(12 p)]]
     (%i6) /* substitute %pi for p */
      s:subst(%pi,p,s)$
     (%i7) /* Check the solution */
      ratsimp(subst(s[1],[eq1,eq2]));
     (%o7)                        [0, 0]
     (%i8) ratsimp(subst(s[2],[eq1,eq2]));
     (%o8)                        [0, 0]
     (%i9) ratsimp(subst(s[3],[eq1,eq2]));
     (%o9)                        [0, 0]
     (%i10) /* numerical values of solution */
      rectform(float(s));
     (%o10) [[x = 1.0980298583288306 - 1.1920356507617584 %i,
     y = 0.37943673232099623 %i - 0.031203873047263193],
     [x = 1.1920356507617584 %i + 1.0980298583288306,
     y = - 0.37943673232099623 %i - 0.031203873047263193],
     [x = - 1.1960597166576612, y = 0.6990275184621078]]

19.2.4 Example 3: Assumptions on parameters
-------------------------------------------

<algsys> may require assumptions on parameters to obtain a solution.  No
general guidance can be provided.  Users may be able to use their
knowledge of the problem to restrict the range of parameters
appropriately.

     (%i1) eqs:[y-x=0, g*x*y-h=0, z+(x+1)/y-x-1=0];
                                            x + 1
     (%o1)   [y - x = 0, g x y - h = 0, z + ----- - x - 1 = 0]
                                              y
     (%i2) /* without assumptions no solution is found */
      algsys(eqs,[x,y,z]);
     (%o2)                          []
     (%i3) assume(h>0);
     (%o3)                        [h > 0]
     (%i4) algsys(eqs,[x,y,z]);
                 sqrt(h)      sqrt(h)           h - g
     (%o4) [[x = -------, y = -------, z = ---------------],
                 sqrt(g)      sqrt(g)      sqrt(g) sqrt(h)
                       sqrt(h)        sqrt(h)             h - g
                [x = - -------, y = - -------, z = - ---------------]]
                       sqrt(g)        sqrt(g)        sqrt(g) sqrt(h)
     (%i5) /* With a different assumption the solution has a different form */
      (forget(h>0),assume(h<0));
     (%o5)                        [h < 0]
     (%i6) algsys(eqs,[x,y,z]);
                   %i sqrt(- h)        %i sqrt(- h)
     (%o6) [[x = - ------------, y = - ------------,
                     sqrt(g)             sqrt(g)
           sqrt(- h) (%i h - %i g)
     z = - -----------------------],
                  sqrt(g) h
          %i sqrt(- h)      %i sqrt(- h)
     [x = ------------, y = ------------,
            sqrt(g)           sqrt(g)
         sqrt(- h) (%i h - %i g)
     z = -----------------------]]
                sqrt(g) h

19.2.5 Example 4: Preproccess equations with poly_reduced_grobner
-----------------------------------------------------------------

In this example the direct solution of the system of equations using
<algsys> finds four real solutions.  After preprocessing with
‘poly_reduced_grobner’, ten solutions are found.

   Inspection of the reduced Gröbner basis returned at (%o5) shows that
it comprises a degree-10 polynomial in <y> and an expression linear in
<x> and of degree-8 in <y>.  There can be at most 10 solutions for y,
and exactly one <x> solution for each <y> solution, for a maximum of ten
solutions overall.

     (%i1) p1:-x*y^3+y^2+x^4-9*x/8;
                               3    2    4   9 x
     (%o1)                - x y  + y  + x  - ---
                                              8
     (%i2) p2:y^4-x^3*y-9*y/8+x^2;
                            4    3     9 y    2
     (%o2)                 y  - x  y - --- + x
                                        8
     (%i3) algsys([p1,p2],[x,y]);
                 1               9      9               1
     (%o3) [[x = -, y = 1], [x = -, y = -], [x = 1, y = -],
                 2               8      8               2
                                                       [x = 0, y = 0]]
     (%i4) /* load grobner package */
      load("grobner")$
     (%i5) eqs:poly_reduced_grobner([p1,p2],[x,y]);
                      8           5           2
     (%o5) [- 200704 y  + 437832 y  - 263633 y  + 53010 x,
                                      10          7         4
                                4096 y   - 10440 y  + 7073 y  - 729 y]
     (%i6) algsys(eqs,[x,y]);
                                        1        9      9
     (%o6) [[x = 0, y = 0], [x = 1, y = -], [x = -, y = -],
                                        2        8      8
          1               sqrt(3) %i - 1        sqrt(3) %i + 1
     [x = -, y = 1], [x = --------------, y = - --------------],
          2                     4                     2
            sqrt(3) %i + 1      sqrt(3) %i - 1
     [x = - --------------, y = --------------],
                  4                   2
           5/2                5/2
          3    %i - 9        3    %i + 9
     [x = -----------, y = - -----------],
              16                 16
             5/2              5/2
            3    %i + 9      3    %i - 9
     [x = - -----------, y = -----------],
                16               16
          sqrt(3) %i - 1        sqrt(3) %i + 1
     [x = --------------, y = - --------------],
                2                     4
            sqrt(3) %i + 1      sqrt(3) %i - 1
     [x = - --------------, y = --------------]]
                  2                   4

19.2.6 Example 5: Intersection of a sphere with two paraboloids
---------------------------------------------------------------

This problem is the intersection of a sphere with two paraboloids (*note
Allgower et al 1992: allgower, Example 2, p841).

   There are two real solutions y = z = (sqrt(5)-1)/2, x = +/-
sqrt(z-y^2) = +/- sqrt(sqrt(5)-2).

     (%i1) algsys([x^2+y^2+z^2-1,z-x^2-y^2,y-x^2-z^2],[x,y,z]);
                                 sqrt(5) - 1        sqrt(5) + 1
     (%o1) [[x = sqrt(2) %i, y = -----------, z = - -----------],
                                      2                  2
                            sqrt(5) + 1      sqrt(5) - 1
     [x = sqrt(2) %i, y = - -----------, z = -----------],
                                 2                2
                            sqrt(5) - 1        sqrt(5) + 1
     [x = - sqrt(2) %i, y = -----------, z = - -----------],
                                 2                  2
                              sqrt(5) + 1      sqrt(5) - 1
     [x = - sqrt(2) %i, y = - -----------, z = -----------],
                                   2                2
                                     sqrt(5) + 1        sqrt(5) + 1
     [x = sqrt(- sqrt(5) - 2), y = - -----------, z = - -----------],
                                          2                  2
                                       sqrt(5) + 1
     [x = - sqrt(- sqrt(5) - 2), y = - -----------,
                                            2
           sqrt(5) + 1                               sqrt(5) - 1
     z = - -----------], [x = sqrt(sqrt(5) - 2), y = -----------,
                2                                         2
         sqrt(5) - 1                                 sqrt(5) - 1
     z = -----------], [x = - sqrt(sqrt(5) - 2), y = -----------,
              2                                           2
         sqrt(5) - 1
     z = -----------]]
              2

