# Documentation

## Use General Simplification Functions

 Note:   Use only in the MuPAD Notebook Interface. This functionality does not run in MATLAB.

### When to Use General Simplifiers

Simplification of mathematical expression is not a clearly defined subject. There is no universal idea as to which form of an expression is simplest. The form of a mathematical expression that is simplest for one problem turns out to be complicated or even unsuitable for another problem. For example, the following two mathematical expressions present the same polynomial in different forms:

(x + 1) (x - 2) (x + 3) (x - 4),

x4 - 2 x3 - 13 x2 + 14 x + 24.

The first form clearly shows the roots of this polynomial. This form is simpler for working with the roots. The second form serves best when you want to the coefficients of the polynomial.

If the problem you want to solve requires a particular form of an expression, the best approach is to choose the appropriate simplification function. See Choosing Simplification Functions.

Besides specific simplifiers, MuPAD® offers two general ones:

• `simplify` searches for a simpler form by rewriting the terms of an expression. This function uses an internal set of rules for rewriting an expression. You cannot modify this set of rules.

• `Simplify` performs more extensive search for a simple form of an expression. For some expressions, this function can be slower, but more flexible and more powerful than `simplify`. `Simplify` uses a wider set of rules to search for a simpler form of an expression. `Simplify` lets you extend the set of simplification rules and also accepts a number of options allowing you more control over the simplification algorithm.

If you do not need a particular form of expressions (expanded, factored, or expressed in particular terms), use `simplify` and `Simplify` to shorten mathematical expressions. For example, use these functions to find a shorter form for a final result. The general simplifiers also can help you in verifying the result.

### Choose simplify or Simplify

Use the `simplify` command to simplify elementary expressions such as:

```simplify((x - 1)*(x + 1)*(x^2 + x + 1)*(x^2 + 1)* (x^2 - x + 1)*(x^4 - x^2 + 1)); simplify(cos(x)^(-2) - tan(x)^2)```

For elementary expressions, `simplify` is an effective and fast simplifier. For more complicated expressions, `simplify` might be less effective. The returned form of the following expression can be shortened further. `Simplify` returns a simpler form:

```f := (cos(x)^2 - sin(x)^2)/(sin(x)*cos(x)): simplify(f), Simplify(f)```

### Use Options to Control Simplification Algorithms

By default, in order to find the simplest form of an expression, the `Simplify` function takes one simplification step. This function can simplify some expressions further by taking more simplifications steps:

```F := exp((cos(x)^2 - sin(x)^2)*sin(2*x)*(exp(2*x) -2*exp(x) + 1)/(exp(2*x) - 1)): Simplify(F)```

You can change the number of internal simplification steps through the option `Steps`. This option is not available for `simplify`:

`Simplify(F, Steps = 250)`

By default, the general simplifiers return only one form of an expression—the form that MuPAD considers to be simplest. To return all forms found by `Simplify`, use the option `All`:

```Simplify((x - 1)*(x + 1)*(x^2 + x + 1)*(x^2 + 1) *(x^2 - x + 1)*(x^4 - x^2 + 1), All)```

While transforming an expression, MuPAD simplifiers keep all forms of an expression mathematically equivalent to the initial expression. For example, the simplifiers do not combine logarithms. The rule for combining logarithms does not hold for arbitrary complex arguments and, therefore, combining logarithms can be incorrect for some parameters:

`Simplify(ln(x + 2) - ln(x^2 + 4*x + 4))`

Potential division by zero is the only exception of this rule:

`Simplify(x*(x + 1)/x)`

To apply more simplification rules that are not generally correct, but which can return simpler results, use the option `IgnoreAnalyticConstraints`. This option is available for both `simplify` and `Simplify`. For example, simplifying an expression with `IgnoreAnalyticConstraints`, you get the result with combined logarithms:

`Simplify(ln(x + 2) - ln(x^2 + 4*x + 4), IgnoreAnalyticConstraints)`

For the list of all options available for the general simplifiers, see `simplify` and `Simplify`.