16 lines
526 B
Text
16 lines
526 B
Text
constant dt = 0.1
|
|
atom y = 1.0
|
|
printf(1," x true/actual y calculated y relative error\n")
|
|
printf(1," --- ------------- ------------- --------------\n")
|
|
for i=0 to 100 do
|
|
atom t = i*dt
|
|
if integer(t) then
|
|
atom act = power(t*t+4,2)/16
|
|
printf(1,"%4.1f %14.9f %14.9f %.9e\n",{t,act,y,abs(y-act)})
|
|
end if
|
|
atom k1 = t*sqrt(y),
|
|
k2 = (t+dt/2)*sqrt(y+dt/2*k1),
|
|
k3 = (t+dt/2)*sqrt(y+dt/2*k2),
|
|
k4 = (t+dt)*sqrt(y+dt*k3)
|
|
y += dt*(k1+2*(k2+k3)+k4)/6
|
|
end for
|