Error in solutions to algebraic equation when passed to ode45

1 view (last 30 days)
Can you pass a DAE and corresponding algebraic equations to ode45?
I am receiving errors (order 10^-12) between the results of the ode solver and the results I get by passing the values to the algebraic equations directly.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 15 Aug 2022
The floating point relative accuracy or tolerances applied to the "options" field could be the cause of this discrepancy.
The typical workflow for solving DAEs with algebraic constraints would be to use “ode15s”, “ode23t”, or “ode15i.” These solvers let you specify algebraic constraints for DAEs by specifying a singular mass matrix and will likely be better suited to these equations.
The following link has details about solving DAEs using those solvers
However, even with the DAE solvers, there is no guarantee that the constraints are satisfied exactly. This is likely not possible due to floating-point restrictions.
If having the constraint satisfied exactly is a requirement for your application, a symbolic solver may be a better option. Here is an example of how to compute a symbolic solution of an ordinary differential equation (ODE) using MATLAB’s “dsolve” function:

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!