I have implemented a finite difference scheme for pricing options using a Black-Scholes-like model. I tested my implementation on a call option, and found that it gave extremely inaccurate results. I investigated intermediate values in my computations, and I suspect that my inaccurate results are caused by the discontinuity in the payoff function.
The payoff function:
$$\text{Payoff}(S) = \max(S-K, 0) \hspace{.4em} \text{for some strike price } K \text{.} $$
My scheme requires that I calculate $\frac{\partial{U}}{\partial{S}}$ and $\frac{\partial^2{U}}{\partial{S}^2}$ at two points near $K$. At these points, $rs\frac{\partial{U}}{\partial{S}}$ causes a minor issue, but $\frac{1}{2}s^2v\frac{\partial^2{U}}{\partial{S}^2}$ explodes when I use a first order central approximation.
What kinds of solutions exist for this problem? I'm trying to keep my derivative matrix $A$ (meaning $U' = A U+x$) "oblivious" to the type of derivative (or, in the case of a call option, the strike price) for simplicity of implementation. "Hack"-ish solutions are very welcome.
An example: I set the strike to K=110. Three nearby asset prices are 107.336, 109.983, and 112.732. If you compute first order central approximations at the point 109.983, you get
\begin{align} \frac{1}{2}s^2v\frac{\partial^2{U}}{\partial{S}^2} &= \frac{1}{2}(109.983^2)*v*\Big( 0.140*0 + (-0.274) * 0 + 0.134858*(112.732-110) \Big) \\ &=2,228.32*v \end{align}
At all other points, for the first time step, $\frac{\partial^2{U}}{\partial{S}^2}=0$.