Jump to content

Euler method: Difference between revisions

m
(Added Wren)
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...
<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>
{{out}}
1,934

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.