Finite Differencing Methods (Method 1): Explicit Forward Differences
Approximation to = f(y)
If all the time steps are the same size, Δt, then use the short-hand = y(n × Δt)
Approximate f(y) with f(); then solving the finite difference equation above,
=
+ Δt f(
): the right-hand side depends only on
, and therefore we can apply a recursion method to find any
PushMethod1 takes an arbitrary f for the right-hand-side, the current point and the size of the time step Δt
Here is an example right-hand-side function:
Applying it once "pushes" the current point (the second argument) forward one increment in time.
Applying it twice "pushes" the current point (the second argument) forward two increments in time. We have "nested" one function call inside the other.
Nest is a useful function for these kinds of operatons: Nest[g,x,3] is g[g[g[x]]]. However, in our case, PushMethod1 takes three arguments, we need to use a Pure Function methods to specify that the PushMethod1 operates only on the point represented by the second argument. This should provide a useful example of what Nest does: # plays the role of the functions argument and the & indicates that the function is to interpreted as a pure function.
We can use NestList to build up the trajectory,very similar to our method above that used AppendTo, but this is more efficient.
NestListWhile to build up the trajectory while a "test" evaluates to True. We have to use a pure function for the test, which operates on the current point (or the last point entered into the list).
Created by Wolfram Mathematica 6.0 (06 November 2007) | ![]() |