Solving as ODE45 and ODE15s gives different results

Hi, I have to solve this problem
as it were a DAE (I know I could just substitute h into the equation, but this is just an example, because in reality the problem I have to solve is a DAE and more complex than this). When I use ode45 and treat the problem as a second order differential equation, the graph t Vs y is
but when I treat it as a DAE, the graph is completely different
and I do not understand why. Here is my code:
ode45 second order differential equation
function yp = dae_normale(t,y)
yp = zeros(2,1);
yp(1) = y(2);
yp(2) = 4*y(2) + 1/(5*y(2) - 2*y(1) ) - 7*y(1);
ode45 second order differential equation run
[t,y] = ode45('dae_normale',[1,5],[1,1]);
[t,y(:,1)]
plot(t,y(:,1))
DAE ode15s
function out = dae(t,y)
out = [y(2)
4*y(2) + 1/y(3) - 7*y(1)
y(3) - 5*y(2) + 2*y(1) ];
DAE ode15s run
y0 = [1; 1; 3];
M = [1 0 0; 0 1 0; 0 0 0];
options = odeset('Mass',M);
[t,y] = ode15s(@dae,[1 5],y0,options);
[t,y(:,1)]
plot(t,y(:,1))
Thank you.

3 Comments

Please include the graph you get from ODE15S for y(1).
Best wishes
Torsten.
I edited the original message.
Maybe you should try what happens when you strengthen the tolerances for ODE45 in the options structure (RelTol=1e-8, AbsTol=1e-8).
Best wishes
Torsten.

Sign in to comment.

Answers (1)

I tried following Torsten's suggestion and now the two graphs are almost equal. Here is the code I modified as Torsten pointed out:
ode45 second order differential equation run
options = odeset('RelTol',1e-8,'AbsTol',[1e-8 1e-8]);
[t,y]=ode45('dae_normale',[1,5],[1,1],options);
[t,y(:,1)]
plot(t,y(:,1))

Asked:

on 10 Nov 2016

Answered:

on 10 Nov 2016

Community Treasure Hunt

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

Start Hunting!