Euler method: Difference between revisions
Content added Content deleted
m (→version 2: changed comments and whitespace.) |
m (→version 2: simplified the REXX program, added more precision.) |
||
Line 2,684: | Line 2,684: | ||
<br>It also shows the percentage difference (analytic vs. Euler's method) for each calculation. |
<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).*/ |
<lang rexx>/*REXX pgm solves example of Newton's cooling law via Euler's method (diff. step sizes).*/ |
||
e=2.718281828459045235360287471352662497757247093699959574966967627724076630353547595 |
|||
numeric digits length( |
numeric digits length(e) - length(.) /*use the number of decimal digits in E*/ |
||
parse arg Ti Tr cc tt ss /*obtain optional arguments from the CL*/ |
parse arg Ti Tr cc tt ss /*obtain optional arguments from the CL*/ |
||
if Ti='' | Ti="," then Ti= 100 /*given? Default: initial temp in ºC.*/ |
if Ti='' | Ti="," then Ti= 100 /*given? Default: initial temp in ºC.*/ |
||
Line 2,704: | Line 2,705: | ||
exit /*stick a fork in it, we're all done. */ |
exit /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
⚫ | |||
e: return 2.718281828459045235360287471352662497757247093699959574966967627724076630353548 |
|||
⚫ | |||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
{{out|output|text= when using the default inputs:}} |
{{out|output|text= when using the default inputs:}} |
||
<pre> |
<pre> |