Euler method: Difference between revisions
Content added Content deleted
(Added Wren) |
m (→{{header|Mathematica}} / {{header|Wolfram Language}}: formatting) |
||
Line 1,733: | Line 1,733: | ||
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... |
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> |
<lang Mathematica> |
||
euler[step_, val_] := NDSolve[ |
|||
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] |
|||
{T'[t] == -0.07 (T[t] - 20), T[0] == 100}, |
|||
T, {t, 0, 100}, |
|||
Method -> "ExplicitEuler", |
|||
StartingStepSize -> step |
|||
][[1, 1, 2]][val] |
|||
</lang> |
</lang> |
||
{{out}} |
{{out}} |