Maxima 5.41.0 Manual: 9. Simplification

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

# 9. Simplification

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

## 9.1 Introduction to Simplification

Maxima performs a cycle of actions in response to each new user-typed command. This consists of four steps: reading or "parsing" the input, evaluation, simplification and output. Parsing converts a syntactically valid sequence of typed characters into a data structure to be used for the rest of the operations. Evaluation includes replacing names with their assigned values. Simplification means rewriting an expression to be easier for the user or other programs to understand. Output includes displaying computational results in a variety of different formats and notations.

Evaluation and simplification sometimes appear to have similar functionality as they both have the goal of removing "complexity" and system designers have sometimes divided a task so that it is performed partly in each. For example, `integrate(x,x)` evaluates the answer as `x*x/2`, which is then simplified to `x^2/2`.

Evaluation is always present: it is the consequence of having a programming system with functions, subroutines, variables, values, loops, assignments and so on. In the evaluation step, built-in or user-defined function names are replaced by their definitions, variables are replaced by their values. This is largely the same as activities of a conventional programming language, but extended to work with symbolic mathematical data. Because of the generality of the mathematics at hand, there are different possible models of evaluation and so the systems has optional "flags" that can steer the process of evaluation. See section Functions and Variables for Evaluation.

By contrast, the intent of simplification is to maintain the value of an expression while re-formulating its representation to be smaller, simpler to understand, or to conform to particular specifications (like factored, expanded). For example, `sin(0)` to `0` or `x+x to 2*x`. There are several powerful tools to alter the results of simplification, since it is largely in this part of the system that a user can incorporate knowledge of newly introduced functions or symbolic notation into Maxima.

Simplification is generally done at four different levels:

- The internal, built-in automated simplifier,
- Built-in simplification routines that can be explicitly called by the user at selected places in a program or command sequence,
- User-written simplification routines, linked to the simplifier by using "tellsimp" or "tellsimpafter" and called automatically,
- User-written routines that can be explicitly called by the user at selected places in a program or command sequence.

The internal simplifier belongs to the heart of Maxima. It is a large and complicated collection of programs, and it has been refined over many years and by thousands of users. Nevertheless, especially if you are trying out novel ideas or unconventional notation, you may find it helpful to make small (or large) changes to the program yourself. For details see for example the paper at the end of https://people.eecs.berkeley.edu/~fateman/papers/intro5.txt.

