R: deSolve - partial differential equation

Viewed 546

Could somebody help me with the R package deSolve/ReacTran, which can be used for solving any parabolic partial differential equation:

PDE for bond pricing, from Cox-Ingresoll-Ross model

I have found a similar example in the book Karline Soetaert, Jeff_Cash, Francesca Mazzia: Solving Partial Differential Equations in R, chapter 9, page 179-181, where is a solution for the equation:

The Nonlinear Schrodinger Equation

Online version of book: Solving Partial Differential Equations in R

The PDE and the solution is defined like:

Schrodinger <- function(t, u, parms) {
du <- 1i * tran.1D (C = u, D = 1, dx = xgrid)$dC +
1i * gam * abs(u)ˆ2 * u
list(du) }

N <- 300
xgrid <- setup.grid.1D(-20, 80, N = N)
x <- xgrid$x.mid

out <- ode.1D(y = yini, parms = NULL, func = Schrodinger,
times = times, dimens = 300, method = "adams")

There's an example of the second partial derivative:

tran.1D (C = u, D = 1, dx = xgrid)$dC

but I'm not sure how to define the first partial derivatives in the PDE and for derivatives by r_e and r_d (more 'xgrid', or ?)

Thank you in advance for any help.

0 Answers
Related