This is a package to return discretized differential operators subject to various boundary conditions. It is intended to be a "simple" stopgap as more advanced implementations (e.g. DiffEqOperators.jl ) mature. This package is also not intended to provide a "higher-level" interface for constructing the equations. See EconPDEs.jl for a package intended to make translation of the sorts of equations used in economics more direct.
Consider constructing the corresponding infinitesimal generator for the following stochastic differential equation:
with some constant μ
and σ >= 0
, and W_t
Brownian Motion subject, with reflecting barriers at x=0
and x=1
, i.e., v'(0) = v'(1) = 0
.
If the payoff is in state x
is f(x)
and ρ
is the discount rate, then the bellman equation for the expected present discounted value of payoffs fulfills
Written in operator form, define the differential operators
then the Bellman equation can be written as
This package provides components to discretize differential operators. To implement directly,
using SimpleDifferentialOperators, LinearAlgebra
f(x) = x^2
μ = -0.1 # constant negative drift
σ = 0.1
ρ = 0.05
M = 100 # size of interior nodes
x̄ = range(0.0, 1.0, length = (M+2)) # extended grid
x = interiornodes(x̄) # interior grid
# discretize L = ρ - μ D_x - σ^2 / 2 D_xx on the interior
# subject to reflecting barriers at 0 and 1
bc = (Reflecting(), Reflecting())
L_x = μ*L₁₋bc(x̄, bc) - σ^2 / 2 * L₂bc(x̄, bc)
L = I * ρ - L_x
## solve the value function on the interior
v = L \ f.(x)
To extrapolate the interior solution to the boundary, one can call extrapolatetoboundary
as follows:
v̄ = extrapolatetoboundary(x̄, v, bc)
To install, run ] add SimpleDifferentialOperators
on Julia 1.3+.
For more usage information, see the docs badge above.
Detailed derivations and more applications can be found here.
-
As a reminder, the package requires Julia 1.1 or later.
-
If you discover a bug in the code or math, please file an issue in this repo with the label "bug."
-
The same holds for feature requests, with the appropriate label.