Maxima file for explicit finite difference expressions.
Maxima file for implicit or compact finite difference expressions.
Usage is just:
load("explicit_fde.mac");
foo : explicit_fde([-1,0,1],1);
which would put a central difference expression for the first derivative into
foo
. The first argument is a list representing the stencil to use, the second argument is the derivative you want to estimate.The implicit expressions are similar:
load("implicit_fde.mac");
foo : implicit_fde([-1,0,1],1,1);
The extra argument is so that you don't get the trivial solution back (see this post for details). Also, the return value for the implicit expression is the augmented coefficient matrix for the first derivative. That means the last column is the explicit side of the expression (terms involving the function value), and the first
n
columns are the coefficients for the first derivative at the stencil points.Thanks to the helpful folks on the Maxima List for fixing some of my mistakes and giving me some good debugging tips.
No comments:
Post a Comment