# normal

Normalize an expression

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```normal(`f`, `options`)
normal(`object`)
```

## Description

`normal(f)` returns a normal form of the rational expression `f`. MuPAD® regards an expression as normalized when it is a fraction where both numerator and denominator are polynomials whose greatest common divisor is 1.

`normal(object)` replaces the operands of `object` with their normalized form.

`normal` and `simplifyFraction` are equivalent.

If argument `f` contains irrational subexpressions such as `sin(x)`, `x^(-1/3)` etc., then these are replaced by auxiliary variables before normalization. After normalization, these variables are replaced by the normalization of the original subexpressions. Algebraic dependencies of the subexpressions are not taken into account. The operands of the non-rational subexpressions are normalized recursively.

If argument `f` contains floating-point numbers, then these are replaced by rational approximants (see `numeric::rationalize`). In the end, `float` is applied to the result.

With the `Expand` option, the normal form is unique for rational expressions: it is the quotient of expanded polynomials whose greatest common divisor is 1. If `f` and `g` are rational expressions, the following statements are equivalent:

• `f` and `g` are mathematically equivalent.

• `normal(f, Expand) = normal(g, Expand)`

• `normal(f - g, Expand) = 0`

A normal form generated without the `Expand` option (which is equivalent to `Expand = FALSE`) is the quotient of products of powers of expanded polynomials, where all factors of the numerator and the denominator are coprime. MuPAD regards factorized expressions, such as x (x + 1), and equivalent expanded expressions, such as x2 + x, as normalized. Therefore, if you do not use `Expand`, there is no unique normal form of a rational expression.

If `f` and `g` are rational expressions, these statements are equivalent:

• `f` and `g` are mathematically equivalent.

• `normal(f - g) = 0`

For special objects, `normal` is automatically mapped to its operands. In particular, if `object` is a polynomial of domain type `DOM_POLY`, then its coefficients are normalized. Further, if `object` is a set, list, table or array, respectively, then `normal` is applied to all entries. Further, the left and right sides of equations (type `"_equal"`), inequalities (type `"_unequal"`), and relations (type `"_less"` or `"_leequal"`) are normalized. Further, the operands of ranges (type `"_range"`) are normalized automatically.

## Examples

### Example 1

Compute the normal form of some rational expressions:

`normal(x^2 - (x + 1)*(x - 1))`
` `
`normal((x^2 - 1)/(x + 1))`
` `
`normal(1/(x + 1) + 1/(y - 1))`
` `

The following expression must be regarded as a rational expression in the “indeterminates” `y` and `sin(x)`:

`normal(1/sin(x)^2 + y/sin(x))`
` `

### Example 2

Normalize the entries of this list:

`[(x^2 - 1)/(x + 1), x^2 - (x + 1)*(x - 1)]`
` `
`normal(%)`
` `

Now, normalize the coefficients of polynomials:

`poly((x^2-1)/(x+1)*Y^2 + (x^2-(x+1)*(x-1))*Y - 1, [Y])`
` `
`normal(%)`
` `

### Example 3

If you use the `Expand` option, `normal` returns a fraction with the expanded numerator and denominator:

`normal(x/(x^6 - 1) + x^2/(x^4 - 1), Expand)`
` `

Without `Expand`, a fraction returned by `normal` can contain factored expressions:

`normal(x/(x^6 - 1) + x^2/(x^4 - 1))`
` `

### Example 4

If you use the `List` option, `normal` returns a list consisting of the numerator and denominator of the input:

`normal((x^2-1)/(x^2+2*x+1), List)`
` `

Note that `normal(f, List)` is not the same as `[numer(f), denom(f)]`:

`[numer, denom]((x^2-1)/(x^2+2*x+1))`
` `

### Example 5

To skip calculation of common divisors of the numerator and denominator of an expression, use the `NoGcd` option:

```y := (x^4 - 1)/(x + 1) + 1: normal(y); normal(y, NoGcd)```
` `
` `

### Example 6

To specify common divisors that you want to cancel out, use the `ToCancel` option:

```y := (x^4 - 1)/(x^2 - 1): normal(y, ToCancel = {x - 1})```
` `

### Example 7

By default, `normal` calls the `rationalize` function in attempt to rationalize the input expression. You might speed up computations by using `Rationalize = None` in conjunction with the `Expand` option. This combination of options lets you skip investigating algebraic dependencies and, therefore, saves some time:

```n := exp(u): a := (n^2 + n)/(n + 1) + 1: normal(a, Expand, Rationalize = None)```
` `

Without `Rationalize = None`, MuPAD analyzes algebraic dependencies and returns this result:

`normal(a, Expand)`
` `

### Example 8

Disable recursive calls to `normal` for subexpressions by using `Recursive = FALSE`:

```y := sqrt((x^2 + 2*x + 1)/(x + 1)): normal(y, Recursive = FALSE)```
` `

### Example 9

Solve this equation, and sum up the fifth powers of the solutions:

```solutions := solve(x^3 + x^2 + 1, x, MaxDegree = 3): f := _plus((solutions[i]^7) \$i = 1..3)```
` `

Normalizing the result returns:

`normal(f)`
` `

To limit the number of internally repeated calls to `normal` due to analysis of algebraic dependencies, use the `Iterations` option. The default number of iterations is 5. Use the `Iterations` option to increase or decrease the number of iterations. For example, normalize the result using just one iteration:

`normal(f, Iterations = 1)`
` `

After two iterations, the result becomes shorter:

`normal(f, Iterations = 2)`
` `

After three iterations, you get the simplest result:

`normal(f, Iterations = 3)`
` `

## Parameters

 `f` `object` A polynomial of type `DOM_POLY`, list, set, table, array, equation, inequality, or range

## Options

 `Expand` Return the numerator and denominator of the normalized expression in expanded form. See “Details” for more information. By default, `Expand = FALSE`. `List` Return a list consisting of the numerator and denominator of `f`. By default, `List = FALSE`. `NoGcd` Skip computing common divisors of the numerator and denominator of `f`. By default, `NoGcd = FALSE`. `ToCancel` Option, specified as `ToCancel = {expr1, expr2, …}` Cancel out only the specified common divisors ```{expr1, expr2,...}```. `Rationalize` Option, specified as `Rationalize = None` Perform only basic rationalization of an irrational input expression. Skip investigating algebraic dependencies. This option works only in conjunction with the `Expand` option. Otherwise, `normal` ignores this option. See Example 7. `Recursive` Recursively normalize subexpressions of an irrational expression. By default, `Recursive = TRUE`. `Iterations` Option, specified as `Iterations = n` Specify the number of repeated calls to `normal`. Repeated calls appear when analysis of algebraic dependencies results in new irrational subexpressions. By default, `n = 5`.

## Return Values

Object of the same type as the input object, or a list of two arithmetical expressions if the `List` option is used.

`object`