I am using lsode to solve a simple ODE on Octave 2.1.72. The ode is: Solve: y''(t) + y(t) =0 such that: y(0)=3 & y(pi/2)=3
My code for this is:
-------- file f.m --------- function xdot = f (x, t) xdot = zeros (2,1);
xdot(1) = x(2); xdot(2) = -x(1); endfunction ---- end of f.m -----
-------- file ode.m --------- l = linspace (0, pi/2, 20);
y_min=[3;3]; psi = lsode( "f", y_min, l );
plot(l,psi(:,1));
---- end of ode.m -----
I am getting correct answer with this. But lsode requires y_min which is actually the value of x(1) and x(2) at t=0. I have the value of x(1) at t=0 and t=pi/2.(I got the value of x(2) at t=0 by solving this on Matlab and then solved this by adding y_min=[3;3]; here). How can I use the given boundary conditions so that I don't need the values of x(2) to solve the problem.