# `daetools`::`reduceDAEIndex`

Convert system of first-order differential algebraic equations to equivalent system of differential index 1

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

```[`newEqs`,`newVars`,`R`,`oldIndex`] := daetools::reduceDAEIndex(`eqs`,`vars`)
```

## Description

`[newEqs,newVars,R,oldIndex] := daetools::reduceDAEIndex(eqs,vars)` converts a high-index system of first-order differential algebraic equations `eqs` to an equivalent system `newEqs` of differential index `1`. The `daetools::reduceDAEIndex` function keeps the original equations and variables and introduces new variables and equations. It also returns the matrix `R` that expresses the new variables in `newVars` as derivatives of the original variables `vars` and the differential index `oldIndex` of the original system of DAEs, `eqs`.

After conversion, `daetools::reduceDAEIndex` checks the differential index of the new system by calling `daetools::isLowIndexDAE`. If the index of `newEqs` is `2` or higher, then `daetools::reduceDAEIndex` issues a warning.

The implementation of `daetools::reduceDAEIndex` uses the Pantelides algorithm. This algorithm reduces higher-index systems to lower-index systems by selectively adding differentiated forms of the original equations. The Pantelides algorithm can underestimate the differential index of a new system, and therefore, can fail to reduce the differential index to `1`. In this case, `daetools::reduceDAEIndex` issues a warning and returns the value of `oldIndex` as `UNKNOWN`. The `daetools::reduceDAEToODE` function uses more reliable, but slower Gaussian elimination. Note that `daetools::reduceDAEToODE` requires the DAE system to be semilinear.

## Examples

### Example 1

Reduce the differential index of a system that contains two second-order differential algebraic equations. Because the equations are second-order equations, first use `reduceDifferentialOrder` to rewrite the system to a system of first-order DAEs.

Create the following system of two second-order DAEs. Here, `x(t)`, `y(t)`, and `F(t)`are state variables of the system.

```eqs := [diff(x(t), t, t) = -F(t)*x(t), diff(y(t), t, t) = -F(t)*y(t) - g, x(t)^2 + y(t)^2 = r^2]; vars := [x(t), y(t), F(t)]```

Rewrite this system so that all equations become first-order differential equations. The `daetools::reduceDifferentialOrder` function replaces the second-order DAE by two first-order expressions by introducing the new variables `Dxt(t)` and `Dyt(t)`.

```[eqs, vars, R] := daetools::reduceDifferentialOrder(eqs, vars): newEquations = eqs; newVariables = vars; relations = R```

Use `daetools::reduceDAEIndex` to rewrite the system so that the differential index is `1`.

```[eqs,vars,R,originalIndex] := daetools::reduceDAEIndex(eqs,vars): newEquations = eqs; newVariables = vars; relations = R; originalDAEIndex = originalIndex```

Use `daetools::reduceRedundancies` to shorten the system.

```[eqs, vars, solvedEquations, constantVariables, replacedVariables, otherEquations] := daetools::reduceRedundancies(eqs, vars): newEquations = eqs; newVariables = vars;```

## Parameters

 `eqs` A list or a vector of equations or expressions in the state variables `vars` and their derivatives. Expressions represent equations with `0` right side. `vars` A list or a vector of identifiers or expressions, such as ```[x1(t), x2(t)]```.

## Return Values

A nested list containing the following four outputs: a list of new equations, a list of new variables, a list of relations between new and original variables, and the differential index of the original DAE system. If `daetools::reduceDAEIndex` fails to reduce the differential index to `1`, then it issues a warning and returns `UNKNOWN` instead of the differential index of the original DAE system.

#### Mathematical Modeling with Symbolic Math Toolbox

Get examples and videos