Anonymous user
Euler method: Difference between revisions
→{{header|Lua}}
m (→{{header|J}}: typo) |
|||
Line 881:
end
</lang>
=={{header|Mathematica}}==
Better methods for differential equation solving are built into Mathematica, so the typical user would omit the Method and StartingStepSize options in the code below. However since the task requests Eulers method, here is the bad solution...
<lang Mathematica>
euler[step_, val_] := NDSolve[{T'[t] == -0.07 (T[t] - 20), T[0] == 100}, T, {t, 0, 100}, Method -> "ExplicitEuler", StartingStepSize -> step][[1, 1, 2]][val]
</lang>
{{out}}
<pre>euler[2, 100]
20.0425
euler[5, 100]
20.0145
euler[10, 100]
20.0005</pre>
=={{header|Perl}}==
|