Hello
y’‘+ yy’=0 with ic = [1;-1]
I have tried to solve this ODE in several ways without any succes.
In order to go further, I have installed the package sci-sundials.
Where did I go wrong ?
If somebody has the solution, it would be nice.
Remark :
with ic = [1;1] there is no problem and all methodes are working well (there is no singularity).
First way (classical one):
function dy = f(t, y)
dy(1) = y(2);
dy(2) = -y(1)*y(2);
endfunction
t = 0:0.01:10*%pi;
t0 = min(t);
y0 = [1; -1];
y = ode(y0, t0, t, f);
plot(t,y(1,:),'LineWidth',2);
Error message in the console : “ode: lsoda exit with state -1.”
Second way : with cvode:
function dy = f(t, y)
dy(1) = y(2);
dy(2) = - y(1)*y(2);
endfunction
t = 0:0.01:10;
t0 = min(t);
tf = max(t);
y0 = [1;-1];
[t,y] = cvode(f,[t0 tf],y0)
plot(t,y(1,:),'LineWidth',2)
In this case, there is no error and the plot displays something …which is very strange (due to a singularity at t = 4.7114)
Third way : with arkode
function dy = f(t, y)
dy = [y(2);- y(1)*y(2)]
endfunction
t = 0:0.01:4;
t0 = min(t);
tf = max(t);
y0 = [1;-1];
[t,y] = arkode(f,[t0 tf],y0)
This solution works fine only if I avoid the singularity.
The plot from t = 0 to 4:
This equation solved very easily with MAPLE gives the following plot: