I am currently trying to get the Runge Kutta 4 Integration to work, but it outputs the following:
Runge Kutta value: inf
While it is supposed to give a value in the range of:
Runge Kutta value: 8.476271005220534e+16
I used the following code, but can't seem to output the right approximation.
endtime = 5
h = 0.01
def f(x, z):
return x*x*z
t = 0
y = 1
while t < endtime:
k1 = f(t, y)
k2 = f(t+(h/2), y+(k1/2))
k3 = f(t+(h/2), y+(k2/2))
k4 = f(t+h, y+k3)
y = y + h*(k1 + 2*k2 + 2*k3 + k4)/6
t = t + h
print("Runge Kutta value: " + str(y))
Is there anyone who knows where I made the mistake