Euler method: Difference between revisions

add RPL
(add RPL)
Line 3,395:
10 57.634
</pre>
 
=={{header|RPL}}==
This is a typical task for which RPL was designed.
(t<sub>n</sub>,y<sub>n</sub>) are handled as complex numbers. This makes the iterations easier to calculate and facilitates the eventual display of the resulting curve, as RPL uses this data format to designate the pixels.
≪ → t temp '-'''K'''*(temp-'''TR''')' ≫ ‘'''F'''’ STO
≪ → h fn
≪ 1 10 '''START'''
DUP h OVER C→R fn EVAL h * R→C +
'''NEXT''' 10 →LIST
≫ ≫ ‘'''EULER'''’ STO
0.07 ''''K'''' STO 20 ''''TR'''' STO
 
(0,100) 2 ''''F'''' '''EULER'''
{{out}}
<pre>
1: { (2,88.8) (4,79.168) (6,70.88448) (8,63.7606528) (10,57.634161408) (12,52.3653788109) (14,47.8342257774) (16,43.9374341685) (18,40.5861933849) (20,37.704126311) }
</pre>
===Analytical solution===
≪ { } 2 20 '''FOR''' t t ''''TR'''+(100-'''TR''')*EXP(-'''K'''*t)' EVAL R→C + '''NEXT''' ≫
{{out}}
<pre>
1: { (2,89.5486588319) (3,84.8467396776) (4,80.4626993165) (5,76.3750471775) (6,72.5637455852) (7,69.0101115348) (8,65.6967251079) (9,62.6073440806) (10,59.7268243033) (11,57.0410454649) (12,54.5368418743) (13,52.2019379227) (14,50.0248879081) (15,47.9950199289) (16,46.1023835698) (17,44.3377011253) (18,42.69232212) (19,41.158180904) (20,39.7277571153) }
</pre>
Accuracy to the degree for the first seconds of cooling needs h to be set at 0.2 s or below
 
=={{header|Ruby}}==
1,150

edits