In finite-difference methods, a differential operator \(D\) is used to transform a function \(f(x)\) into one of its derivatives, for instance \({f}'(x)\) or \({f}''(x)\). As differentiation is linear, so it can be written as a matrix while using linear algebra methods to solve it. As you know, FDM does not give the exact discretization of the derivative but an approximation, like \({f}'_{i}={f}'(x_{i})+\epsilon _{i}\), notice that the error decreases along with the decreasing of the spacing of the grid, say, the tighter the grids (including \(t\) axis and \(x\) axis), the better approximation quality, but the worse simulation duration.
As you might refer to Tylor’s polynomial, provide differential operators including the first and the second derivative to obtain a manageable approximation error, they can be defined as:
As seen from the equations that the value of the derivative at any given index \(i\) only determined by the adjacent three values of the function with the middle of the same index, thus the differential operator can be written as a tridiagonal matrix, like:
To save storage resources and avoid redundant computations, store the upper, main, and lower diagonals of the matrix in the \(dzMap\_\) of the pricing engine and compute it by Thomson algorithm while evolving back, instead of using a traditional matrix with a large number of zeros and many meaningless additions and multiplications in the pricing process.