Main Content

reduceRedundancies

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

Description

[newEqs,newVars] = reduceRedundancies(eqs,vars) eliminates redundant equations and variables from the system of first-order differential algebraic equations (DAEs) 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.

example

[newEqs,newVars,R] = reduceRedundancies(eqs,vars) returns a structure array R containing information on the eliminated equations and variables.

example

Examples

collapse all

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 = 

(a1t x1(t)+a2t x1(t)2-bf(t)a3t x1(t)2+a4t x3(t)-cf(t))

newVars = 

(x1(t)x3(t))

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 = 

(Vac(t)=V1(t)+V2(t)V1(t)=RI(t)V2(t)=Lt I(t)Vac(t)=V0cos(t))

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

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 = 

-Lt I(t)-RI(t)+V0cos(t)

newVars = I(t)

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 = (Vac(t)V1(t)V2(t)I(t))
[newEqs,newVars] = reduceRedundancies(eqs,vars2)
newEqs = 

-Lt V1(t)+RV1(t)-RV0cos(t)R

newVars = V1(t)

Here, reduceRedundancies returns a reduced equation in term of the state variable V1(t).

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 = 

(a1t x1(t)+a2t x1(t)2-bf(t)a3t x1(t)2+a4t x3(t)-cf(t))

newVars = 

(x1(t)x3(t))

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 = 

(x4(t)-f(t)x1(t)-2x2(t))

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 = (x4(t)f(t))

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 = 

(x2(t)x1(t)2)

The otherEquations field contains those equations from eqs that do not contain any of the state variables vars.

R4 = R.otherEquations
R4 = f(t)-sin(t)

Input Arguments

collapse all

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.

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

collapse all

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.

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

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