Maxima internally represents expressions as "trees" with operators or "roots" like `+`, `*` , `=` and operands ("leaves") which are variables like x, y, z, functions or sub-trees, like `x*y`. Each operator has a simplification program associated with it. `+` (which also covers binary `-` since `a-b = a+(-1)*b)` and `*` (which also covers `/` since `a/b = a*b^(-1)`) have rather elaborate simplification programs. These simplification programs (simplus, simptimes, simpexpt, etc.) are called whenever the simplifier encounters the respective arithmetic operators in an expression tree to be analyzed.

The structure of the simplifier dates back to 1965, and many hands have worked on it through the years. The structure turns out to be, in modern jargon, data- directed, or object-oriented. The program dispatches to the appropriate routine depending on the root of some sub-tree of the expression, recursively. This general notion means you can make modifications to the simplification process by very local changes to the program. In many cases it is conceptually straightforward to add an operator and add its simplification routine without disturbing existing code.

We note that in addition to this general simplifier operating on algebraic expression trees, there are several other representations of expressions in Maxima which have separate methods and simplifiers. For example, the `rat()` function converts polynomials to vectors of coefficients to assist in rapid manipulation of such forms. Other representations include Taylor series and the (rarely used) Poisson series.

All operators introduced by the user initially have no simplification programs associated with them. Maxima does not know anything about function "f" and so typing `f(a,b)` will result in simplifying a,b, but not `f`. Even some built-in operators have no simplifications. For example, `=` does not "simplify" - it is a place-holder with no simplification semantics other than to simplify its two arguments, in this case referred to as the left and right sides. Other parts of Maxima such as the solve program take special note of equations, that is, trees with `=` as the root. (Note - in Maxima, the assignment operation is `:` . That is, `q: 4` sets the value of the symbol q to `4`. Function definition is done with `:=`. )

The general simplifier returns results with an internal flag indicating the expression and each sub-expression has been simplified. This does not guarantee that it is unique over all possible equivalent expressions. That's too hard (theoretically, not possible given the generality of what can be expressed in Maxima). However, some aspects of the expression, such as the ordering of terms in a sum or product, are made uniform. This is important for the other programs to work properly.

You can set a number of option variables which direct Maxima's processing to favor particular kinds of patterns as being goals. You can even use the most extreme option which is to turn the simplifier off by simp:false. We do not recommend this since many internal routines expect their arguments to be simplified. (About the only time it seems plausible to turn off the simplifier is in the rare case that you want to over-ride a built-in simplification. In that case you might temporarily disable the simplifier, put in the new transformation via `tellsimp`, and then re-enable the simplifier by `simp:true`.)

It is more plausible for you to associate user-defined symbolic function names or operators with properties (`additive`, `lassociative`, `oddfun`, `antisymmetric`, `linear`, `outative`, `commutative`, `multiplicative`, `rassociative`, `evenfun`, `nary` and `symmetric`). These options steer the simplifier processing in systematic directions.

For example, `declare(f,oddfun)` specifies that `f` is an odd function. Maxima will simplify `f(-x)` to `-f(x)`. In the case of an even function, that is `declare(g,evenfun)`, Maxima will simplify `g(-x)` to `g(x)`. You can also associate a programming function with a name such as `h(x):=x^2+1`. In that case the evaluator will immediately replace `h(3)` by `10`, and `h(a+1)` by `(a+1)^2+1`, so any properties of `h` will be ignored.

In addition to these directly related properties set up by the user, facts and properties from the actual context may have an impact on the simplifier's behavior, too. See section Introduction to Maximas Database.

Example: `sin(n*%pi)` is simplified to zero, if n is an integer.

    (%i1) sin(n*%pi);
    (%o1)                      sin(%pi n)
    (%i2) declare(n, integer);
    (%o2)                         done
    (%i3) sin(n*%pi);
    (%o3)                           0

If automated simplification is not sufficient, you can consider a variety of built-in, but explicitly called simplfication functions (`ratsimp`, `expand`, `factor`, `radcan` and others). There are also flags that will push simplification into one or another direction. Given `demoivre:true` the simplifier rewrites complex exponentials as trigonometric forms. Given `exponentialize:true` the simplifier tries to do the reverse: rewrite trigonometric forms as complex exponentials.

As everywhere in Maxima, by writing your own functions (be it in the Maxima user language or in the implementation language Lisp) and explicitly calling them at selected places in the program, you can respond to your individual simplification needs. Lisp gives you a handle on all the internal mechanisms, but you rarely need this full generality. "Tellsimp" is designed to generate much of the Lisp internal interface into the simplifier automatically. See See section Rules and Patterns.

Over the years (Maxima/Macsyma's origins date back to about 1966!) users have contributed numerous application packages and tools to extend or alter its functional behavior. Various non-standard and "share" packages exist to modify or extend simplification as well. You are invited to look into this more experimental material where work is still in progress. See section simplification

The following appended material is optional on a first reading, and reading it is not necessary for productive use of Maxima. It is for the curious user who wants to understand what is going on, or the ambitious programmer who might wish to change the (open-source) code. Experimentation with redefining Maxima Lisp code is easily possible: to change the definition of a Lisp program (say the one that simplifies `cos()`, named `simp%cos`), you simply load into Maxima a text file that will overwrite the `simp%cos` function from the maxima package.

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

## 9.2 Functions and Variables for Simplification

Property: additive

  If `declare(f,additive)` has been executed, then:

  (1) If `f` is univariate, whenever the simplifier encounters `f` applied to a sum, `f` will be distributed over that sum. I.e. `f(y+x)` will simplify to `f(y)+f(x)`.

  (2) If `f` is a function of 2 or more arguments, additivity is defined as additivity in the first argument to `f`, as in the case of `sum` or `integrate`, i.e. `f(h(x)+g(x),x)` will simplify to `f(h(x),x)+f(g(x),x)`. This simplification does not occur when `f` is applied to expressions of the form `sum(x[i],i,lower-limit,upper-limit)`.

  Example:

      (%i1) F3 (a + b + c);
      (%o1)                     F3(c + b + a)
      (%i2) declare (F3, additive);
      (%o2)                         done
      (%i3) F3 (a + b + c);
      (%o3)                 F3(c) + F3(b) + F3(a)

  ·

  @ref{Category: Operators} · @ref{Category: Declarations and inferences}

Property: antisymmetric

  If `declare(h,antisymmetric)` is done, this tells the simplifier that `h` is antisymmetric. E.g. `h(x,z,y)` will simplify to `- h(x, y, z)`. That is, it will give (-1)^n times the result given by `symmetric` or `commutative`, where n is the number of interchanges of two arguments necessary to convert it to that form.

  Examples:

      (%i1) S (b, a);
      (%o1)                        S(b, a)
      (%i2) declare (S, symmetric);
      (%o2)                         done
      (%i3) S (b, a);
      (%o3)                        S(a, b)
      (%i4) S (a, c, e, d, b);
      (%o4)                   S(a, b, c, d, e)
      (%i5) T (b, a);
      (%o5)                        T(b, a)
      (%i6) declare (T, antisymmetric);
      (%o6)                         done
      (%i7) T (b, a);
      (%o7)                       - T(a, b)
      (%i8) T (a, c, e, d, b);
      (%o8)                   T(a, b, c, d, e)

  ·

  @ref{Category: Operators} · @ref{Category: Declarations and inferences}

Function: combine (expr)

  Simplifies the sum expr by combining terms with the same denominator into a single term.

  Example:

      (%i1) 1*f/2*b + 2*c/3*a + 3*f/4*b +c/5*b*a;
                            5 b f   a b c   2 a c
      (%o1)                 ----- + ----- + -----
                              4       5       3
      (%i2) combine (%);
                        75 b f + 4 (3 a b c + 10 a c)
      (%o2)             -----------------------------
                                     60

  ·

  @ref{Category: Expressions}

Property: commutative

  If `declare(h, commutative)` is done, this tells the simplifier that `h` is a commutative function. E.g. `h(x, z, y)` will simplify to `h(x, y, z)`. This is the same as `symmetric`.

  Exemplo:

      (%i1) S (b, a);
      (%o1)                        S(b, a)
      (%i2) S (a, b) + S (b, a);
      (%o2)                   S(b, a) + S(a, b)
      (%i3) declare (S, commutative);
      (%o3)                         done
      (%i4) S (b, a);
      (%o4)                        S(a, b)
      (%i5) S (a, b) + S (b, a);
      (%o5)                       2 S(a, b)
      (%i6) S (a, c, e, d, b);
      (%o6)                   S(a, b, c, d, e)

  ·

  @ref{Category: Operators} · @ref{Category: Declarations and inferences}

Function: demoivre (expr)
Option variable: demoivre

  The function `demoivre (expr)` converts one expression without setting the global variable `demoivre`.

  When the variable `demoivre` is `true`, complex exponentials are converted into equivalent expressions in terms of circular functions: `exp (a + b*%i)` simplifies to `%e^a * (cos(b) + %i*sin(b))` if `b` is free of `%i`. `a` and `b` are not expanded.

  The default value of `demoivre` is `false`.

  `exponentialize` converts circular and hyperbolic functions to exponential form. `demoivre` and `exponentialize` cannot both be true at the same time.

  ·

  @ref{Category: Complex variables} · @ref{Category: Trigonometric functions} · @ref{Category: Hyperbolic functions}

Function: distrib (expr)

  Distributes sums over products. It differs from `expand` in that it works at only the top level of an expression, i.e., it doesn't recurse and it is faster than `expand`. It differs from `multthru` in that it expands all sums at that level.

  Examples:

      (%i1) distrib ((a+b) * (c+d));
      (%o1)                 b d + a d + b c + a c
      (%i2) multthru ((a+b) * (c+d));
      (%o2)                 (b + a) d + (b + a) c
      (%i3) distrib (1/((a+b) * (c+d)));
                                      1
      (%o3)                    ---------------
                               (b + a) (d + c)
      (%i4) expand (1/((a+b) * (c+d)), 1, 0);
                                      1
      (%o4)                 ---------------------
                            b d + a d + b c + a c

  ·

  @ref{Category: Expressions}

Option variable: distribute_over

  Default value: `true`

  `distribute_over` controls the mapping of functions over bags like lists, matrices, and equations. At this time not all Maxima functions have this property. It is possible to look up this property with the command `properties`.

  The mapping of functions is switched off, when setting `distribute_over` to the value `false`.

  Examples:

  The `sin` function maps over a list:

      (%i1) sin([x,1,1.0]);
      (%o1)         [sin(x), sin(1), 0.8414709848078965]

  `mod` is a function with two arguments which maps over lists. Mapping over nested lists is possible too:

      (%i1) mod([x,11,2*a],10);
      (%o1)             [mod(x, 10), 1, 2 mod(a, 5)]
      (%i2) mod([[x,y,z],11,2*a],10);
      (%o2) [[mod(x, 10), mod(y, 10), mod(z, 10)], 1, 2 mod(a, 5)]

  Mapping of the `floor` function over a matrix and an equation:

      (%i1) floor(matrix([a,b],[c,d]));
                           [ floor(a)  floor(b) ]
      (%o1)                [                    ]
                           [ floor(c)  floor(d) ]
      (%i2) floor(a=b);
      (%o2)                  floor(a) = floor(b)

  Functions with more than one argument map over any of the arguments or all arguments:

      (%i1) expintegral_e([1,2],[x,y]);
      (%o1) [[expintegral_e(1, x), expintegral_e(1, y)],
                            [expintegral_e(2, x), expintegral_e(2, y)]]

  Check if a function has the property distribute_over:

      (%i1) properties(abs);
      (%o1) [integral, rule, distributes over bags, noun, gradef,
                                                       system function]

  The mapping of functions is switched off, when setting `distribute_over` to the value `false`.

      (%i1) distribute_over;
      (%o1)                         true
      (%i2) sin([x,1,1.0]);
      (%o2)         [sin(x), sin(1), 0.8414709848078965]
      (%i3) distribute_over : not distribute_over;
      (%o3)                         false
      (%i4) sin([x,1,1.0]);
      (%o4)                   sin([x, 1, 1.0])

  ·

  @ref{Category: Simplification flags and variables}

Option variable: domain

  Default value: `real`

  When `domain` is set to `complex`, `sqrt (x^2)` will remain `sqrt (x^2)` instead of returning `abs(x)`.

  ·

  @ref{Category: Simplification flags and variables}

Property: evenfun
Property: oddfun

  `declare(f, evenfun)` or `declare(f, oddfun)` tells Maxima to recognize the function `f` as an even or odd function.

  Examples:

      (%i1) o (- x) + o (x);
      (%o1)                     o(x) + o(- x)
      (%i2) declare (o, oddfun);
      (%o2)                         done
      (%i3) o (- x) + o (x);
      (%o3)                           0
      (%i4) e (- x) - e (x);
      (%o4)                     e(- x) - e(x)
      (%i5) declare (e, evenfun);
      (%o5)                         done
      (%i6) e (- x) - e (x);
      (%o6)                           0

Function: expand
`expand` (expr)
`expand` (expr, p, n)

  Expand expression expr. Products of sums and exponentiated sums are multiplied out, numerators of rational expressions which are sums are split into their respective terms, and multiplication (commutative and non-commutative) are distributed over addition at all levels of expr.

  For polynomials one should usually use `ratexpand` which uses a more efficient algorithm.

  `maxnegex` and `maxposex` control the maximum negative and positive exponents, respectively, which will expand.

  `expand (expr, p, n)` expands expr, using p for `maxposex` and n for `maxnegex`. This is useful in order to expand part but not all of an expression.

  `expon` - the exponent of the largest negative power which is automatically expanded (independent of calls to `expand`). For example if `expon` is 4 then `(x+1)^(-5)` will not be automatically expanded.

  `expop` - the highest positive exponent which is automatically expanded. Thus `(x+1)^3`, when typed, will be automatically expanded only if `expop` is greater than or equal to 3. If it is desired to have `(x+1)^n` expanded where `n` is greater than `expop` then executing `expand ((x+1)^n)` will work only if `maxposex` is not less than `n`.

  `expand(expr, 0, 0)` causes a resimplification of `expr`. `expr` is not reevaluated. In distinction from `ev(expr, noeval)` a special representation (e. g. a CRE form) is removed. See also `ev`.

  The `expand` flag used with `ev` causes expansion.

  The file ``share/simplification/facexp.mac'` contains several related functions (in particular `facsum`, `factorfacsum` and `collectterms`, which are autoloaded) and variables (`nextlayerfactor` and `facsum_combine`) that provide the user with the ability to structure expressions by controlled expansion. Brief function descriptions are available in ``simplification/facexp.usg'`. A demo is available by doing `demo("facexp")`.

  Examples:

      (%i1) expr:(x+1)^2*(y+1)^3;
                                     2        3
      (%o1)                   (x + 1)  (y + 1)
      (%i2) expand(expr);
             2  3        3    3      2  2        2      2      2
      (%o2) x  y  + 2 x y  + y  + 3 x  y  + 6 x y  + 3 y  + 3 x  y
                                                            2
                                           + 6 x y + 3 y + x  + 2 x + 1
      (%i3) expand(expr,2);
                     2        3              3          3
      (%o3)         x  (y + 1)  + 2 x (y + 1)  + (y + 1)
      (%i4) expr:(x+1)^-2*(y+1)^3;
                                         3
                                  (y + 1)
      (%o4)                       --------
                                         2
                                  (x + 1)
      (%i5) expand(expr);
                  3               2
                 y             3 y            3 y             1
      (%o5) ------------ + ------------ + ------------ + ------------
             2              2              2              2
            x  + 2 x + 1   x  + 2 x + 1   x  + 2 x + 1   x  + 2 x + 1
      (%i6) expand(expr,2,2);
                                         3
                                  (y + 1)
      (%o6)                     ------------
                                 2
                                x  + 2 x + 1

  Resimplify an expression without expansion:

      (%i1) expr:(1+x)^2*sin(x);
                                      2
      (%o1)                    (x + 1)  sin(x)
      (%i2) exponentialize:true;
      (%o2)                         true
      (%i3) expand(expr,0,0);
                                  2    %i x     - %i x
                        %i (x + 1)  (%e     - %e      )
      (%o3)           - -------------------------------
                                       2

  ·

  @ref{Category: Expressions}

Function: expandwrt (expr, x_1, …, x_n)

  Expands expression `expr` with respect to the variables x_1, …, x_n. All products involving the variables appear explicitly. The form returned will be free of products of sums of expressions that are not free of the variables. x_1, …, x_n may be variables, operators, or expressions.

  By default, denominators are not expanded, but this can be controlled by means of the switch `expandwrt_denom`.

  This function is autoloaded from ``simplification/stopex.mac'`.

  ·

  @ref{Category: Expressions}

Option variable: expandwrt_denom

  Default value: `false`

  `expandwrt_denom` controls the treatment of rational expressions by `expandwrt`. If `true`, then both the numerator and denominator of the expression will be expanded according to the arguments of `expandwrt`, but if `expandwrt_denom` is `false`, then only the numerator will be expanded in that way.

  ·

  @ref{Category: Expressions}

Function: expandwrt_factored (expr, x_1, …, x_n)

  is similar to `expandwrt`, but treats expressions that are products somewhat differently. `expandwrt_factored` expands only on those factors of `expr` that contain the variables x_1, …, x_n.

  This function is autoloaded from ``simplification/stopex.mac'`.

  ·

  @ref{Category: Expressions}

Option variable: expon

  Default value: 0

  `expon` is the exponent of the largest negative power which is automatically expanded (independent of calls to `expand`). For example, if `expon` is 4 then `(x+1)^(-5)` will not be automatically expanded.

  ·

  @ref{Category: Expressions}

Function: exponentialize (expr)
Option variable: exponentialize

  The function `exponentialize (expr)` converts circular and hyperbolic functions in expr to exponentials, without setting the global variable `exponentialize`.

  When the variable `exponentialize` is `true`, all circular and hyperbolic functions are converted to exponential form. The default value is `false`.

  `demoivre` converts complex exponentials into circular functions. `exponentialize` and `demoivre` cannot both be true at the same time.

  ·

  @ref{Category: Complex variables} · @ref{Category: Trigonometric functions} · @ref{Category: Hyperbolic functions}

Option variable: expop

  Default value: 0

  `expop` is the highest positive exponent which is automatically expanded. Thus `(x + 1)^3`, when typed, will be automatically expanded only if `expop` is greater than or equal to 3. If it is desired to have `(x + 1)^n` expanded where `n` is greater than `expop` then executing `expand ((x + 1)^n)` will work only if `maxposex` is not less than n.

  ·

  @ref{Category: Expressions}

Property: lassociative

  `declare (g, lassociative)` tells the Maxima simplifier that `g` is left-associative. E.g., `g (g (a, b), g (c, d))` will simplify to `g (g (g (a, b), c), d)`.

  ·

  @ref{Category: Declarations and inferences} · @ref{Category: Operators} · @ref{Category: Simplification}

Property: linear

  One of Maxima's operator properties. For univariate `f` so declared, "expansion" `f(x + y)` yields `f(x) + f(y)`, `f(a*x)` yields `a*f(x)` takes place where `a` is a "constant". For functions of two or more arguments, "linearity" is defined to be as in the case of `sum` or `integrate`, i.e., `f (a*x + b, x)` yields `a*f(x,x) + b*f(1,x)` for `a` and `b` free of `x`.

  Example:

      (%i1) declare (f, linear);
      (%o1)                         done
      (%i2) f(x+y);
      (%o2)                      f(y) + f(x)
      (%i3) declare (a, constant);
      (%o3)                         done
      (%i4) f(a*x);
      (%o4)                        a f(x)

  `linear` is equivalent to `additive` and `outative`. See also `opproperties`.

  Example:

      (%i1) 'sum (F(k) + G(k), k, 1, inf);
                             inf
                             ====
                             \
      (%o1)                   >    (G(k) + F(k))
                             /
                             ====
                             k = 1
      (%i2) declare (nounify (sum), linear);
      (%o2)                         done
      (%i3) 'sum (F(k) + G(k), k, 1, inf);
                           inf          inf
                           ====         ====
                           \            \
      (%o3)                 >    G(k) +  >    F(k)
                           /            /
                           ====         ====
                           k = 1        k = 1

  ·

  @ref{Category: Declarations and inferences} · @ref{Category: Operators} · @ref{Category: Simplification}

Option variable: maxnegex

  Default value: 1000

  `maxnegex` is the largest negative exponent which will be expanded by the `expand` command, see also `maxposex`.

  ·

  @ref{Category: Expressions}

Option variable: maxposex

  Default value: 1000

  `maxposex` is the largest exponent which will be expanded with the `expand` command, see also `maxnegex`.

  ·

  @ref{Category: Expressions}

Property: multiplicative

  `declare(f, multiplicative)` tells the Maxima simplifier that `f` is multiplicative.

  1. If `f` is univariate, whenever the simplifier encounters `f` applied to a product, `f` distributes over that product. E.g., `f(x*y)` simplifies to `f(x)*f(y)`. This simplification is not applied to expressions of the form `f('product(...))`.
  2. If `f` is a function of 2 or more arguments, multiplicativity is defined as multiplicativity in the first argument to `f`, e.g., `f (g(x) * h(x), x)` simplifies to `f (g(x) ,x) * f (h(x), x)`.

  `declare(nounify(product), multiplicative)` tells Maxima to simplify symbolic products.

  Example:

      (%i1) F2 (a * b * c);
      (%o1)                       F2(a b c)
      (%i2) declare (F2, multiplicative);
      (%o2)                         done
      (%i3) F2 (a * b * c);
      (%o3)                   F2(a) F2(b) F2(c)

  `declare(nounify(product), multiplicative)` tells Maxima to simplify symbolic products.

      (%i1) product (a[i] * b[i], i, 1, n);
                                   n
                                 /===\
                                  ! !
      (%o1)                       ! !  a  b
                                  ! !   i  i
                                 i = 1
      (%i2) declare (nounify (product), multiplicative);
      (%o2)                         done
      (%i3) product (a[i] * b[i], i, 1, n);
                                n         n
                              /===\     /===\
                               ! !       ! !
      (%o3)                  ( ! !  a )  ! !  b
                               ! !   i   ! !   i
                              i = 1     i = 1

  ·

  @ref{Category: Declarations and inferences} · @ref{Category: Expressions} · @ref{Category: Simplification}

Function: multthru
`multthru` (expr)
`multthru` (expr_1, expr_2)

  Multiplies a factor (which should be a sum) of expr by the other factors of expr. That is, expr is `f_1 f_2 ... f_n` where at least one factor, say f_i, is a sum of terms. Each term in that sum is multiplied by the other factors in the product. (Namely all the factors except f_i). `multthru` does not expand exponentiated sums. This function is the fastest way to distribute products (commutative or noncommutative) over sums. Since quotients are represented as products `multthru` can be used to divide sums by products as well.

  `multthru (expr_1, expr_2)` multiplies each term in expr_2 (which should be a sum or an equation) by expr_1. If expr_1 is not itself a sum then this form is equivalent to `multthru (expr_1*expr_2)`.

      (%i1) x/(x-y)^2 - 1/(x-y) - f(x)/(x-y)^3;
                            1        x         f(x)
      (%o1)             - ----- + -------- - --------
                          x - y          2          3
                                  (x - y)    (x - y)
      (%i2) multthru ((x-y)^3, %);
                                 2
      (%o2)             - (x - y)  + x (x - y) - f(x)
      (%i3) ratexpand (%);
                                 2
      (%o3)                   - y  + x y - f(x)
      (%i4) ((a+b)^10*s^2 + 2*a*b*s + (a*b)^2)/(a*b*s^2);
                              10  2              2  2
                       (b + a)   s  + 2 a b s + a  b
      (%o4)            ------------------------------
                                        2
                                   a b s
      (%i5) multthru (%);  /* note that this does not expand (b+a)^10 */
                                              10
                             2   a b   (b + a)
      (%o5)                  - + --- + ---------
                             s    2       a b
                                 s
      (%i6) multthru (a.(b+c.(d+e)+f));
      (%o6)            a . f + a . c . (e + d) + a . b
      (%i7) expand (a.(b+c.(d+e)+f));
      (%o7)         a . f + a . c . e + a . c . d + a . b

  ·

  @ref{Category: Expressions}

Property: nary

  `declare(f, nary)` tells Maxima to recognize the function `f` as an n-ary function.

  The `nary` declaration is not the same as calling the `nary` function. The sole effect of `declare(f, nary)` is to instruct the Maxima simplifier to flatten nested expressions, for example, to simplify `foo(x, foo(y, z))` to `foo(x, y, z)`. See also `declare`.

  Example:

      (%i1) H (H (a, b), H (c, H (d, e)));
      (%o1)               H(H(a, b), H(c, H(d, e)))
      (%i2) declare (H, nary);
      (%o2)                         done
      (%i3) H (H (a, b), H (c, H (d, e)));
      (%o3)                   H(a, b, c, d, e)

Option variable: negdistrib

  Default value: `true`

  When `negdistrib` is `true`, -1 distributes over an expression. E.g., `-(x + y)` becomes `- y - x`. Setting it to `false` will allow `- (x + y)` to be displayed like that. This is sometimes useful but be very careful: like the `simp` flag, this is one flag you do not want to set to `false` as a matter of course or necessarily for other than local use in your Maxima.

  Example:

      (%i1) negdistrib;
      (%o1)                         true
      (%i2) -(x+y);
      (%o2)                       (- y) - x
      (%i3) negdistrib : not negdistrib ;
      (%o3)                         false
      (%i4) -(x+y);
      (%o4)                       - (y + x)

  ·

  @ref{Category: Simplification flags and variables}

System variable: opproperties

  `opproperties` is the list of the special operator properties recognized by the Maxima simplifier:

  Example:

      (%i1) opproperties;
      (%o1) [linear, additive, multiplicative, outative, evenfun,
      oddfun, commutative, symmetric, antisymmetric, nary,
      lassociative, rassociative]

  ·

  @ref{Category: Global variables} · @ref{Category: Operators}

Property: outative

  `declare(f, outative)` tells the Maxima simplifier that constant factors in the argument of `f` can be pulled out.

  1. If `f` is univariate, whenever the simplifier encounters `f` applied to a product, that product will be partitioned into factors that are constant and factors that are not and the constant factors will be pulled out. E.g., `f(a*x)` will simplify to `a*f(x)` where `a` is a constant. Non-atomic constant factors will not be pulled out.
  2. If `f` is a function of 2 or more arguments, outativity is defined as in the case of `sum` or `integrate`, i.e., `f (a*g(x), x)` will simplify to `a * f(g(x), x)` for `a` free of `x`.

  `sum`, `integrate`, and `limit` are all `outative`.

  Example:

      (%i1) F1 (100 * x);
      (%o1)                       F1(100 x)
      (%i2) declare (F1, outative);
      (%o2)                         done
      (%i3) F1 (100 * x);
      (%o3)                       100 F1(x)
      (%i4) declare (zz, constant);
      (%o4)                         done
      (%i5) F1 (zz * y);
      (%o5)                       zz F1(y)

  ·

  @ref{Category: Declarations and inferences} · @ref{Category: Operators}

Function: radcan (expr)

  Simplifies expr, which can contain logs, exponentials, and radicals, by converting it into a form which is canonical over a large class of expressions and a given ordering of variables; that is, all functionally equivalent forms are mapped into a unique form. For a somewhat larger class of expressions, `radcan` produces a regular form. Two equivalent expressions in this class do not necessarily have the same appearance, but their difference can be simplified by `radcan` to zero.

  For some expressions `radcan` is quite time consuming. This is the cost of exploring certain relationships among the components of the expression for simplifications based on factoring and partial-fraction expansions of exponents.

  Examples:

      (%i1) radcan((log(x+x^2)-log(x))^a/log(1+x)^(a/2));
                                          a/2
      (%o1)                     log(x + 1)
      (%i2) radcan((log(1+2*a^x+a^(2*x))/log(1+a^x)));
      (%o2)                           2
      (%i3) radcan((%e^x-1)/(1+%e^(x/2)));
                                    x/2
      (%o3)                       %e    - 1

  ·

  @ref{Category: Simplification functions}

Option variable: radexpand

  Default value: `true`

  `radexpand` controls some simplifications of radicals.

  When `radexpand` is `all`, causes nth roots of factors of a product which are powers of n to be pulled outside of the radical. E.g. if `radexpand` is `all`, `sqrt (16*x^2)` simplifies to `4*x`.

  More particularly, consider `sqrt (x^2)`.

  - If `radexpand` is `all` or `assume (x > 0)` has been executed, `sqrt(x^2)` simplifies to `x`.
  - If `radexpand` is `true` and `domain` is `real` (its default), `sqrt(x^2)` simplifies to `abs(x)`.
  - If `radexpand` is `false`, or `radexpand` is `true` and `domain` is `complex`, `sqrt(x^2)` is not simplified.

  Note that `domain` only matters when `radexpand` is `true`.

  ·

  @ref{Category: Simplification flags and variables}

Property: rassociative

  `declare (g, rassociative)` tells the Maxima simplifier that `g` is right-associative. E.g., `g(g(a, b), g(c, d))` simplifies to `g(a, g(b, g(c, d)))`.

  ·

  @ref{Category: Declarations and inferences} · @ref{Category: Operators}

Function: scsimp (expr, rule_1, …, rule_n)

  Sequential Comparative Simplification (method due to Stoute). `scsimp` attempts to simplify expr according to the rules rule_1, …, rule_n. If a smaller expression is obtained, the process repeats. Otherwise after all simplifications are tried, it returns the original answer.

  `example (scsimp)` displays some examples.

  ·

  @ref{Category: Simplification functions}

Option variable: simp

  Default value: `true`

  `simp` enables simplification. This is the default. `simp` is also an `evflag`, which is recognized by the function `ev`. See `ev`.

  When `simp` is used as an `evflag` with a value `false`, the simplification is suppressed only during the evaluation phase of an expression. The flag does not suppress the simplification which follows the evaluation phase.

  Many Maxima functions and operations require simplification to be enabled to work normally. When simplification is disabled, many results will be incomplete, and in addition there may be incorrect results or program errors.

  Examples:

  The simplification is switched off globally. The expression `sin(1.0)` is not simplified to its numerical value. The `simp`-flag switches the simplification on.

      (%i1) simp:false;
      (%o1)                         false
      (%i2) sin(1.0);
      (%o2)                       sin(1.0)
      (%i3) sin(1.0),simp;
      (%o3)                  0.8414709848078965

  The simplification is switched on again. The `simp`-flag cannot suppress the simplification completely. The output shows a simplified expression, but the variable `x` has an unsimplified expression as a value, because the assignment has occurred during the evaluation phase of the expression.

      (%i1) simp:true;
      (%o1)                         true
      (%i2) x:sin(1.0),simp:false;
      (%o2)                  0.8414709848078965
      (%i3) :lisp $x
      ((%SIN) 1.0)

  ·

  @ref{Category: Evaluation flags}

Property: symmetric

  `declare (h, symmetric)` tells the Maxima simplifier that `h` is a symmetric function. E.g., `h (x, z, y)` simplifies to `h (x, y, z)`.

  `commutative` is synonymous with `symmetric`.

  ·

  @ref{Category: Declarations and inferences} · @ref{Category: Operators}

Function: xthru (expr)

  Combines all terms of expr (which should be a sum) over a common denominator without expanding products and exponentiated sums as `ratsimp` does. `xthru` cancels common factors in the numerator and denominator of rational expressions but only if the factors are explicit.

  Sometimes it is better to use `xthru` before `ratsimp`ing an expression in order to cause explicit factors of the gcd of the numerator and denominator to be canceled thus simplifying the expression to be `ratsimp`ed.

  Examples:

      (%i1) ((x+2)^20 - 2*y)/(x+y)^20 + (x+y)^(-19) - x/(x+y)^20;
                                      20
                       1       (x + 2)   - 2 y       x
      (%o1)        --------- + --------------- - ---------
                          19             20             20
                   (y + x)        (y + x)        (y + x)
      (%i2) xthru (%);
                                       20
                                (x + 2)   - y
      (%o2)                     -------------
                                         20
                                  (y + x)

  ·

  @ref{Category: Expressions}

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

This document was generated by dpb build user on April, 8 2018 using texi2html 1.76.