[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 10. Mathematical Functions

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 10.1 Functions for Numbers

Function: abs (expr)

  Returns the absolute value expr. If expr is complex, returns the complex modulus of expr.

  `abs` distributes over a list, a matrix, or an equation. See `distribute_over`.

  ·

  @ref{Category: 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(n, 6)]
      (%i5) assume (x > 0, x < 1)$
      (%i6) ceiling (x);
      (%o6)                           1
      (%i7) tex (ceiling (a));
      $$\left \lceil a \right \rceil$$
      (%o7)                         false

  The function `ceiling` does not automatically map over lists or matrices. 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

  ·

  @ref{Category: 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.

  ·

  @ref{Category: 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(n, 6)]
      (%i5) assume (x > 0, x < 1)$
      (%i6) floor (x);
      (%o6)                           0
      (%i7) tex (floor (a));
      $$\left \lfloor a \right \rfloor$$
      (%o7)                         false

  The function `floor` does not automatically map over lists or matrices. 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

  ·

  @ref{Category: Mathematical functions}

Function: fix (x)

  A synonym for `entier (x)`.

  ·

  @ref{Category: 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`.

  ·

  @ref{Category: Mathematical functions} · @ref{Category: Lists} · @ref{Category: 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`.

  ·

  @ref{Category: Mathematical functions} · @ref{Category: Lists} · @ref{Category: Sets}

Function: max (x_1, …, x_n)

  Return a simplified value for the maximum of the expressions x_1 through x_n. When `get (trylevel, maxmin)`, is 2 or greater, `max` uses the simplification `max (e, -e) --> |e|`. When `get (trylevel, maxmin)` is 3 or greater, max tries to eliminate expressions that are between two other arguments; for example, `max (x, 2*x, 3*x) --> max (x, 3*x)`. To set the value of `trylevel` to 2, use `put (trylevel, 2, maxmin)`.

  See also `min` and `lmax`.

  ·

  @ref{Category: Mathematical functions}

Function: min (x_1, …, x_n)

  Return a simplified value for the minimum of the expressions `x_1` through `x_n`. When `get (trylevel, maxmin)`, is 2 or greater, `min` uses the simplification `min (e, -e) --> -|e|`. When `get (trylevel, maxmin)` is 3 or greater, `min` tries to eliminate expressions that are between two other arguments; for example, `min (x, 2*x, 3*x) --> min (x, 3*x)`. To set the value of `trylevel` to 2, use `put (trylevel, 2, maxmin)`.

  See also `max` and `lmin`.

  ·

  @ref{Category: 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`.

  ·

  @ref{Category: 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 `abs(x)/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 `distribute_over`.

  ·

  @ref{Category: Mathematical functions}

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 10.2 Functions for Complex Numbers

Function: cabs (expr)

  Returns the complex absolute value (the complex modulus) of expr.

  ·

  @ref{Category: 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));
      (%o3)                           1
      (%i4) carg (exp (%pi * %i));
      (%o4)                          %pi
      (%i5) carg (exp (3/2 * %pi * %i));
                                      %pi
      (%o5)                         - ---
                                       2
      (%i6) carg (17 * exp (2 * %i));
      (%o6)                           2

  ·

  @ref{Category: 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)             conjugate(yy) + conjugate(xx)

  ·

  @ref{Category: 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`.

  ·

  @ref{Category: Complex variables}

Function: polarform (expr)

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

  ·

  @ref{Category: Complex variables} · @ref{Category: 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.

  ·

  @ref{Category: Complex variables}

Function: rectform (expr)

  Returns an expression `a + b %i` equivalent to expr, such that a and b are purely real.

  ·

  @ref{Category: Complex variables}

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 10.3 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)`.

  ·

  @ref{Category: Gamma and factorial functions} · @ref{Category: 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)

  ·

  @ref{Category: 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`.

  ·

  @ref{Category: 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)    [81.44668037931197,
                .3430658398165454 %i + .6529654964201665]
      (%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) [.3430658398165454 %i + .6529654964201665,
             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.44668037931199, 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

  ·

  @ref{Category: Gamma and factorial functions} · @ref{Category: Operators}

Option variable: factlim

  Default value: -1

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

  ·

  @ref{Category: Gamma and factorial functions}

Option variable: factorial_expand

  Default value: false

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

  ·

  @ref{Category: 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, for integral x, `genfact (x, x, 1) = x!` and `genfact (x, x/2, 2) = x!!`.

  ·

  @ref{Category: 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)

  ·

  @ref{Category: Number theory}

Option variable: sumsplitfact

  Default value: `true`

  When `sumsplitfact` is `false`, `minfactorial` is applied after a `factcomb`.

  ·

  @ref{Category: Gamma and factorial functions} · @ref{Category: Simplification flags and variables}

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 10.4 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`.

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: 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.

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: 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`.

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: 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`.

  ·

  @ref{Category: 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.24827317833392 - 6.113257021832577 %i
      (%i5) li [3] (7);
      (%o5)                        li (7)
                                     3
      (%i6) li [2] (7), numer;
      (%o6)        1.24827317833392 - 6.113257021832577 %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, .2676526384986274, .5822405249432515,
      .9784693966661848, 1.64493407, 2.190177004178597
       - .7010261407036192 %i, 2.374395264042415
       - 1.273806203464065 %i, 2.448686757245154
       - 1.758084846201883 %i, 2.467401098097648
       - 2.177586087815347 %i]
      (%i9) map (lambda ([x], li [3] (x)), L);
      (%o9) [0, .2584613953442624, 0.537213192678042,
      .8444258046482203, 1.2020569, 1.642866878950322
       - .07821473130035025 %i, 2.060877505514697
       - .2582419849982037 %i, 2.433418896388322
       - .4919260182322965 %i, 2.762071904015935
       - .7546938285978846 %i]

  ·

  @ref{Category: 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.

  ``lognumer``

    if `true` then negative floating point arguments to `log` will always be converted to their absolute value before the `log` is taken. If `numer` is also `true`, then negative integer arguments to `log` will also be converted to their absolute value.

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

  ·

  @ref{Category: 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.

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: Integral calculus} · @ref{Category: Global flags}

Option variable: logarc
Function: logarc (expr)

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

  The function `logarc(expr)` carries out that replacement for an expression expr without setting the global variable `logarc`.

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: Simplification flags and variables} · @ref{Category: 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))`.

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: 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))`.

  ·

  @ref{Category: Exponential and logarithm functions}

Option variable: logexpand

  Default value: `false`

  If `true` 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`, that is the default value, all of these simplifications will be turned off.

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: 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.

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: Simplification flags and variables}

Option variable: lognumer

  Default value: `false`

  If `true` then negative floating point arguments to `log` will always be converted to their absolute value before the `log` is taken. If `numer` is also `true`, then negative integer arguments to `log` will also be converted to their absolute value.

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: Simplification flags and variables} · @ref{Category: Numerical evaluation}

Option variable: logsimp

  Default value: `true`

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

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: Simplification flags and variables}

Function: plog (x)

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

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: Complex variables}

Function: sqrt (x)

  The square root of x. It is represented internally by `x^(1/2)`. See also `rootscontract`.

  `radexpand` if `true` will cause nth roots of factors of a product which are powers of n to be pulled outside of the radical, e.g. `sqrt(16*x^2)` will become `4*x` only if `radexpand` is `true`.

  ·

  @ref{Category: Mathematical functions}

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 10.5 Trigonometric Functions

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 10.5.1 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.

·

@ref{Category: Trigonometric functions}

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 10.5.2 Functions and Variables for Trigonometric

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/3, %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)   ]

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: 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)

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: Hyperbolic functions} · @ref{Category: Simplification flags and variables}

Function: acos (x)

  - Arc Cosine.

  ·

  @ref{Category: Trigonometric functions}

Function: acosh (x)

  - Hyperbolic Arc Cosine.

  ·

  @ref{Category: Hyperbolic functions}

Function: acot (x)

  - Arc Cotangent.

  ·

  @ref{Category: Trigonometric functions}

Function: acoth (x)

  - Hyperbolic Arc Cotangent.

  ·

  @ref{Category: Hyperbolic functions}

Function: acsc (x)

  - Arc Cosecant.

  ·

  @ref{Category: Trigonometric functions}

Function: acsch (x)

  - Hyperbolic Arc Cosecant.

  ·

  @ref{Category: Hyperbolic functions}

Function: asec (x)

  - Arc Secant.

  ·

  @ref{Category: Trigonometric functions}

Function: asech (x)

  - Hyperbolic Arc Secant.

  ·

  @ref{Category: Hyperbolic functions}

Function: asin (x)

  - Arc Sine.

  ·

  @ref{Category: Trigonometric functions}

Function: asinh (x)

  - Hyperbolic Arc Sine.

  ·

  @ref{Category: Hyperbolic functions}

Function: atan (x)

  - Arc Tangent.

  ·

  @ref{Category: Trigonometric functions}

Function: atan2 (y, x)

  - yields the value of `atan(y/x)` in the interval `-%pi` to `%pi`.

  ·

  @ref{Category: Trigonometric functions}

Function: atanh (x)

  - Hyperbolic Arc Tangent.

  ·

  @ref{Category: Hyperbolic 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.

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: Package atrig1}

Function: cos (x)

  - Cosine.

  ·

  @ref{Category: Trigonometric functions}

Function: cosh (x)

  - Hyperbolic Cosine.

  ·

  @ref{Category: Hyperbolic functions}

Function: cot (x)

  - Cotangent.

  ·

  @ref{Category: Trigonometric functions}

Function: coth (x)

  - Hyperbolic Cotangent.

  ·

  @ref{Category: Hyperbolic functions}

Function: csc (x)

  - Cosecant.

  ·

  @ref{Category: Trigonometric functions}

Function: csch (x)

  - Hyperbolic Cosecant.

  ·

  @ref{Category: Hyperbolic functions}

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` the sine of the half-angle 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:

                 realpart(z)
           floor(-----------)
                    2 %pi
      (- 1)                   (1 - unit_step(- imagpart(z))

                                  realpart(z)            realpart(z)
                            floor(-----------) - ceiling(-----------)
                                     2 %pi                  2 %pi
                      ((- 1)                                          + 1))

  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;
      (%o1)                                false
      (%i2) sin(x/2);
                                              x
      (%o2)                               sin(-)
                                              2
      (%i3) halfangles:true;
      (%o3)                                true
      (%i4) sin(x/2);
                                                          x
                                                  floor(-----)
                                                        2 %pi
                            sqrt(1 - cos(x)) (- 1)
      (%o4)                 ----------------------------------
                                         sqrt(2)
      (%i5) assume(x>0, x<2*%pi)$
      (%i6) sin(x/2);
                                     sqrt(1 - cos(x))
      (%o6)                          ----------------
                                         sqrt(2)

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: Simplification flags and variables}

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

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: Package ntrig}

Function: sec (x)

  - Secant.

  ·

  @ref{Category: Trigonometric functions}

Function: sech (x)

  - Hyperbolic Secant.

  ·

  @ref{Category: Hyperbolic functions}

Function: sin (x)

  - Sine.

  ·

  @ref{Category: Trigonometric functions}

Function: sinh (x)

  - Hyperbolic Sine.

  ·

  @ref{Category: Hyperbolic functions}

Function: tan (x)

  - Tangent.

  ·

  @ref{Category: Trigonometric functions}

Function: tanh (x)

  - Hyperbolic Tangent.

  ·

  @ref{Category: Hyperbolic functions}

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)

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: 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`.

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: 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`.

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: 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.

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: Simplification flags and variables}

Function: trigreduce (expr, x)
Function: 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

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: Simplification functions}

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

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: Simplification flags and variables}

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

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: Simplification functions}

Function: trigrat (expr)

  Gives a canonical simplifyed 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

  ·

  @ref{Category: Trigonometric functions} · @ref{Category: Simplification functions}

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 10.6 Random Numbers

Function: make_random_state (n)
Function: make_random_state (s)
Function: make_random_state (true)
Function: 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.

  ·

  @ref{Category: Random numbers}

Function: set_random_state (s)

  Copies s to the random number generator state.

  `set_random_state` always returns `done`.

  ·

  @ref{Category: 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)                   .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)                  .2310127244107132
      (%i12) random (10.0);
      (%o12)                  4.394553645870825
      (%i13) random (100.0);
      (%o13)                  32.28666704056853

  ·

  @ref{Category: Random numbers} · @ref{Category: Numerical methods}

0

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by Charlie & on December, 12 2011 using texi2html 1.76.