Error in solutions to algebraic equation when passed to ode45
1 view (last 30 days)
Show older comments
MathWorks Support Team
on 15 Aug 2022
Answered: MathWorks Support Team
on 15 Aug 2022
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
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:
0 Comments
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!