Euler method: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Minor tidy) |
imported>2Paule No edit summary |
||
Line 3,913: | Line 3,913: | ||
90.000 20.002 |
90.000 20.002 |
||
done |
done |
||
</pre> |
|||
=={{header|Uiua}}== |
|||
'''Solution:''' |
|||
<syntaxhighlight lang="Uiua"> |
|||
"Euler Solution" |
|||
T ← 100 # initial starting temp |
|||
TR ← 20 # room temp |
|||
TMINUSTR ← - TR T |
|||
h ← 10 # step size |
|||
k ← 0.07 # coefficent |
|||
TEND ← 100 # end time |
|||
n ← ÷ h 100 # steps |
|||
# inital starting point |
|||
T |
|||
. |
|||
# .. clone the top of stack and take if for next step |
|||
# repeat the steps n times with ⍥ |
|||
Solution ← [⍥(.. - × h × k - TR)]+ n 1 |
|||
⇌ ⊂ Solution T |
|||
# analytical solution |
|||
"Analytical Solution" |
|||
# apply function to LIST |
|||
List ← × k × h ⇡n |
|||
# Analytical solution applied |
|||
+ TR × TMINUSTR ⁿ ¯List e |
|||
</syntaxhighlight> |
|||
'''Example:''' |
|||
<pre> |
|||
"Euler Solution" |
|||
[100 43.99999999999999 27.199999999999996 22.159999999999997 20.648 20.194399999999998 20.05832 20.017496 20.0052488 20.00157464 20.000472392 20.0001417176 20.0001417176 20.0001417176] |
|||
"Analytical Solution" |
|||
[100 59.72682430331276 39.727757115328515 29.796514260238553 24.864805010017434 22.41579067378548 21.199646145638216 20.59572664567395 20.295829097318634 20.14690438216231] |
|||
</pre> |
</pre> |
||