FdAmericanOption problem and Tracing

Posted by Joseph Wang on
URL: http://quantlib.414.s1.nabble.com/FdAmericanOption-problem-and-Tracing-tp3483.html

I've tried some numerical experiments, and I don't think that the
problem is easily fixable,
and that the focus should be to put in some checks to make sure that the
time steps are
such that the problem doesn't develop.

I think that the problem is an interaction between large time steps,
small space steps,
and boundary conditions.  If you have large time steps and small space
steps, the error
from the value of the point next to the boundary becomes large.  This
results in an
artificially large second derivative which then destroys the
simulation.  What I did to
convince myself this was the problem was to artifically set the problem
up so that it
is a pure diffusion problem and then run the simulation with different
differencing
methods.  In all cases, you see problems start to in the penultimate
point and then
spread to the middle.

Also something that I've seen that I think is interesting syntax is

#define TRACE(x)  if (turn_on_trace(x)) trace_ostream

This lets you write things like

TRACE(2) << "Trace statement";