Last updated: 2023-03-16.
tf_quant_finance.math.pde.steppers.weighted_implicit_explicit.weighted_implicit_explicit_scheme#
Constructs weighted implicit-explicit scheme.
tf_quant_finance.math.pde.steppers.weighted_implicit_explicit.weighted_implicit_explicit_scheme(
theta
)
Approximates the space-discretized equation of du/dt = A(t) u(t) + b(t) as
(u(t2) - u(t1)) / (t2 - t1) = theta * (A u(t1) + b)
+ (1 - theta) (A u(t2) + b),
where A = A((t1 + t2)/2), b = b((t1 + t2)/2), and theta is a float
between 0 and 1.
Note that typically A and b are evaluated at t1 and t2 in
the explicit and implicit terms respectively (the two terms of the right-hand
side). Instead, we evaluate them at the midpoint (t1 + t2)/2, which saves
some computation. One can check that evaluating at midpoint doesn’t change the
order of accuracy of the scheme: it is still second order accurate in
t2 - t1 if theta = 0.5 and first order accurate otherwise.
The solution is the following:
u(t2) = (1 - (1 - theta) dt A)^(-1) * (1 + theta dt A) u(t1) + dt b.
The main bottleneck here is inverting the matrix (1 - (1 - theta) dt A).
This matrix is tridiagonal (each point is influenced by the two neighbouring
points), and thus the inversion can be efficiently performed using
tf.linalg.tridiagonal_solve.
References:#
[1] I.V. Puzynin, A.V. Selin, S.I. Vinitsky, A high-order accuracy method for numerical solving of the time-dependent Schrodinger equation, Comput. Phys. Commun. 123 (1999), 1. https://www.sciencedirect.com/science/article/pii/S0010465599002246
Args:#
theta: A float in range[0, 1]. A parameter used to mix implicit and explicit schemes together. Value of0.0corresponds to the fully implicit scheme,1.0to the fully explicit, and0.5to the Crank-Nicolson scheme.
Returns:#
A callable that consumes the following arguments by keyword:
value_grid: Grid of values at time
t1, i.e.u(t1).t1: Time before the step.
t2: Time after the step.
equation_params_fn: A callable that takes a scalar
Tensorargument representing time, and constructs the tridiagonal matrixA(a tuple of threeTensors, main, upper, and lower diagonals) and the inhomogeneous termb. All of theTensors are of the samedtypeasvalue_gridand of the shape broadcastable with the shape ofvalue_grid. The callable returns aTensorof the same shape anddtypeasvalue_gridand represents an approximate solutionu(t2).