Golden ratio/Convergence: Difference between revisions

added comments to ooRexx code (cf. REXX)
(→‎{{header|ooRexx}}: added ooRexx code)
(added comments to ooRexx code (cf. REXX))
Line 1,177:
=={{header|ooRexx}}==
<syntaxhighlight lang="oorexx">/* REXX
* Compute the Golden Ratio using recursioniteration
* 20230604 Walter Pachl
*/
Line 1,183:
Parse Value '1 1 1e-5' With oldPhi phi limit
Do iterations=1 By 1 Until delta<=limit
phi=1+1/oldPhi /* next approximation */
delta=abs(phi-oldPhi) /* difference to previous */
If delta>limit Then /* not small enough */
oldPhi=phi /* proceed with new value */
End
actualPhi=(1+rxCalcsqrt(5,16))/2 /* compute the real value */
Say 'Final value of phi : ' phi /* our approximation */
Say 'Actual value : ' actualPhi /* the real value */
Say 'Error (approx) :' (phi-actualPhi) /* the difference */
Say 'Number of iterations:' iterations
Exit
::REQUIRES RXMATH library
</syntaxhighlight>
2,289

edits