Learn R Programming

mcODE (version 1.1)

ODE.ADA: Monte Carlo ODE Solver of Akhtar et al

Description

Given g' = G(x, g) and g(x0) = g0 satisfying conditions for existence and uniqueness of solution, a Monte Carlo approximation to the solution is found. The method is essentially a rejection method.

Usage

ODE.ADA(G, initvalue, endpoint, X0 = 0, npoints = 1000, M, R, N = 1e+05)

Value

A list consisting of

x

a vector of length npoints, consisting of the x-coordinate of the solution.

y

a vector of length npoints, consisting of the y-coordinate of the solution, i.e. g(x).

Arguments

G

a function having two numeric vector arguments.

initvalue

a numeric initial value

endpoint

a numeric interval endpoint value.

X0

a numeric interval starting point value.

npoints

an integer value specifying the number of subintervals to build the approximation on.

M

a numeric value specifying an upper bound for F(x, g).

R

a numeric value specifying a lower bound for F(x, g).

N

an integer value specifying the number of Monte Carlo simulations used for each subinterval.

References

Akhtar, M. N., Durad, M. H., and Ahmed, A. (2015). Solving initial value ordinary differential equations by Monte Carlo method. Proc. IAM, 4:149-174.

Examples

Run this code
G <- function(x, g) {
    -1000*g + sin(x)
}
gTrue <- function(x) (1000*sin(x) - cos(x))/1000001 
xF <- 1; x0 <- 0
g0 <- -1/1000001  # initial value
NAkhtar <- 800
nAkhtar <- 2500
MAkhtar <- 1e-3
RAkhtar <- 1e-6
gAkhtar <- ODE.ADA(G, initvalue = g0, endpoint = xF, X0 = x0, 
    npoints = nAkhtar, M=MAkhtar, R = RAkhtar, N = NAkhtar)
plot(gAkhtar, type = "l")

Run the code above in your browser using DataLab