Anonymous user
Euler method: Difference between revisions
m
→version 2: changed a comment, changed or added whitespace, used a more idiomatic method for setting the numeric digits.
m (→version 2: used a template for the output section.) |
m (→version 2: changed a comment, changed or added whitespace, used a more idiomatic method for setting the numeric digits.) |
||
Line 2,618:
===version 2===
This REXX version allows values to be specified via the command line (CL).
<br>It also shows the percentage difference (analytic vs. Euler's method) for each calculation.
<lang rexx>/*REXX pgm solves example of Newton's cooling law via Euler's method (diff. step sizes).*/
numeric digits length( e() -
parse arg Ti Tr cc tt ss /*obtain optional arguments from the CL*/
if Ti
if Tr
if cc
if tt
if ss
@= '═' /*the character used in title separator*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
e: return 2.718281828459045235360287471352662497757247093699959574966967627724076630353548
/*──────────────────────────────────────────────────────────────────────────────────────*/
exp: procedure; parse arg x;
_=1; w=1; do j=1; _= _*x/j;
if z\==0 then z= e()**ix * z;
{{out|output|text= when using the default inputs:}}
<pre>
|