[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Solving 2nd degree differntial equatation
From: |
Maverick |
Subject: |
Re: Solving 2nd degree differntial equatation |
Date: |
Fri, 3 Jun 2016 23:39:24 -0700 (PDT) |
Thanks for reply.
Yes, I've rewritten it like that/(f=@(x,t) [x(2);-k*sin(x(1))];/)
And initial condition x0=1, after rewritting it in the same manner will be
x0=[1;0]?
I know it works considerebly slower than build in function, but it's my
assigment to test both methods.
Could you take a look at Verlet method? I read it like 10 times and I see no
error but it doesn't converges to same point as lsode() or RK.
where:
x0 is initial condition
f is our function
T is argument for which we calculate x(T)
t0 is staring point
N is number of steps in method
k is our constant
/function x=Verlet(f,t0,T,x0,N,k,h=(T-t0)/N)
t=t0;
x=x0;
v=f(x,t);
for n=1:N
v=v-(h/2)*k*sin(x);
x=x+h*v;
v=v-(h/2)*k*sin(x);
end
endfunction /
--
View this message in context:
http://octave.1599824.n4.nabble.com/Solving-2nd-degree-differntial-equatation-tp4677408p4677429.html
Sent from the Octave - General mailing list archive at Nabble.com.
Re: Solving 2nd degree differntial equatation, Juan Pablo Carbajal, 2016/06/04