So I have this analytically unsolvable non-linear second order differential equation:
x''=(-1/x)((x')²+gx-gh+ax')
to which I've been trying to apply the Runge-Kutta method in Octave for a while without getting good results. This is the code I've been using:
graphics_toolkit('gnuplot')
to=0
tf=2.8
N=150
dt=[tf-to]/N
b=2.65
g=9.81
h=0.07
y(1)=0.015
z(1)=0
t(1)=to
for i=1:N-1
y(i+1)= y(i) - dt.*z(i)
z(i+1)= z(i) - dt.*[z(i).**2 + g.*y(i) - g.*h + b.*z(i)]./y(i)
t(i+1)= t(i) + dt
endfor
plot(y,t)
title=('Numerical solution')
xlabel=('Time')
ylabel=('Position')
Frankly, I'm unable to tell where the issue is, maybe there's something about the method I'm not getting, or maybe is my code missing something important.
Thanks for your time and attention.