Anonymous user
Euler method: Difference between revisions
m
→version 2: increased the decimal digits precision and its changes to the output.
m (→version 2: simplified the REXX program, added more precision.) |
m (→version 2: increased the decimal digits precision and its changes to the output.) |
||
Line 2,684:
<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).*/
e=2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138
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*/
Line 2,713:
══seconds══ ══Euler method══ ═════analytic═════ ══difference══
0 100.000 ºC 100.000000000 ºC 0.00 %
2 88.800 ºC 89.
4 79.168 ºC 80.
6 70.884 ºC 72.
8 63.761 ºC 65.
10 57.634 ºC 59.
12 52.365 ºC 54.
14 47.834 ºC 50.
16 43.937 ºC 46.
18 40.586 ºC 42.692322120 ºC 4.93 %
20 37.704 ºC 39.
22 35.226 ºC 37.
24 33.094 ºC 34.
26 31.261 ºC 32.
28 29.684 ºC 31.
30 28.328 ºC 29.796514260 ºC 4.93 %
32 27.163 ºC 28.516680350 ºC 4.75 %
34 26.160 ºC 27.
36 25.297 ºC 26.436768540 ºC 4.31 %
38 24.556 ºC 25.595857740 ºC 4.06 %
40 23.918 ºC 24.864805010 ºC 3.81 %
42 23.369 ºC 24.
44 22.898 ºC 23.
46 22.492 ºC 23.
48 22.143 ºC 22.
50 21.843 ºC 22.
52 21.585 ºC 22.
54 21.363 ºC 21.
56 21.172 ºC 21.587287580 ºC 1.92 %
58 21.008 ºC 21.
60 20.867 ºC 21.
62 20.746 ºC 21.
64 20.641 ºC 20.
66 20.551 ºC 20.
68 20.474 ºC 20.
70 20.408 ºC 20.
72 20.351 ºC 20.
74 20.302 ºC 20.
76 20.259 ºC 20.
78 20.223 ºC 20.340284460 ºC 0.58 %
80 20.192 ºC 20.
82 20.165 ºC 20.
84 20.142 ºC 20.
86 20.122 ºC 20.
88 20.105 ºC 20.
90 20.090 ºC 20.
92 20.078 ºC 20.
94 20.067 ºC 20.
96 20.057 ºC 20.
98 20.049 ºC 20.
100 20.042 ºC 20.
Line 2,768:
══seconds══ ══Euler method══ ═════analytic═════ ══difference══
0 100.000 ºC 100.000000000 ºC 0.00 %
5 72.000 ºC 76.
10 53.800 ºC 59.
15 41.970 ºC 47.
20 34.281 ºC 39.
25 29.282 ºC 33.
30 26.034 ºC 29.796514260 ºC 12.63 %
35 23.922 ºC 26.903486920 ºC 11.08 %
40 22.549 ºC 24.864805010 ºC 9.31 %
45 21.657 ºC 23.
50 21.077 ºC 22.
55 20.700 ºC 21.
60 20.455 ºC 21.
65 20.296 ºC 20.
70 20.192 ºC 20.
75 20.125 ºC 20.
80 20.081 ºC 20.
85 20.053 ºC 20.
90 20.034 ºC 20.
95 20.022 ºC 20.
100 20.014 ºC 20.
Line 2,793:
══seconds══ ══Euler method══ ═════analytic═════ ══difference══
0 100.000 ºC 100.000000000 ºC 0.00 %
10 44.000 ºC 59.
20 27.200 ºC 39.
30 22.160 ºC 29.796514260 ºC 25.63 %
40 20.648 ºC 24.864805010 ºC 16.96 %
50 20.194 ºC 22.
60 20.058 ºC 21.
70 20.017 ºC 20.
80 20.005 ºC 20.
90 20.002 ºC 20.
</pre>
|