Runge-Kutta method: Difference between revisions
Content deleted Content added
Runge-Kutta method in various BASIC dialents (QBasic and True BASIC) |
|||
Line 1,254: | Line 1,254: | ||
=={{header|FutureBasic}}== |
=={{header|FutureBasic}}== |
||
<lang futurebasic> |
<lang futurebasic>window 1 |
||
include "ConsoleWindow" |
|||
⚫ | |||
def tab 9 |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end fn = x * sqr(y) |
|||
⚫ | |||
end fn = ( x ^2 + 4 ) ^2 / 16 |
|||
⚫ | |||
⚫ | |||
h = 0.1 |
h = 0.1 |
||
y = 1 |
y = 1 |
||
for i = 0 to 100 |
for i = 0 to 100 |
||
x = i * h |
x = i * h |
||
if x == int(x) |
if x == int(x) |
||
result = fn exactY( x ) |
result = fn exactY( x ) |
||
print "y("; mid$( str$(x), 2, len(str$(x) )); ") = "; y, "Error = "; result - y |
print "y("; mid$( str$(x), 2, len$(str$(x) )); ") = "; y, "Error = "; result - y |
||
end if |
end if |
||
k1 = h * fn dydx( x, y ) |
k1 = h * fn dydx( x, y ) |
||
k2 = h * fn dydx( x + h / 2, y + k1 / 2 ) |
k2 = h * fn dydx( x + h / 2, y + k1 / 2 ) |
||
k3 = h * fn dydx( x + h / 2, y + k2 / 2 ) |
k3 = h * fn dydx( x + h / 2, y + k2 / 2 ) |
||
k4 = h * fn dydx( x + h, y + k3 ) |
k4 = h * fn dydx( x + h, y + k3 ) |
||
⚫ | |||
⚫ | |||
HandleEvents</lang> |
|||
⚫ | |||
⚫ | |||
</lang> |
|||
Output: |
Output: |
||
<pre> |
<pre> |