Skip to content
All library documents

Diagnosing Finite-Difference Errors in a Two-Factor PDE

Article Quant Q&A · Author: Pim

Summary

The document discusses troubleshooting an implicit finite-difference implementation for a two-factor pricing PDE with correlated state variables. The reported symptoms include negative values and failures of expected monotonicity, which may arise even when boundary conditions and the discretization appear reasonable. The response points to checking boundary conditions and how the unbounded state space is truncated, and suggests transforming variables to improve the numerical balance of the operator. For the lognormal SABR case, it gives logarithms of the forward and volatility as an example of such a transformation.

It also emphasizes grid resolution and the computational cost of directly inverting the coupled two-dimensional system. Alternating direction implicit methods are offered as a practical alternative. These are troubleshooting pointers rather than a full derivation or diagnosis: the document does not provide the implementation, establish which issue caused the reported behavior, or demonstrate convergence. Its claim about matrix stability alone should not be treated as proof that the solution is accurate or monotone.

Key ideas

  • Variable transformations can improve the scaling of a finite-difference operator.
  • Boundary conditions and spatial-domain truncation both affect numerical results.
  • A coupled two-dimensional discretization produces a costly system to invert directly.
  • Alternating direction implicit methods can reduce the computational burden.
  • Grid resolution should be checked, but the document does not establish a universal minimum.

Tags

Full text
# Unable to obtain correct Finite Difference Results


# Unable to obtain correct Finite Difference Results












A rather general question regarding a specific problem I am facing with my Matlab implementation of the implicit FD method for this PDE:

\begin{equation} \frac{\sigma_s^2}{2}\frac{\partial^2 V}{\partial S^2} + \rho(t) \sigma_S \sigma_\alpha\frac{\partial^2 V}{\partial S \partial \alpha} + \frac{\sigma_\alpha^2}{2}\frac{\partial^2 V}{\partial \alpha^2} + \mu_s \frac{\partial V}{\partial S} + \mu_\alpha \frac{\partial V}{\partial \alpha} + \frac{\partial V}{\partial t} - r(t)V \end{equation}

When running my code, I obtain negative and non-monotonic-increasing values. However, they should be all positive and monotonic-increasing throughout the two-dimensions of the grid ($F$ and $\alpha$). I checked my boundary conditions again and again but they seem fine to me. Same holds for FD discretization of the PDE.

My question is, what could be the cause of my problem?

For example,

- Is there a possibility that FD formula and boundary conditions are correct, but that a particular choice of step sizes is ruining the method?

- How can I know if the problem is coding-related or that, for example, my FD matrix (A) is misspecified?

- Am I correct that FD matrix A is not dependent on time, hence can be calculated outside the FD loop?

A more detailed version of my question is given here

Edit June 7: Extended the code to handle larger grids. Applied variable transformation to both F and vol (alpha) similar to here formula (2.16). (Obviously, the upper bound on F/x changed accordingly to account for transformation from F to x). I now obtain 'nicer' results, in the sense that values are positive and for large part of the grid monotonic-increasing. However, when $\beta=1$ and $\nu=0$, I do not obtain similar results as BS. Also, for the lower part of the $V$ matrix (upper part F/x domain), values are no longer monotonic increasing (along $\alpha$/column-dimension), see left down corner V matrix (near $F_{max}$ and $\alpha_{min}$) and right down corner V matrix (near $F_{max}$ and $\alpha_{max}$). $A$ does seem to satisfy the stability constraint: $||A^{−1}||_{\infty} = 1 \leq 1$. I have noted that the diagonals of $A$ tend to increase rapidly suddenly (to an order of magnitude +04) and then decrease, after it increases again, etc (example). Is this how $A$ would normally behave (after variable transformation)?

## Answer by Antoine Conze (score 2, accepted)

https://quant.stackexchange.com/a/40177

a few pointers:

- did you use appropriate boundary conditions ?

- how did you truncate the space domain ? in particular it is common to first do a change of variable to get a better behaved $A$ matrix with all terms roughly of the same size. For instance in the "log normal" SABR case ($\beta=1$) it would be appropriate to work in $(x, y) \in ]-\infty, +\infty[ \times ]-\infty, +\infty[$ space with $x = \ln(F/F_0)$ and $y = \ln(\alpha/\alpha_0)$, and to truncate the space domain to $[-b_x, +b_x] \times [-b_y, +b_y]$ with appropriate bounds $b_x$ and $b_y$.

- how many grid points in each direction did you use ? For practical purpose a $50 \times 50$ discretization would be a minimum.

Also from a practical standpoint since the state space is 2 dimensional the matrix $A$ is not tridiagonal and thus very costly to invert. This is why ADI (alternate direction implicit for which you will find plenty of references) are preferred.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.