Declare three output arguments when calling `reduceRedundancies`

to simplify a system of equations and return information about the eliminated equations.

Create the following system of five differential algebraic equations (DAEs) in four state variables `x1(t)`

, `x2(t)`

, `x3(t)`

, and `x4(t)`

. The system also contains symbolic parameters `a1`

, `a2`

, `a3`

, `a4`

, `b`

, `c`

, and the function `f(t)`

that are not state variables.

Call `reduceRedundancies`

with three output arguments.

newEqs =
$$\left(\begin{array}{c}{a}_{1}\hspace{0.17em}\frac{\partial}{\partial t}\mathrm{}{x}_{1}\left(t\right)+\frac{{a}_{2}\hspace{0.17em}\frac{\partial}{\partial t}\mathrm{}{x}_{1}\left(t\right)}{2}-b\hspace{0.17em}f\left(t\right)\\ \frac{{a}_{3}\hspace{0.17em}\frac{\partial}{\partial t}\mathrm{}{x}_{1}\left(t\right)}{2}+{a}_{4}\hspace{0.17em}\frac{\partial}{\partial t}\mathrm{}{x}_{3}\left(t\right)-c\hspace{0.17em}f\left(t\right)\end{array}\right)$$

newVars =
$$\left(\begin{array}{c}{x}_{1}\left(t\right)\\ {x}_{3}\left(t\right)\end{array}\right)$$

R = *struct with fields:*
solvedEquations: [2x1 sym]
constantVariables: [1x2 sym]
replacedVariables: [1x2 sym]
otherEquations: [1x1 sym]

The function `reduceRedundancies`

returns information about eliminated equations to `R`

. Here, `R`

is a structure array with four fields.

The `solvedEquations`

field contains the equations that are eliminated by `reduceRedundancies`

. The eliminated equations contain those state variables from `vars`

that do not appear in `newEqs`

. The right side of each eliminated equation is equal to zero.

R1 =
$$\left(\begin{array}{c}{x}_{1}\left(t\right)-2\hspace{0.17em}{x}_{2}\left(t\right)\\ {x}_{4}\left(t\right)-f\left(t\right)\end{array}\right)$$

The `constantVariables`

field contains a matrix with two columns. The first column contains those state variables from `vars`

that `reduceRedundancies`

replaced by constant values. The second column contains the corresponding constant values.

R2 = $$\left(\begin{array}{cc}{x}_{4}\left(t\right)& f\left(t\right)\end{array}\right)$$

The `replacedVariables`

field contains a matrix with two columns. The first column contains those state variables from `vars`

that `reduceRedundancies`

replaced by expressions in terms of other variables. The second column contains the corresponding values of the eliminated variables.

R3 =
$$\left(\begin{array}{cc}{x}_{2}\left(t\right)& \frac{{x}_{1}\left(t\right)}{2}\end{array}\right)$$

The `otherEquations`

field contains those equations from `eqs`

that do not contain any of the state variables `vars`

.

R4 = $$f\left(t\right)-\mathrm{sin}\left(t\right)$$