Runge-Kutta method: Difference between revisions
Content deleted Content added
Added BBC BASIC |
|||
Line 85:
y(9.0) = 451.56245928 Error: 4.07232E-05
y(10.0) = 675.99994902 Error: 5.09833E-05</pre>
==={{header|BBC BASIC}}===
<lang bbcbasic> y = 1.0
FOR i% = 0 TO 100
t = i% / 10
IF t = INT(t) THEN
actual = ((t^2 + 4)^2) / 16
PRINT "y("; t ") = "; y TAB(20) "Error = "; actual - y
ENDIF
k1 = t * SQR(y)
k2 = (t + 0.05) * SQR(y + 0.05 * k1)
k3 = (t + 0.05) * SQR(y + 0.05 * k2)
k4 = (t + 0.10) * SQR(y + 0.10 * k3)
y += 0.1 * (k1 + 2 * (k2 + k3) + k4) / 6
NEXT i%</lang>
'''Output:'''
<pre>y(0) = 1 Error = 0
y(1) = 1.56249985 Error = 1.45721892E-7
y(2) = 3.99999908 Error = 9.19479201E-7
y(3) = 10.5624971 Error = 2.90956245E-6
y(4) = 24.9999938 Error = 6.23490936E-6
y(5) = 52.5624892 Error = 1.08196974E-5
y(6) = 99.9999834 Error = 1.65945964E-5
y(7) = 175.562476 Error = 2.35177287E-5
y(8) = 288.999968 Error = 3.15652015E-5
y(9) = 451.562459 Error = 4.07231605E-5
y(10) = 675.999949 Error = 5.09832905E-5
</pre>
=={{header|C}}==
|