Golden ratio/Convergence: Difference between revisions
Content added Content deleted
Basicgames (talk | contribs) |
|||
Line 261: | Line 261: | ||
<pre>Result: 1.618033 after 14 iterations |
<pre>Result: 1.618033 after 14 iterations |
||
The error is approximately -1.201865E-06</pre> |
The error is approximately -1.201865E-06</pre> |
||
==={{header|Craft Basic}}=== |
|||
<syntaxhighlight lang="basic">precision 6 |
|||
define i = 0, d = 0, phi0 = 1, phi1 = 0 |
|||
do |
|||
let phi1 = 1 / phi0 + 1 |
|||
let d = abs(phi1 - phi0) |
|||
let phi0 = phi1 |
|||
let i = i + 1 |
|||
wait |
|||
loopuntil .00001 > d |
|||
print "result: ", phi1, " after ", i, " iterations" |
|||
print "the error is approximately ", phi1 - (.5 * (1 + sqrt(5))) |
|||
end</syntaxhighlight> |
|||
==={{header|FreeBASIC}}=== |
==={{header|FreeBASIC}}=== |