Functions for Numbers
=====================

 -- Function: abs (Z)

     The abs function represents the mathematical absolute value function and works for both numerical and symbolic values. If the argument, Z, is a real or complex number, abs returns the absolute value of Z. If possible, symbolic expressions using the absolute value function are also simplified.

     Maxima can differentiate, integrate and calculate limits for expressions containing abs. The abs_integrate package further extends Maxima's ability to calculate integrals involving the abs function. See (%i12) in the examples below.

     When applied to a list or matrix, abs automatically distributes over the terms. Similarly, it distributes over both sides of an equation. To alter this behaviour, see the variable distribute_over

     See also cabs

     Examples:

     Calculation of abs for real and complex numbers, including numerical constants and various infinities. The first example shows how abs distributes over the elements of a list.

          (%i1) abs([-4, 0, 1, 1+%i]);
          (%o1)                  [4, 0, 1, sqrt(2)]

          (%i2) abs((1+%i)*(1-%i));
          (%o2)                           2
          (%i3) abs(%e+%i);
                                          2
          (%o3)                    sqrt(%e  + 1)
          (%i4) abs([inf, infinity, minf]);
          (%o4)                   [inf, inf, inf]

     Simplification of expressions containing abs:

          (%i5) abs(x^2);
                                          2
          (%o5)                          x
          (%i6) abs(x^3);
                                       2
          (%o6)                       x  abs(x)

          (%i7) abs(abs(x));
          (%o7)                       abs(x)
          (%i8) abs(conjugate(x));
          (%o8)                       abs(x)

     Integrating and differentiating with the abs function. Note that more integrals involving the abs function can be performed, if the abs_integrate package is loaded. The last example shows the Laplace transform of abs: see laplace

          (%i9) diff(x*abs(x),x),expand;
          (%o9)                       2 abs(x)

          (%i10) integrate(abs(x),x);
                                       x abs(x)
          (%o10)                       --------
                                          2

          (%i11) integrate(x*abs(x),x);
                                     /
                                     [
          (%o11)                     I x abs(x) dx
                                     ]
                                     /

          (%i12) load("abs_integrate")$
          (%i13) integrate(x*abs(x),x);
                                2           3
                               x  abs(x)   x  signum(x)
          (%o13)               --------- - ------------
                                   2            6

          (%i14) integrate(abs(x),x,-2,%pi);
                                         2
                                      %pi
          (%o14)                      ---- + 2
                                       2

          (%i15) laplace(abs(x),x,s);
                                         1
          (%o15)                         --
                                          2
                                         s

     Categories: Mathematical functions

 -- Function: ceiling (X)

     When X is a real number, return the least integer that is greater than or equal to X.

     If X is a constant expression (10 * %pi, for example), ceiling evaluates X using big floating point numbers, and applies ceiling to the resulting big float.  Because ceiling uses floating point evaluation, it's possible, although unlikely, that ceiling could return an erroneous value for constant inputs.  To guard against errors, the floating point evaluation is done using three values for fpprec

     For non-constant inputs, ceiling tries to return a simplified value. Here are examples of the simplifications that ceiling knows about:

          (%i1) ceiling (ceiling (x));
          (%o1)                      ceiling(x)

          (%i2) ceiling (floor (x));
          (%o2)                       floor(x)

          (%i3) declare (n, integer)$

          (%i4) [ceiling (n), ceiling (abs (n)), ceiling (max (n, 6))];
          (%o4)                [n, abs(n), max(6, n)]

          (%i5) assume (x > 0, x < 1)$

          (%i6) ceiling (x);
          (%o6)                           1

          (%i7) tex (ceiling (a));
          $$\left \lceil a \right \rceil$$
          (%o7)                         false

     The ceiling function distributes over lists, matrices and equations. See distribute_over

     Finally, for all inputs that are manifestly complex, ceiling returns a noun form.

     If the range of a function is a subset of the integers, it can be declared to be integervalued.  Both the ceiling and floor functions can use this information; for example:

          (%i1) declare (f, integervalued)$

          (%i2) floor (f(x));
          (%o2)                         f(x)

          (%i3) ceiling (f(x) - 1);
          (%o3)                       f(x) - 1

     Example use:

          (%i1) unitfrac(r) := block([uf : [], q],
              if not(ratnump(r)) then
                 error("unitfrac: argument must be a rational number"),
              while r # 0 do (
                  uf : cons(q : 1/ceiling(1/r), uf),
                  r : r - q),
              reverse(uf));
          (%o1) unitfrac(r) := block([uf : [], q],
          if not ratnump(r) then
          error("unitfrac: argument must be a rational number"),
                                            1
          while r # 0 do (uf : cons(q : ----------, uf), r : r - q),
                                                1
                                        ceiling(-)
                                                r
          reverse(uf))

          (%i2) unitfrac (9/10);
                                      1  1  1
          (%o2)                      [-, -, --]
                                      2  3  15

          (%i3) apply ("+", %);
                                         9
          (%o3)                          --
                                         10

          (%i4) unitfrac (-9/10);
                                            1
          (%o4)                       [- 1, --]
                                            10

          (%i5) apply ("+", %);
                                          9
          (%o5)                         - --
                                          10

          (%i6) unitfrac (36/37);
                                  1  1  1  1    1
          (%o6)                  [-, -, -, --, ----]
                                  2  3  8  69  6808

          (%i7) apply ("+", %);
                                         36
          (%o7)                          --
                                         37

     Categories: Mathematical functions

 -- Function: entier (X)

     Returns the largest integer less than or equal to X where X is numeric.  fix (as in fixnum) is a synonym for this, so fix(X) is precisely the same.

     Categories: Mathematical functions

 -- Function: floor (X)

     When X is a real number, return the largest integer that is less than or equal to X.

     If X is a constant expression (10 * %pi, for example), floor evaluates X using big floating point numbers, and applies floor to the resulting big float. Because floor uses floating point evaluation, it's possible, although unlikely, that floor could return an erroneous value for constant inputs.  To guard against errors, the floating point evaluation is done using three values for fpprec

     For non-constant inputs, floor tries to return a simplified value.  Here are examples of the simplifications that floor knows about:

          (%i1) floor (ceiling (x));
          (%o1)                      ceiling(x)

          (%i2) floor (floor (x));
          (%o2)                       floor(x)

          (%i3) declare (n, integer)$

          (%i4) [floor (n), floor (abs (n)), floor (min (n, 6))];
          (%o4)                [n, abs(n), min(6, n)]

          (%i5) assume (x > 0, x < 1)$

          (%i6) floor (x);
          (%o6)                           0

          (%i7) tex (floor (a));
          $$\left \lfloor a \right \rfloor$$
          (%o7)                         false

     The floor function distributes over lists, matrices and equations. See distribute_over

     Finally, for all inputs that are manifestly complex, floor returns a noun form.

     If the range of a function is a subset of the integers, it can be declared to be integervalued.  Both the ceiling and floor functions can use this information; for example:

          (%i1) declare (f, integervalued)$

          (%i2) floor (f(x));
          (%o2)                         f(x)

          (%i3) ceiling (f(x) - 1);
          (%o3)                       f(x) - 1

     Categories: Mathematical functions

 -- Function: fix (X)

     A synonym for entier (X).

     Categories: Mathematical functions

 -- Function: hstep (X)
     The Heaviside unit step function, equal to 0 if X is negative, equal to 1 if X is positive and equal to 1/2 if X is equal to zero.

     If you want a unit step function that takes on the value of 0 at X equal to zero, use unit_step

     Categories: Laplace transform Mathematical functions

 -- Function: lmax (L)

     When L is a list or a set, return apply ('max, args (L)). When L is not a list or a set, signal an error. See also lmin and max

     Categories: Mathematical functions Lists Sets

 -- Function: lmin (L)

     When L is a list or a set, return apply ('min, args (L)). When L is not a list or a set, signal an error. See also lmax and min

     Categories: Mathematical functions Lists Sets

 -- Function: max (X_1, ..., X_N)

     Return a simplified value for the numerical maximum of the expressions X_1 through X_N. For an empty argument list, max yields minf.

     The option variable maxmin_effort controls which simplification methods are applied. Using the default value of twelve for maxmin_effort, max uses all available simplification methods. To to inhibit all simplifications, set maxmin_effort to zero.

     When maxmin_effort is one or more, for an explicit list of real numbers, max returns a number.

     Unless max needs to simplify a lengthy list of expressions, we suggest using the default value of maxmin_effort. Setting maxmin_effort to zero (no simplifications), will cause problems for some Maxima functions; accordingly, generally maxmin_effort should be nonzero.

     See also min, lmax, and lmin.

     Examples:

     In the first example, setting maxmin_effort to zero suppresses simplifications.

          (%i1) block([maxmin_effort : 0], max(1,2,x,x, max(a,b)));
          (%o1) max(1,2,max(a,b),x,x)

          (%i2) block([maxmin_effort : 1], max(1,2,x,x, max(a,b)));
          (%o2) max(2,a,b,x)

     When maxmin_effort is two or more, max compares pairs of members:

          (%i1) block([maxmin_effort : 1], max(x,x+1,x+3));
          (%o1) max(x,x+1,x+3)

          (%i2) block([maxmin_effort : 2], max(x,x+1,x+3));
          (%o2) x+3

     Finally, when maxmin_effort is three or more, max compares triples members and excludes those that are in between; for example

          (%i1) block([maxmin_effort : 4], max(x, 2*x, 3*x, 4*x));
          (%o1) max(x,4*x)

     Categories: Mathematical functions

 -- Function: min (X_1, ..., X_N)

     Return a simplified value for the numerical minimum of the expressions X_1 through X_N. For an empty argument list, minf yields inf.

     The option variable maxmin_effort controls which simplification methods are applied. Using the default value of twelve for maxmin_effort, max uses all available simplification methods. To to inhibit all simplifications, set maxmin_effort to zero.

     When maxmin_effort is one or more, for an explicit list of real numbers, min returns a number.

     Unless min needs to simplify a lengthy list of expressions, we suggest using the default value of maxmin_effort. Setting maxmin_effort to zero (no simplifications), will cause problems for some Maxima functions; accordingly, generally maxmin_effort should be nonzero.

     See also max, lmax, and lmin.

     Examples:

     In the first example, setting maxmin_effort to zero suppresses simplifications.

          (%i1) block([maxmin_effort : 0], min(1,2,x,x, min(a,b)));
          (%o1) min(1,2,a,b,x,x)

          (%i2) block([maxmin_effort : 1], min(1,2,x,x, min(a,b)));
          (%o2) min(1,a,b,x)

     When maxmin_effort is two or more, min compares pairs of members:

          (%i1) block([maxmin_effort : 1], min(x,x+1,x+3));
          (%o1) min(x,x+1,x+3)

          (%i2) block([maxmin_effort : 2], min(x,x+1,x+3));
          (%o2) x

     Finally, when maxmin_effort is three or more, min compares triples members and excludes those that are in between; for example

          (%i1) block([maxmin_effort : 4], min(x, 2*x, 3*x, 4*x));
          (%o1) max(x,4*x)

     Categories: Mathematical functions

 -- Function: round (X)

     When X is a real number, returns the closest integer to X. Multiples of 1/2 are rounded to the nearest even integer.  Evaluation of X is similar to floor and ceiling

     The round function distributes over lists, matrices and equations. See distribute_over

     Categories: Mathematical functions

 -- Function: signum (X)

     For either real or complex numbers X, the signum function returns 0 if X is zero; for a nonzero numeric input X, the signum function returns x/abs(x).

     For non-numeric inputs, Maxima attempts to determine the sign of the input. When the sign is negative, zero, or positive, signum returns -1,0, 1, respectively.  For all other values for the sign, signum a simplified but equivalent form.  The simplifications include reflection (signum(-x) gives -signum(x)) and multiplicative identity (signum(x*y) gives signum(x) * signum(y)).

     The signum function distributes over a list, a matrix, or an equation.  See sign and distribute_over

     Categories: Mathematical functions

 -- Function: truncate (X)

     When X is a real number, return the closest integer to X not greater in absolute value than X.  Evaluation of X is similar to floor and ceiling

     The truncate function distributes over lists, matrices and equations. See distribute_over

     Categories: Mathematical functions

Functions for Complex Numbers
=============================

 -- Function: cabs (EXPR)

     Calculates the absolute value of an expression representing a complex number.  Unlike the function abs the cabs function always decomposes its argument into a real and an imaginary part.  If x and y represent real variables or expressions, the cabs function calculates the absolute value of x + %i*y as

          (%i1) cabs (1);
          (%o1)                           1

          (%i2) cabs (1 + %i);
          (%o2)                        sqrt(2)

          (%i3) cabs (exp (%i));
          (%o3)                           1

          (%i4) cabs (exp (%pi * %i));
          (%o4)                           1

          (%i5) cabs (exp (3/2 * %pi * %i));
          (%o5)                           1

          (%i6) cabs (17 * exp (2 * %i));
          (%o6)                          17

     If cabs returns a noun form this most commonly is caused by some properties of the variables involved not being known:

          (%i1) cabs (a+%i*b);
                                          2    2
          (%o1)                     sqrt(b  + a )

          (%i2) declare(a,real,b,real);
          (%o2)                         done

          (%i3) cabs (a+%i*b);
                                          2    2
          (%o3)                     sqrt(b  + a )

          (%i4) assume(a>0,b>0);
          (%o4)                    [a > 0, b > 0]

          (%i5) cabs (a+%i*b);
                                          2    2
          (%o5)                     sqrt(b  + a )

     The cabs function can use known properties like symmetry properties of complex functions to help it calculate the absolute value of an expression.  If such identities exist, they can be advertised to cabs using function properties.  The symmetries that cabs understands are: mirror symmetry, conjugate function and complex characteristic.

     cabs is a verb function and is not suitable for symbolic calculations.  For such calculations (including integration, differentiation and taking limits of expressions containing absolute values), use abs

     The result of cabs can include the absolute value function, abs and the arc tangent, atan2

     When applied to a list or matrix, cabs automatically distributes over the terms.  Similarly, it distributes over both sides of an equation.

     For further ways to compute with complex numbers, see the functions rectform realpart imagpart carg conjugate and polarform

     Examples:

     Examples with sqrt and sin

          (%i1) cabs(sqrt(1+%i*x));
                                       2     1/4
          (%o1)                      (x  + 1)
          (%i2) cabs(sin(x+%i*y));
                              2        2         2        2
          (%o2)       sqrt(cos (x) sinh (y) + sin (x) cosh (y))

     The error function, erf has mirror symmetry, which is used here in the calculation of the absolute value with a complex argument:

          (%i3) cabs(erf(x+%i*y));
                                                    2
                     (erf(%i y + x) - erf(%i y - x))
          (%o3) sqrt(--------------------------------
                                    4
                                                                         2
                                          (erf(%i y + x) + erf(%i y - x))
                                        - --------------------------------)
                                                         4

     Maxima knows complex identities for the Bessel functions, which allow it to compute the absolute value for complex arguments.  Here is an example for bessel_j

          (%i4) cabs(bessel_j(1,%i));
          (%o4)                 abs(bessel_j(1, %i))

     Categories: Complex variables

 -- Function: carg (Z)

     Returns the complex argument of Z.  The complex argument is an angle theta in (-%pi, %pi] such that r exp (theta %i) = Z where r is the magnitude of Z.

     carg is a computational function, not a simplifying function.

     See also abs (complex magnitude), polarform rectform realpart and imagpart

     Examples:

          (%i1) carg (1);
          (%o1)                           0

          (%i2) carg (1 + %i);
                                         %pi
          (%o2)                          ---
                                          4

          (%i3) carg (exp (%i));
                                         sin(1)
          (%o3)                     atan(------)
                                         cos(1)

          (%i4) carg (exp (%pi * %i));
          (%o4)                          %pi

          (%i5) carg (exp (3/2 * %pi * %i));
                                          %pi
          (%o5)                         - ---
                                           2

          (%i6) carg (17 * exp (2 * %i));
                                      sin(2)
          (%o6)                  atan(------) + %pi
                                      cos(2)

     If carg returns a noun form this most commonly is caused by some properties of the variables involved not being known:

          (%i1) carg (a+%i*b);
          (%o1)                      atan2(b, a)

          (%i2) declare(a,real,b,real);
          (%o2)                         done

          (%i3) carg (a+%i*b);
          (%o3)                      atan2(b, a)

          (%i4) assume(a>0,b>0);
          (%o4)                    [a > 0, b > 0]

          (%i5) carg (a+%i*b);
                                            b
          (%o5)                        atan(-)
                                            a

     Categories: Complex variables

 -- Function: conjugate (X)

     Returns the complex conjugate of X.

          (%i1) declare ([aa, bb], real, cc, complex, ii, imaginary);
          (%o1)                         done

          (%i2) conjugate (aa + bb*%i);
          (%o2)                      aa - %i bb

          (%i3) conjugate (cc);
          (%o3)                     conjugate(cc)

          (%i4) conjugate (ii);
          (%o4)                         - ii

          (%i5) conjugate (xx + yy);
          (%o5)                        yy + xx

     Categories: Complex variables

 -- Function: imagpart (EXPR)

     Returns the imaginary part of the expression EXPR.

     imagpart is a computational function, not a simplifying function.

     See also abs carg polarform rectform and realpart

     Example:

          (%i1) imagpart (a+b*%i);
          (%o1)                           b

          (%i2) imagpart (1+sqrt(2)*%i);
          (%o2)                        sqrt(2)

          (%i3) imagpart (1);
          (%o3)                           0

          (%i4) imagpart (sqrt(2)*%i);
          (%o4)                        sqrt(2)

     Categories: Complex variables

 -- Function: polarform (EXPR)

     Returns an expression r %e^(%i theta) equivalent to EXPR, such that r and theta are purely real.

     Example:

          (%i1) polarform(a+b*%i);
                                 2    2    %i atan2(b, a)
          (%o1)            sqrt(b  + a ) %e

          (%i2) polarform(1+%i);
                                            %i %pi
                                            ------
                                              4
          (%o2)                   sqrt(2) %e

          (%i3) polarform(1+2*%i);
                                          %i atan(2)
          (%o3)                 sqrt(5) %e

     Categories: Complex variables Exponential and logarithm functions

 -- Function: realpart (EXPR)

     Returns the real part of EXPR.  realpart and imagpart will work on expressions involving trigonometric and hyperbolic functions, as well as square root, logarithm, and exponentiation.

     Example:

          (%i1) realpart (a+b*%i);
          (%o1)                           a

          (%i2) realpart (1+sqrt(2)*%i);
          (%o2)                           1

          (%i3) realpart (sqrt(2)*%i);
          (%o3)                           0

          (%i4) realpart (1);
          (%o4)                           1

     Categories: Complex variables

 -- Function: rectform (EXPR)

     Returns an expression a + b %i equivalent to EXPR, such that A and B are purely real.

     Example:

          (%i1) rectform(sqrt(2)*%e^(%i*%pi/4));
          (%o1)                        %i + 1

          (%i2) rectform(sqrt(b^2+a^2)*%e^(%i*atan2(b, a)));
          (%o2)                       %i b + a

          (%i3) rectform(sqrt(5)*%e^(%i*atan(2)));
          (%o3)                       2 %i + 1

     Categories: Complex variables

Combinatorial Functions
=======================

 -- Operator: !!

     The double factorial operator.

     For an integer, float, or rational number n, n!! evaluates to the product n (n-2) (n-4) (n-6) ... (n - 2 (k-1)) where k is equal to entier (n/2), that is, the largest integer less than or equal to n/2.  Note that this definition does not coincide with other published definitions for arguments which are not integers.

     For an even (or odd) integer n, n!! evaluates to the product of all the consecutive even (or odd) integers from 2 (or 1) through n inclusive.

     For an argument n which is not an integer, float, or rational, n!! yields a noun form genfact (n, n/2, 2).

     Categories: Gamma and factorial functions Operators

 -- Function: binomial (X, Y)

     The binomial coefficient X!/(Y! (X - Y)!). If X and Y are integers, then the numerical value of the binomial coefficient is computed.  If Y, or X - Y, is an integer, the binomial coefficient is expressed as a polynomial.

     Examples:

          (%i1) binomial (11, 7);
          (%o1)                          330

          (%i2) 11! / 7! / (11 - 7)!;
          (%o2)                          330

          (%i3) binomial (x, 7);
                  (x - 6) (x - 5) (x - 4) (x - 3) (x - 2) (x - 1) x
          (%o3)   -------------------------------------------------
                                        5040

          (%i4) binomial (x + 7, x);
                (x + 1) (x + 2) (x + 3) (x + 4) (x + 5) (x + 6) (x + 7)
          (%o4) -------------------------------------------------------
                                         5040

          (%i5) binomial (11, y);
          (%o5)                    binomial(11, y)

     Categories: Number theory

 -- Function: factcomb (EXPR)

     Tries to combine the coefficients of factorials in EXPR with the factorials themselves by converting, for example, (n + 1)*n! into (n + 1)!.

     sumsplitfact if set to false will cause minfactorial to be applied after a factcomb.

     Example:

          (%i1) sumsplitfact;
          (%o1)                         true

          (%i2) (n + 1)*(n + 1)*n!;
                                            2
          (%o2)                      (n + 1)  n!

          (%i3) factcomb (%);
          (%o3)                  (n + 2)! - (n + 1)!

          (%i4) sumsplitfact: not sumsplitfact;
          (%o4)                         false

          (%i5) (n + 1)*(n + 1)*n!;
                                            2
          (%o5)                      (n + 1)  n!

          (%i6) factcomb (%);
          (%o6)                 n (n + 1)! + (n + 1)!

     Categories: Gamma and factorial functions

 -- Function: factorial
 -- Operator: !

     Represents the factorial function.  Maxima treats factorial (X) the same as X!.

     For any complex number x, except for negative integers, x! is defined as gamma(x+1).

     For an integer x, x! simplifies to the product of the integers from 1 to x inclusive.  0! simplifies to 1.  For a real or complex number in float or bigfloat precision x, x! simplifies to the value of gamma (x+1).  For x equal to n/2 where n is an odd integer, x! simplifies to a rational factor times sqrt (%pi) (since gamma (1/2) is equal to sqrt (%pi)).

     The option variables factlim and gammalim control the numerical evaluation of factorials for integer and rational arguments.  The functions minfactorial and factcomb simplifies expressions containing factorials.

     The functions gamma bffac and cbffac are varieties of the gamma function.  bffac and cbffac are called internally by gamma to evaluate the gamma function for real and complex numbers in bigfloat precision.

     makegamma substitutes gamma for factorials and related functions.

     Maxima knows the derivative of the factorial function and the limits for specific values like negative integers.

     The option variable factorial_expand controls the simplification of expressions like (n+x)!, where n is an integer.

     See also binomial

     The factorial of an integer is simplified to an exact number unless the operand is greater than factlim.  The factorial for real and complex numbers is evaluated in float or bigfloat precision.

          (%i1) factlim : 10;
          (%o1)                          10

          (%i2) [0!, (7/2)!, 8!, 20!];
                               105 sqrt(%pi)
          (%o2)            [1, -------------, 40320, 20!]
                                    16

          (%i3) [4,77!, (1.0+%i)!];
          (%o3) [4, 77!, 0.3430658398165453 %i + 0.6529654964201667]

          (%i4) [2.86b0!, (1.0b0+%i)!];
          (%o4) [5.046635586910012b0, 3.430658398165454b-1 %i
                                                    + 6.529654964201667b-1]

     The factorial of a known constant, or general expression is not simplified. Even so it may be possible to simplify the factorial after evaluating the operand.

          (%i1) [(%i + 1)!, %pi!, %e!, (cos(1) + sin(1))!];
          (%o1)      [(%i + 1)!, %pi!, %e!, (sin(1) + cos(1))!]

          (%i2) ev (%, numer, %enumer);
          (%o2) [0.3430658398165453 %i + 0.6529654964201667,
                   7.188082728976031, 4.260820476357003, 1.227580202486819]

     Factorials are simplified, not evaluated. Thus x! may be replaced even in a quoted expression.

          (%i1) '([0!, (7/2)!, 4.77!, 8!, 20!]);
                    105 sqrt(%pi)
          (%o1) [1, -------------, 81.44668037931197, 40320,
                         16
                                                       2432902008176640000]

     Maxima knows the derivative of the factorial function.

          (%i1) diff(x!,x);
          (%o1)                    x! psi (x + 1)
                                         0

     The option variable factorial_expand controls expansion and simplification of expressions with the factorial function.

          (%i1) (n+1)!/n!,factorial_expand:true;
          (%o1)                         n + 1

     Categories: Gamma and factorial functions Operators

 -- Option variable: factlim
     Default value: 100000

     factlim specifies the highest factorial which is automatically expanded.  If it is -1 then all integers are expanded.

     Categories: Gamma and factorial functions

 -- Option variable: factorial_expand
     Default value: false

     The option variable factorial_expand controls the simplification of expressions like (x+n)!, where n is an integer. See factorial for an example.

     Categories: Gamma and factorial functions

 -- Function: genfact (X, Y, Z)

     Returns the generalized factorial, defined as x (x-z) (x - 2 z) ... (x - (y - 1) z).  Thus, when X is an integer, genfact (x, x, 1) = x! and genfact (x, x/2, 2) = x!!.

     Categories: Gamma and factorial functions

 -- Function: minfactorial (EXPR)

     Examines EXPR for occurrences of two factorials which differ by an integer. minfactorial then turns one into a polynomial times the other.

          (%i1) n!/(n+2)!;
                                         n!
          (%o1)                       --------
                                      (n + 2)!
          (%i2) minfactorial (%);
                                          1
          (%o2)                    ---------------
                                   (n + 1) (n + 2)

     Categories: Number theory

 -- Option variable: sumsplitfact
     Default value: true

     When sumsplitfact is false, minfactorial is applied after a factcomb

          (%i1) sumsplitfact;
          (%o1)                         true

          (%i2) n!/(n+2)!;
                                         n!
          (%o2)                       --------
                                      (n + 2)!

          (%i3) factcomb(%);
                                         n!
          (%o3)                       --------
                                      (n + 2)!

          (%i4) sumsplitfact: not sumsplitfact ;
          (%o4)                         false

          (%i5) n!/(n+2)!;
                                         n!
          (%o5)                       --------
                                      (n + 2)!

          (%i6) factcomb(%);
                                          1
          (%o6)                    ---------------
                                   (n + 1) (n + 2)

     Categories: Gamma and factorial functions Simplification flags and variables

Root, Exponential and Logarithmic Functions
===========================================

 -- Option variable: %e_to_numlog
     Default value: false

     When true, r some rational number, and x some expression, %e^(r*log(x)) will be simplified into x^r .  It should be noted that the radcan command also does this transformation, and more complicated transformations of this ilk as well.  The logcontract command "contracts" expressions containing log.

     Categories: Exponential and logarithm functions Simplification flags and variables

 -- Option variable: %emode
     Default value: true

     When %emode is true, %e^(%pi %i x) is simplified as follows.

     %e^(%pi %i x) simplifies to cos (%pi x) + %i sin (%pi x) if x is a floating point number, an integer, or a multiple of 1/2, 1/3, 1/4, or 1/6, and then further simplified.

     For other numerical x, %e^(%pi %i x) simplifies to %e^(%pi %i y) where y is x - 2 k for some integer k such that abs(y) < 1.

     When %emode is false, no special simplification of %e^(%pi %i x) is carried out.

          (%i1) %emode;
          (%o1)                         true

          (%i2) %e^(%pi*%i*1);
          (%o2)                          - 1

          (%i3) %e^(%pi*%i*216/144);
          (%o3)                         - %i

          (%i4) %e^(%pi*%i*192/144);
                                    sqrt(3) %i    1
          (%o4)                  (- ----------) - -
                                        2         2

          (%i5) %e^(%pi*%i*180/144);
                                     %i          1
          (%o5)                 (- -------) - -------
                                   sqrt(2)    sqrt(2)

          (%i6) %e^(%pi*%i*120/144);
                                    %i   sqrt(3)
          (%o6)                     -- - -------
                                    2       2

          (%i7) %e^(%pi*%i*121/144);
                                      121 %i %pi
                                      ----------
                                         144
          (%o7)                     %e

     Categories: Exponential and logarithm functions Simplification flags and variables

 -- Option variable: %enumer
     Default value: false

     When %enumer is true, %e is replaced by its numeric value 2.718...  whenever numer is true.

     When %enumer is false, this substitution is carried out only if the exponent in %e^x evaluates to a number.

     See also ev and numer

          (%i1) %enumer;
          (%o1)                         false

          (%i2) numer;
          (%o2)                         false

          (%i3) 2*%e;
          (%o3)                         2 %e

          (%i4) %enumer: not %enumer;
          (%o4)                         true

          (%i5) 2*%e;
          (%o5)                         2 %e

          (%i6) numer: not numer;
          (%o6)                         true

          (%i7) 2*%e;
          (%o7)                   5.43656365691809

          (%i8) 2*%e^1;
          (%o8)                   5.43656365691809

          (%i9) 2*%e^x;
                                                   x
          (%o9)                 2 2.718281828459045

     Categories: Exponential and logarithm functions Evaluation flags

 -- Function: exp (X)

     Represents the exponential function.  Instances of exp (X) in input are simplified to %e^X; exp does not appear in simplified expressions.

     demoivre if true causes %e^(a + b %i) to simplify to %e^(a (cos(b) + %i sin(b))) if b is free of %i. See demoivre

     %emode, when true, causes %e^(%pi %i x) to be simplified. See %emode

     %enumer, when true causes %e to be replaced by 2.718... whenever numer is true.  See %enumer

          (%i1) demoivre;
          (%o1)                         false

          (%i2) %e^(a + b*%i);
                                       %i b + a
          (%o2)                      %e

          (%i3) demoivre: not demoivre;
          (%o3)                         true

          (%i4) %e^(a + b*%i);
                                a
          (%o4)               %e  (%i sin(b) + cos(b))

     Categories: Exponential and logarithm functions

 -- Function: li [S] (Z)

     Represents the polylogarithm function of order S and argument Z, defined by the infinite series

                                           inf
                                           ====   k
                                           \     z
                                  Li (z) =  >    --
                                    s      /      s
                                           ====  k
                                           k = 1

     li [1] is - log (1 - z).  li [2] and li [3] are the dilogarithm and trilogarithm functions, respectively.

     When the order is 1, the polylogarithm simplifies to - log (1 - z), which in turn simplifies to a numerical value if Z is a real or complex floating point number or the numer evaluation flag is present.

     When the order is 2 or 3, the polylogarithm simplifies to a numerical value if Z is a real floating point number or the numer evaluation flag is present.

     Examples:

          (%i1) assume (x > 0);
          (%o1)                        [x > 0]

          (%i2) integrate ((log (1 - t)) / t, t, 0, x);
          (%o2)                       - li (x)
                                          2

          (%i3) li [2] (7);
          (%o3)                        li (7)
                                         2

          (%i4) li [2] (7), numer;
          (%o4)       1.248273182099423 - 6.113257028817991 %i

          (%i5) li [3] (7);
          (%o5)                        li (7)
                                         3

          (%i6) li [3] (7), numer;
          (%o6)       5.319257992145674 - 5.94792444808033 %i

          (%i7) L : makelist (i / 4.0, i, 0, 8);
          (%o7)   [0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]

          (%i8) map (lambda ([x], li [2] (x)), L);
          (%o8) [0.0, 0.2676526390827326, 0.5822405264650125,
          0.978469392930306, 1.644934066848226,
          2.190177011441645 - 0.7010261415046585 %i,
          2.37439527027248 - 1.2738062049196 %i,
          2.448686765338205 - 1.758084848210787 %i,
          2.467401100272339 - 2.177586090303601 %i]

          (%i9) map (lambda ([x], li [3] (x)), L);
          (%o9) [0.0, 0.2584613953442624, 0.537213192678042,
          0.8444258046482203, 1.2020569, 1.642866878950322
           - 0.07821473130035025 %i, 2.060877505514697
           - 0.2582419849982037 %i, 2.433418896388322
           - 0.4919260182322965 %i, 2.762071904015935
           - 0.7546938285978846 %i]

     Categories: Exponential and logarithm functions

 -- Function: log (X)

     Represents the natural (base e) logarithm of X.

     Maxima does not have a built-in function for the base 10 logarithm or other bases. log10(x) := log(x) / log(10) is a useful definition.

     Simplification and evaluation of logarithms is governed by several global flags:

     logexpand
          causes log(a^b) to become b*log(a). If it is set to all, log(a*b) will also simplify to log(a)+log(b). If it is set to super, then log(a/b) will also simplify to log(a)-log(b) for rational numbers a/b, a#1. (log(1/b), for b integer, always simplifies.) If it is set to false, all of these simplifications will be turned off.

     logsimp
          if false then no simplification of %e to a power containing log's is done.

     lognegint
          if true implements the rule log(-n) -> log(n)+%i*%pi for n a positive integer.

     %e_to_numlog
          when true, r some rational number, and x some expression, the expression %e^(r*log(x)) will be simplified into x^r.  It should be noted that the radcan command also does this transformation, and more complicated transformations of this as well. The logcontract command "contracts" expressions containing log.

     Categories: Exponential and logarithm functions

 -- Option variable: logabs
     Default value: false

     When doing indefinite integration where logs are generated, e.g. integrate(1/x,x), the answer is given in terms of log(abs(...)) if logabs is true, but in terms of log(...) if logabs is false.  For definite integration, the logabs:true setting is used, because here "evaluation" of the indefinite integral at the endpoints is often needed.

     Categories: Exponential and logarithm functions Integral calculus Global flags

 -- Function: logarc (EXPR)

     The function logarc(EXPR) carries out the replacement of inverse circular and hyperbolic functions with equivalent logarithmic functions for an expression EXPR without setting the global variable logarc.

     Categories: Exponential and logarithm functions Simplification flags and variables Simplification functions

 -- Option variable: logarc

     When the global variable logarc is true, inverse circular and hyperbolic functions are replaced by equivalent logarithmic functions. The default value of logarc is false.

     Categories: Exponential and logarithm functions Simplification flags and variables Simplification functions

 -- Option variable: logconcoeffp
     Default value: false

     Controls which coefficients are contracted when using logcontract.  It may be set to the name of a predicate function of one argument.  E.g. if you like to generate SQRTs, you can do logconcoeffp:'logconfun$ logconfun(m):=featurep(m,integer) or ratnump(m)$ .  Then logcontract(1/2*log(x)); will give log(sqrt(x)).

     Categories: Exponential and logarithm functions Simplification flags and variables

 -- Function: logcontract (EXPR)

     Recursively scans the expression EXPR, transforming subexpressions of the form a1*log(b1) + a2*log(b2) + c into log(ratsimp(b1^a1 * b2^a2)) + c

          (%i1) 2*(a*log(x) + 2*a*log(y))$

          (%i2) logcontract(%);
                                           2  4
          (%o2)                     a log(x  y )

     The declaration declare(n,integer) causes logcontract(2*a*n*log(x)) to simplify to a*log(x^(2*n)).  The coefficients that "contract" in this manner are those such as the 2 and the n here which satisfy featurep(coeff,integer).  The user can control which coefficients are contracted by setting the option logconcoeffp to the name of a predicate function of one argument. E.g. if you like to generate SQRTs, you can do logconcoeffp:'logconfun$ logconfun(m):=featurep(m,integer) or ratnump(m)$ .  Then logcontract(1/2*log(x)); will give log(sqrt(x)).

     Categories: Exponential and logarithm functions

 -- Option variable: logexpand
     Default value: true

     If true, that is the default value, causes log(a^b) to become b*log(a).  If it is set to all, log(a*b) will also simplify to log(a)+log(b).  If it is set to super, then log(a/b) will also simplify to log(a)-log(b) for rational numbers a/b, a#1.  (log(1/b), for integer b, always simplifies.) If it is set to false, all of these simplifications will be turned off.

     When logexpand is set to all or super, the logarithm of a product expression simplifies to a summation of logarithms.

     Examples:

     When logexpand is true, log(a^b) simplifies to b*log(a).

          (%i1) log(n^2), logexpand=true;
          (%o1)                       2 log(n)

     When logexpand is all, log(a*b) simplifies to log(a)+log(b).

          (%i1) log(10*x), logexpand=all;
          (%o1)                   log(x) + log(10)

     When logexpand is super, log(a/b) simplifies to log(a)-log(b) for rational numbers a/b with a#1.

          (%i1) log(a/(n + 1)), logexpand=super;
          (%o1)                  log(a) - log(n + 1)

     When logexpand is set to all or super, the logarithm of a product expression simplifies to a summation of logarithms.

          (%i1) my_product : product (X(i), i, 1, n);
                                       n
                                     /===\
                                      ! !
          (%o1)                       ! !  X(i)
                                      ! !
                                     i = 1
          (%i2) log(my_product), logexpand=all;
                                    n
                                   ====
                                   \
          (%o2)                     >    log(X(i))
                                   /
                                   ====
                                   i = 1
          (%i3) log(my_product), logexpand=super;
                                    n
                                   ====
                                   \
          (%o3)                     >    log(X(i))
                                   /
                                   ====
                                   i = 1

     When logexpand is false, these simplifications are disabled.

          (%i1) logexpand : false $
          (%i2) log(n^2);
                                            2
          (%o2)                        log(n )
          (%i3) log(10*x);
          (%o3)                       log(10 x)
          (%i4) log(a/(n + 1));
                                           a
          (%o4)                      log(-----)
                                         n + 1
          (%i5) log ('product (X(i), i, 1, n));
                                         n
                                       /===\
                                        ! !
          (%o5)                    log( ! !  X(i))
                                        ! !
                                       i = 1

     Categories: Exponential and logarithm functions Simplification flags and variables

 -- Option variable: lognegint
     Default value: false

     If true implements the rule log(-n) -> log(n)+%i*%pi for n a positive integer.

     Categories: Exponential and logarithm functions Simplification flags and variables

 -- Option variable: logsimp
     Default value: true

     If false then no simplification of %e to a power containing log's is done.

     Categories: Exponential and logarithm functions Simplification flags and variables

 -- Function: plog (X)

     Represents the principal branch of the complex-valued natural logarithm with -%pi < carg(X) <= +%pi .

     Categories: Exponential and logarithm functions Complex variables

 -- Function: sqrt (X)

     The square root of X.  It is represented internally by X^(1/2).  See also rootscontract and radexpand

     Categories: Mathematical functions

Trigonometric Functions
=======================

Introduction to Trigonometric
-----------------------------

Maxima has many trigonometric functions defined.  Not all trigonometric identities are programmed, but it is possible for the user to add many of them using the pattern matching capabilities of the system.  The trigonometric functions defined in Maxima are: acos, acosh, acot, acoth, acsc, acsch, asec, asech, asin, asinh, atan, atanh, cos, cosh, cot, coth, csc, csch, sec, sech, sin, sinh, tan, and tanh.  There are a number of commands especially for handling trigonometric functions, see trigexpand, trigreduce, and the switch trigsign.  Two share packages extend the simplification rules built into Maxima, ntrig and atrig1.  Do describe(COMMAND) for details.

Categories: Trigonometric functions

Functions and Variables for Trigonometric
-----------------------------------------

Trigonometric and Hyperbolic Functions
......................................

 -- Function: acos (X)

     -- Arc Cosine.

     Categories: Trigonometric functions

 -- Function: acosh (X)

     -- Hyperbolic Arc Cosine.

     Categories: Hyperbolic functions

 -- Function: acot (X)

     -- Arc Cotangent.

     Categories: Trigonometric functions

 -- Function: acoth (X)

     -- Hyperbolic Arc Cotangent.

     Categories: Hyperbolic functions

 -- Function: acsc (X)

     -- Arc Cosecant.

     Categories: Trigonometric functions

 -- Function: acsch (X)

     -- Hyperbolic Arc Cosecant.

     Categories: Hyperbolic functions

 -- Function: asec (X)

     -- Arc Secant.

     Categories: Trigonometric functions

 -- Function: asech (X)

     -- Hyperbolic Arc Secant.

     Categories: Hyperbolic functions

 -- Function: asin (X)

     -- Arc Sine.

     Categories: Trigonometric functions

 -- Function: asinh (X)

     -- Hyperbolic Arc Sine.

     Categories: Hyperbolic functions

 -- Function: atan (X)

     -- Arc Tangent.

     See also atan2.

     Categories: Trigonometric functions

 -- Function: atan2 (Y, X)

     -- yields the value of atan(y/x) in the interval -%pi to %pi taking into consideration the quadrant of the point (x,y).

     See also atan.

     Categories: Trigonometric functions

 -- Function: atanh (X)

     -- Hyperbolic Arc Tangent.

     Categories: Hyperbolic functions

 -- Function: cos (X)

     -- Cosine.

     Categories: Trigonometric functions

 -- Function: cosh (X)

     -- Hyperbolic Cosine.

     Categories: Hyperbolic functions

 -- Function: cot (X)

     -- Cotangent.

     Categories: Trigonometric functions

 -- Function: coth (X)

     -- Hyperbolic Cotangent.

     Categories: Hyperbolic functions

 -- Function: csc (X)

     -- Cosecant.

     Categories: Trigonometric functions

 -- Function: csch (X)

     -- Hyperbolic Cosecant.

     Categories: Hyperbolic functions

 -- Function: sec (X)

     -- Secant.

     Categories: Trigonometric functions

 -- Function: sech (X)

     -- Hyperbolic Secant.

     Categories: Hyperbolic functions

 -- Function: sin (X)

     -- Sine.

     Categories: Trigonometric functions

 -- Function: sinh (X)

     -- Hyperbolic Sine.

     Categories: Hyperbolic functions

 -- Function: tan (X)

     -- Tangent.

     Categories: Trigonometric functions

 -- Function: tanh (X)

     -- Hyperbolic Tangent.

     Categories: Hyperbolic functions

Options Controlling Simplification
..................................

 -- Option variable: %piargs
     Default value: true

     When %piargs is true, trigonometric functions are simplified to algebraic constants when the argument is an integer multiple of %pi, %pi/2, %pi/4, or %pi/6.

     Maxima knows some identities which can be applied when %pi , etc., are multiplied by an integer variable (that is, a symbol declared to be integer).

     Examples:

          (%i1) %piargs : 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$

          (%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

     Some identities are applied when %pi and %pi/2 are multiplied by an integer variable.

          (%i1) declare (n, integer, m, even)$

          (%i2) [sin (%pi * n), cos (%pi * m), sin (%pi/2 * m),
                 cos (%pi/2 * m)];
                                                m/2
          (%o2)                  [0, 1, 0, (- 1)   ]

     Categories: Trigonometric functions Simplification flags and variables

 -- Option variable: %iargs
     Default value: true

     When %iargs is true, trigonometric functions are simplified to hyperbolic functions when the argument is apparently a multiple of the imaginary unit %i.

     Even when the argument is demonstrably real, the simplification is applied; Maxima considers only whether the argument is a literal multiple of %i.

     Examples:

          (%i1) %iargs : false$

          (%i2) [sin (%i * x), cos (%i * x), tan (%i * x)];
          (%o2)           [sin(%i x), cos(%i x), tan(%i x)]

          (%i3) %iargs : true$

          (%i4) [sin (%i * x), cos (%i * x), tan (%i * x)];
          (%o4)           [%i sinh(x), cosh(x), %i tanh(x)]

     Even when the argument is demonstrably real, the simplification is applied.

          (%i1) declare (x, imaginary)$

          (%i2) [featurep (x, imaginary), featurep (x, real)];
          (%o2)                     [true, false]

          (%i3) sin (%i * x);
          (%o3)                      %i sinh(x)

     Categories: Trigonometric functions Hyperbolic functions Simplification flags and variables

 -- Option variable: halfangles
     Default value: false

     When halfangles is true, trigonometric functions of arguments EXPR/2 are simplified to functions of EXPR.

     For a real argument x in the interval 0 <= x < 2*%pi, sin(x/2) simplifies to a simple formula:

                                   sqrt(1 - cos(x))
                                   ----------------
                                       sqrt(2)

     A complicated factor is needed to make this formula correct for all complex arguments z = x+iy:
                   x                       x                x
           floor(-----)            floor(-----) - ceiling(-----)
                 2 %pi                   2 %pi            2 %pi
      (- 1)             (1 - ((- 1)                              + 1)
                                                               unit_step(- y))

     Maxima knows this factor and similar factors for the functions sin, cos, sinh, and cosh.  For special values of the argument z these factors simplify accordingly.

     Examples:

          (%i1) halfangles : false$

          (%i2) sin (x / 2);
                                           x
          (%o2)                        sin(-)
                                           2

          (%i3) halfangles : true$

          (%i4) sin (x / 2);
                                      x
                              floor(-----)
                                    2 %pi
                         (- 1)             sqrt(1 - cos(x))
          (%o4)          ----------------------------------
                                      sqrt(2)

          (%i5) assume(x>0, x<2*%pi)$

          (%i6) sin(x / 2);
                                  sqrt(1 - cos(x))
          (%o6)                   ----------------
                                      sqrt(2)

     Categories: Trigonometric functions Simplification flags and variables

 -- Option variable: trigsign
     Default value: true

     When trigsign is true, it permits simplification of negative arguments to trigonometric functions.  E.g., sin(-x) will become -sin(x) only if trigsign is true.

     Categories: Trigonometric functions Simplification flags and variables

Explicit Simplifications Using Identities
.........................................

 -- Function: trigexpand (EXPR)

     Expands trigonometric and hyperbolic functions of sums of angles and of multiple angles occurring in EXPR.  For best results, EXPR should be expanded.  To enhance user control of simplification, this function expands only one level at a time, expanding sums of angles or multiple angles.  To obtain full expansion into sines and cosines immediately, set the switch trigexpand: true.

     trigexpand is governed by the following global flags:

     trigexpand
          If true causes expansion of all expressions containing sin's and cos's occurring subsequently.

     halfangles
          If true causes half-angles to be simplified away.

     trigexpandplus
          Controls the "sum" rule for trigexpand, expansion of sums (e.g. sin(x + y)) will take place only if trigexpandplus is true.

     trigexpandtimes
          Controls the "product" rule for trigexpand, expansion of products (e.g. sin(2 x)) will take place only if trigexpandtimes is true.

     Examples:

          (%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)

     Categories: Trigonometric functions Simplification functions

 -- Option variable: trigexpandplus
     Default value: true

     trigexpandplus controls the "sum" rule for trigexpand.  Thus, when the trigexpand command is used or the trigexpand switch set to true, expansion of sums (e.g. sin(x+y)) will take place only if trigexpandplus is true.

     Categories: Trigonometric functions Simplification flags and variables

 -- Option variable: trigexpandtimes
     Default value: true

     trigexpandtimes controls the "product" rule for trigexpand. Thus, when the trigexpand command is used or the trigexpand switch set to true, expansion of products (e.g. sin(2*x)) will take place only if trigexpandtimes is true.

     Categories: Trigonometric functions Simplification flags and variables

 -- Option variable: triginverses
     Default value: true

     triginverses controls the simplification of the composition of trigonometric and hyperbolic functions with their inverse functions.

     If all, both e.g. atan(tan(X)) and tan(atan(X)) simplify to X.

     If true, the ARCFUN(FUN(X)) simplification is turned off.

     If false, both the ARCFUN(FUN(X)) and FUN(ARCFUN(X)) simplifications are turned off.

     Categories: Trigonometric functions Simplification flags and variables

 -- Function: trigreduce
     trigreduce (EXPR, X)
     trigreduce (EXPR)

     Combines products and powers of trigonometric and hyperbolic sin's and cos's of X into those of multiples of X. It also tries to eliminate these functions when they occur in denominators.  If X is omitted then all variables in EXPR are used.

     See also 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

     Categories: Trigonometric functions Simplification functions

 -- Function: trigsimp (EXPR)

     Employs the identities sin(x)^2+cos(x)^2 = 1 and cosh(x)^2-sinh(x)^2 = 1 to simplify expressions containing tan, sec, etc., to sin, cos, sinh, cosh.

     trigreduce, ratsimp, and radcan may be able to further simplify the result.

     demo ("trgsmp.dem") displays some examples of trigsimp.

     Categories: Trigonometric functions Simplification functions

 -- Function: trigrat (EXPR)

     Gives a canonical simplified quasilinear form of a trigonometrical expression; EXPR is a rational fraction of several sin, cos or tan, the arguments of them are linear forms in some variables (or kernels) and %pi/N (N integer) with integer coefficients. The result is a simplified fraction with numerator and denominator linear in sin and cos.  Thus trigrat linearize always when it is possible.

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

     The following example is taken from Davenport, Siret, and Tournier, Calcul Formel, Masson (or in English, Addison-Wesley), section 1.5.5, Morley theorem.

          (%i1) c : %pi/3 - a - b$

          (%i2) bc : sin(a)*sin(3*c)/sin(a+b);
                                                     %pi
                           sin(a) sin(3 ((- b) - a + ---))
                                                      3
          (%o2)            -------------------------------
                                     sin(b + a)

          (%i3) ba : bc, c=a, a=c;
                                                   %pi
                              sin(3 a) sin(b + a - ---)
                                                    3
          (%o3)               -------------------------
                                            %pi
                                    sin(a - ---)
                                             3

          (%i4) ac2 : ba^2 + bc^2 - 2*bc*ba*cos(b);
                   2         2         %pi
                sin (3 a) sin (b + a - ---)
                                        3
          (%o4) ---------------------------
                          2     %pi
                       sin (a - ---)
                                 3
                                                   %pi
           - (2 sin(a) sin(3 a) sin(3 ((- b) - a + ---)) cos(b)
                                                    3
                       %pi            %pi
           sin(b + a - ---))/(sin(a - ---) sin(b + a))
                        3              3
                2       2                %pi
             sin (a) sin (3 ((- b) - a + ---))
                                          3
           + ---------------------------------
                           2
                        sin (b + a)

          (%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

     Categories: Trigonometric functions Simplification functions

Additional Functions
....................

 -- Package: atrig1

     The atrig1 package contains several additional simplification rules for inverse trigonometric functions.  Together with rules already known to Maxima, the following angles are fully implemented: 0, %pi/6, %pi/4, %pi/3, and %pi/2.

     Corresponding angles in the other three quadrants are also available. Do load("atrig1"); to use them.

     Categories: Trigonometric functions Package atrig1

 -- Package: ntrig

     The ntrig package contains a set of simplification rules that are used to simplify trigonometric function whose arguments are of the form F(N %pi/10) where F is any of the functions sin, cos, tan, csc, sec and cot.

     Categories: Trigonometric functions Package ntrig

Random Numbers
==============

 -- Function: make_random_state
     make_random_state (N)
     make_random_state (S)
     make_random_state (true)
     make_random_state (false)

     A random state object represents the state of the random number generator. The state comprises 627 32-bit words.

     make_random_state (N) returns a new random state object created from an integer seed value equal to N modulo 2^32. N may be negative.

     make_random_state (S) returns a copy of the random state S.

     make_random_state (true) returns a new random state object, using the current computer clock time as the seed.

     make_random_state (false) returns a copy of the current state of the random number generator.

     Categories: Random numbers

 -- Function: set_random_state (S)

     Copies S to the random number generator state.

     set_random_state always returns done.

     Categories: Random numbers

 -- Function: random (X)

     Returns a pseudorandom number.  If X is an integer, random (X) returns an integer from 0 through X - 1 inclusive.  If X is a floating point number, random (X) returns a nonnegative floating point number less than X.  random complains with an error if X is neither an integer nor a float, or if X is not positive.

     The functions make_random_state and set_random_state maintain the state of the random number generator.

     The Maxima random number generator is an implementation of the Mersenne twister MT 19937.

     Examples:

          (%i1) s1: make_random_state (654321)$

          (%i2) set_random_state (s1);
          (%o2)                         done

          (%i3) random (1000);
          (%o3)                          768

          (%i4) random (9573684);
          (%o4)                        7657880

          (%i5) random (2^75);
          (%o5)                11804491615036831636390

          (%i6) s2: make_random_state (false)$

          (%i7) random (1.0);
          (%o7)                  0.2310127244107132

          (%i8) random (10.0);
          (%o8)                   4.394553645870825

          (%i9) random (100.0);
          (%o9)                   32.28666704056853

          (%i10) set_random_state (s2);
          (%o10)                        done

          (%i11) random (1.0);
          (%o11)                 0.2310127244107132

          (%i12) random (10.0);
          (%o12)                  4.394553645870825

          (%i13) random (100.0);
          (%o13)                  32.28666704056853

     Categories: Random numbers Numerical methods