# reduceDAEToODE

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

## Syntax

## Description

converts
a high-index system of first-order semilinear algebraic equations `newEqs`

= reduceDAEToODE(`eqs`

,`vars`

)`eqs`

to
an equivalent system of ordinary differential equations, `newEqs`

.
The differential index of the new system is `0`

,
that is, the Jacobian of `newEqs`

with respect to
the derivatives of the variables in `vars`

is invertible.

`[`

returns
a vector of constraint equations.`newEqs`

,`constraintEqs`

]
= reduceDAEToODE(`eqs`

,`vars`

)

## Examples

### Convert DAE System to Implicit ODE System

Convert a system of differential algebraic equations (DAEs) to a system of implicit ordinary differential equations (ODEs).

Create the following system of two differential algebraic equations.
Here, the symbolic functions `x(t)`

, `y(t)`

,
and `z(t)`

represent the state variables of the system.
Specify the equations and variables as two symbolic vectors: equations
as a vector of symbolic equations, and variables as a vector of symbolic
function calls.

syms x(t) y(t) z(t) eqs = [diff(x,t)+x*diff(y,t) == y,... x*diff(x, t)+x^2*diff(y) == sin(x),... x^2 + y^2 == t*z]; vars = [x(t), y(t), z(t)];

Use `reduceDAEToODE`

to rewrite the system
so that the differential index is `0`

.

newEqs = reduceDAEToODE(eqs, vars)

newEqs = x(t)*diff(y(t), t) - y(t) + diff(x(t), t) diff(x(t), t)*(cos(x(t)) - y(t)) - x(t)*diff(y(t), t) z(t) - 2*x(t)*diff(x(t), t) - 2*y(t)*diff(y(t), t) + t*diff(z(t), t)

### Reduce System and Return More Details

Check if the following DAE system has a low
(`0`

or `1`

) or high (`>1`

)
differential index. If the index is higher than `1`

,
first try to reduce the index by using `reduceDAEIndex`

and
then by using `reduceDAEToODE`

.

Create the system of differential algebraic equations. Here,
the functions `x1(t)`

, `x2(t)`

,
and `x3(t)`

represent the state variables of the
system. The system also contains the functions `q1(t)`

, `q2(t)`

,
and `q3(t)`

. These functions do not represent state
variables. Specify the equations and variables as two symbolic vectors:
equations as a vector of symbolic equations, and variables as a vector
of symbolic function calls.

syms x1(t) x2(t) x3(t) q1(t) q2(t) q3(t) eqs = [diff(x2) == q1 - x1, diff(x3) == q2 - 2*x2 - t*(q1-x1), q3 - t*x2 - x3]; vars = [x1(t), x2(t), x3(t)];

Use `isLowIndexDAE`

to check the differential
index of the system. For this system, `isLowIndexDAE`

returns `0`

(`false`

).
This means that the differential index of the system is `2`

or
higher.

isLowIndexDAE(eqs, vars)

ans = logical 0

Use `reduceDAEIndex`

as your first attempt
to rewrite the system so that the differential index is `1`

.
For this system, `reduceDAEIndex`

issues a warning
because it cannot reduce the differential index of the system to `0`

or `1`

.

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

Warning: Index of reduced DAEs is larger than 1. newEqs = x1(t) - q1(t) + diff(x2(t), t) Dx3t(t) - q2(t) + 2*x2(t) + t*(q1(t) - x1(t)) q3(t) - x3(t) - t*x2(t) diff(q3(t), t) - x2(t) - t*diff(x2(t), t) - Dx3t(t) newVars = x1(t) x2(t) x3(t) Dx3t(t)

If `reduceDAEIndex`

cannot reduce the semilinear
system so that the index is `0`

or `1`

,
try using `reduceDAEToODE`

. This function can be
much slower, therefore it is not recommended as a first choice. Use
the syntax with two output arguments to also return the constraint
equations.

[newEqs, constraintEqs] = reduceDAEToODE(eqs, vars)

newEqs = x1(t) - q1(t) + diff(x2(t), t) 2*x2(t) - q2(t) + t*q1(t) - t*x1(t) + diff(x3(t), t) diff(x1(t), t) - diff(q1(t), t) + diff(q2(t), t, t) - diff(q3(t), t, t, t) constraintEqs = x1(t) - q1(t) + diff(q2(t), t) - diff(q3(t), t, t) x3(t) - q3(t) + t*x2(t) x2(t) - q2(t) + diff(q3(t), t)

Use the syntax with three output arguments to return the new
equations, constraint equations, and the differential index of the
original system, `eqs`

.

[newEqs, constraintEqs, oldIndex] = reduceDAEToODE(eqs, vars)

newEqs = x1(t) - q1(t) + diff(x2(t), t) 2*x2(t) - q2(t) + t*q1(t) - t*x1(t) + diff(x3(t), t) diff(x1(t), t) - diff(q1(t), t) + diff(q2(t), t, t) - diff(q3(t), t, t, t) constraintEqs = x1(t) - q1(t) + diff(q2(t), t) - diff(q3(t), t, t) x3(t) - q3(t) + t*x2(t) x2(t) - q2(t) + diff(q3(t), t) oldIndex = 3

## Input Arguments

## Output Arguments

## Algorithms

The implementation of `reduceDAEToODE`

is
based on Gaussian elimination. This algorithm is more reliable than
the Pantelides algorithm used by `reduceDAEIndex`

,
but it can be much slower.

## Version History

**Introduced in R2014b**