# reduceRedundancies

Simplify system of first-order differential algebraic equations by eliminating redundant equations and variables

## Syntax

## Description

`[`

eliminates redundant equations and variables from the system of first-order
differential algebraic equations (DAEs) `newEqs`

,`newVars`

]
= reduceRedundancies(`eqs`

,`vars`

)`eqs`

. The input argument
`vars`

specifies the state variables of the system.

`reduceRedundancies`

returns the new DAE system as a column
vector `newEqs`

and the reduced state variables as a column
vector `newVars`

. Each element of `newEqs`

represents an equation with right side equal to zero.

## Examples

### Reduce DAE System by Removing Redundant Equations

Simplify a system of five differential algebraic equations (DAEs) in four state variables to a system of two equations in two state variables.

Create the following system of five 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.

syms x1(t) x2(t) x3(t) x4(t) a1 a2 a3 a4 b c f(t) eqs = [a1*diff(x1(t),t)+a2*diff(x2(t),t) == b*x4(t), a3*diff(x2(t),t)+a4*diff(x3(t),t) == c*x4(t), x1(t) == 2*x2(t), x4(t) == f(t), f(t) == sin(t)]; vars = [x1(t),x2(t),x3(t),x4(t)];

Use `reduceRedundancies`

to eliminate redundant equations and corresponding state variables.

[newEqs,newVars] = reduceRedundancies(eqs,vars)

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)$$

### Specify Input Order of State Variables

Specify input order of the state variables to choose which variables are being returned when eliminating DAEs.

Create a system of four DAEs in four state variables `V_ac(t)`

, `V1(t)`

, `V2(t)`

, and `I(t)`

. The system also contains symbolic parameters `L`

, `R`

, and `V0`

.

syms V_ac(t) V1(t) V2(t) I(t) L R V0 eqs = [V_ac(t) == V1(t) + V2(t), V1(t) == I(t)*R, V2(t) == L*diff(I(t),t), V_ac(t) == V0*cos(t)]

eqs =$$\left(\begin{array}{c}{V}_{\mathrm{ac}}\left(t\right)={V}_{1}\left(t\right)+{V}_{2}\left(t\right)\\ {V}_{1}\left(t\right)=R\hspace{0.17em}\text{I}\left(t\right)\\ {V}_{2}\left(t\right)=L\hspace{0.17em}\frac{\partial}{\partial t}\mathrm{}\text{I}\left(t\right)\\ {V}_{\mathrm{ac}}\left(t\right)={V}_{0}\hspace{0.17em}\mathrm{cos}\left(t\right)\end{array}\right)$$

vars = [V_ac(t),I(t),V1(t),V2(t)]

`vars = $$\left(\begin{array}{cccc}{V}_{\mathrm{ac}}\left(t\right)& \text{I}\left(t\right)& {V}_{1}\left(t\right)& {V}_{2}\left(t\right)\end{array}\right)$$`

Use `reduceRedundancies`

to eliminate redundant equations and variables. `reduceRedundancies`

prioritizes to keep the state variables in the vector `vars`

starting from the first element.

[newEqs,newVars] = reduceRedundancies(eqs,vars)

newEqs =$$-L\hspace{0.17em}\frac{\partial}{\partial t}\mathrm{}\text{I}\left(t\right)-R\hspace{0.17em}\text{I}\left(t\right)+{V}_{0}\hspace{0.17em}\mathrm{cos}\left(t\right)$$

`newVars = $$\text{I}\left(t\right)$$`

Here, `reduceRedundancies`

returns a reduced equation in term of the variable `I(t)`

.

When multiple ways of reducing the DAEs exist, specify a different input order of the state variables to choose which variables are being returned. Specify another vector that contains a different order of the state variables. Eliminate the DAEs again.

vars2 = [V_ac(t),V1(t),V2(t),I(t)]

`vars2 = $$\left(\begin{array}{cccc}{V}_{\mathrm{ac}}\left(t\right)& {V}_{1}\left(t\right)& {V}_{2}\left(t\right)& \text{I}\left(t\right)\end{array}\right)$$`

[newEqs,newVars] = reduceRedundancies(eqs,vars2)

newEqs =$$-\frac{L\hspace{0.17em}\frac{\partial}{\partial t}\mathrm{}{V}_{1}\left(t\right)+R\hspace{0.17em}{V}_{1}\left(t\right)-R\hspace{0.17em}{V}_{0}\hspace{0.17em}\mathrm{cos}\left(t\right)}{R}$$

`newVars = $${V}_{1}\left(t\right)$$`

Here, `reduceRedundancies`

returns a reduced equation in term of the state variable `V1(t)`

.

### Obtain Information About Eliminated Equations

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.

syms x1(t) x2(t) x3(t) x4(t) a1 a2 a3 a4 b c f(t) eqs = [a1*diff(x1(t),t)+a2*diff(x2(t),t) == b*x4(t), a3*diff(x2(t),t)+a4*diff(x3(t),t) == c*x4(t), x1(t) == 2*x2(t), x4(t) == f(t), f(t) == sin(t)]; vars = [x1(t),x2(t),x3(t),x4(t)];

Call `reduceRedundancies`

with three output arguments.

[newEqs,newVars,R] = reduceRedundancies(eqs,vars)

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: [x4(t) f(t)]
replacedVariables: [x2(t) x1(t)/2]
otherEquations: f(t) - sin(t)

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 = R.solvedEquations

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 = R.constantVariables

`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 = R.replacedVariables

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 = R.otherEquations

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

## Input Arguments

`eqs`

— System of first-order DAEs

vector of symbolic equations | vector of symbolic expressions

System of first-order DAEs, specified as a vector of symbolic equations or expressions.

The relation operator `==`

defines symbolic
equations. If you specify the element of `eqs`

as a
symbolic expression without a right side, then a symbolic equation with
right side equal to zero is assumed.

`vars`

— State variables

vector of symbolic functions | vector of symbolic function calls

State variables, specified as a vector of symbolic functions or function
calls, such as `x(t)`

.

The input order of the state variables determines which reduced variables
are being returned. If multiple ways of reducing the DAEs exist, then
`reduceRedundancies`

prioritizes to keep the state
variables in `vars`

starting from the first element.

**Example: **`[x(t),z(t),y(t)]`

## Output Arguments

`newEqs`

— System of first-order DAEs

column vector of symbolic expressions

System of first-order DAEs, returned as a column vector of symbolic
expressions. Each element of `newEqs`

represents an
equation with right side equal to zero.

`newVars`

— Reduced set of variables

column vector of symbolic function calls

Reduced set of variables, returned as a column vector of symbolic function calls.

`R`

— Information about eliminated variables

structure array

Information about eliminated variables, returned as a structure array containing four fields. To access this information, use:

`R.solvedEquations`

to return a symbolic column vector of all equations that`reduceRedundancies`

used to replace those state variables that do not appear in`newEqs`

.`R.constantVariables`

to return a matrix with the following two columns. The first column contains those original state variables of the vector`vars`

that were eliminated and replaced by constant values. The second column contains the corresponding constant values.`R.replacedVariables`

to return a matrix with the following two columns. The first column contains those original state variables of the vector`vars`

that were eliminated and replaced in terms of other variables. The second column contains the corresponding values of the eliminated variables.`R.otherEquations`

to return a column vector containing all original equations`eqs`

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

.

## Version History

**Introduced in R2014b**

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)