# mrdivide

Class: LagOp

Lag operator polynomial right division

## Syntax

`A = C/BA = mrdivide(C, B,'PropertyName', PropertyValue)`

## Description

`A = C/B` returns the quotient lag operator polynomial (`A`), which is the result of C(L)/B(L).

`A = mrdivide(C, B,'PropertyName', PropertyValue)` accepts one or more optional comma-separated property name/value pairs.

## Tips

The right division operator (/) invokes `mrdivide`, but the optional inputs are available only by calling `mrdivide` directly.

To right-invert a stable B(L), set C(L) = eye(B.Dimension).

## Input Arguments

 `C` Numerator (dividend) lag operator polynomial object, as produced by `LagOp`, in the quotient C(L)/B(L). `B` Denominator (divisor) lag operator polynomial object, as produced by `LagOp`, in the quotient C(L)/B(L). If at least one of `C` or `B` is a lag operator polynomial object, the other can be a cell array of matrices (initial lag operator coefficients), or a single matrix (zero-degree lag operator). `'AbsTol'` Nonnegative scalar absolute tolerance used as part of the termination criterion of the calculation of the quotient coefficients and, subsequently, to determine which coefficients to include in the quotient. Specifying an absolute tolerance allows for customization of the termination criterion. Once the algorithm has terminated, `'AbsTol'` is used to exclude polynomial lags with near-zero coefficients. A coefficient matrix for a given lag is excluded if the magnitudes of all elements of the matrix are less than or equal to the absolute tolerance. Default: `1e-12` `'RelTol'` Nonnegative scalar relative tolerance used as part of the termination criterion of the calculation of the quotient coefficients. At each lag, a coefficient matrix is calculated and its 2-norm compared to the largest coefficient 2-norm. If the ratio of the current norm to the largest norm is less than or equal to `'RelTol'`, then the relative termination criterion is satisfied. Default: `0.01` `'Window'` Positive integer indicating the size of the window used to check termination tolerances. `Window` represents the number of consecutive lags for which coefficients must satisfy a tolerance-based termination criterion in order to terminate the calculation of the quotient coefficients. If coefficients remain below tolerance for the length of the specified tolerance window, they are assumed to have died out sufficiently to terminate the algorithm (see notes below). Default: `20` `'Degree'` Nonnegative integer indicating the maximum degree of the quotient polynomial. For stable denominators, the default is the power to which the magnitude of the largest eigenvalue of the denominator must be raised to equal the relative termination tolerance `'RelTol'`; for unstable denominators, the default is the power to which the magnitude of the largest eigenvalue must be raised to equal the largest positive floating point number (see `realmax`). The default is 1000, regardless of the stability of the denominator. Default: `1000`

## Output Arguments

 `A` Quotient lag operator polynomial object, with A(L) = C(L)/B(L).

## Examples

collapse all

### Invert a Lag Operator Polynomial

Create a `LagOp` polynomial object with a sequence of scalar coefficients specified as a cell array:

```A = LagOp({1 -0.5}); ```

Invert the polynomial by using the short-hand slash ("/") operator:

```a = 1 / A ```
```a = 1-D Lag Operator Polynomial: ----------------------------- Coefficients: [1 0.5 0.25 0.125 0.0625 0.03125 0.015625] Lags: [0 1 2 3 4 5 6] Degree: 6 Dimension: 1 ```

## Algorithms

Lag operator polynomial division generally results in infinite-degree polynomials. `mrdivide` imposes a termination criterion to truncate the degree of the quotient polynomial.

If `'Degree'` is unspecified, the maximum degree of the quotient is determined by the stability of the denominator. Stable denominator polynomials usually result in quotients whose coefficients exhibit geometric decay in absolute value. (When coefficients change sign, it is the coefficient envelope which decays geometrically.) Unstable denominators usually result in quotients whose coefficients exhibit geometric growth in absolute value. In either case, maximum degree will not exceed the value of `'Degree'`.

To control truncation error by terminating the coefficient sequence too early, the termination criterion involves three steps:

1. At each lag in the quotient polynomial, a coefficient matrix is calculated and tested against both a relative and an absolute tolerance (see `'RelTol'` and` 'AbsTol'` inputs ).

2. If the current coefficient matrix is below either tolerance, then a tolerance window is opened to ensure that all subsequent coefficients remain below tolerance for a number of lags determined by `'Window'`.

3. If any subsequent coefficient matrix within the window is above both tolerances, then the tolerance window is closed and additional coefficients are calculated, repeating steps (1) and (2) until a subsequent coefficient matrix is again below either tolerance, and a new window is opened.

The algorithm repeats steps 1–3 until a coefficient is below tolerance and subsequent coefficients remains below tolerance for `'Window'` lags, or until the maximum `'Degree'` is encountered, or until a coefficient becomes numerically unstable (`NaN` or `+/-Inf`).

## References

[1] Box, G.E.P., G.M. Jenkins, and G.C. Reinsel. Time Series Analysis: Forecasting and Control. 3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1994.

[2] Hayashi, F. Econometrics. Princeton, NJ: Princeton University Press, 2000.

[3] Hamilton, J. D. Time Series Analysis. Princeton, NJ: Princeton University Press, 1994.