runge.kutta | R Documentation |
runge.kutta
numerically solves a differential equation by the
fourth-order Runge-Kutta method.
runge.kutta(f, initial, x)
f |
A function |
initial |
The initial value of |
x |
A vector of values of |
A vector of values of y
as solution of the function f
corresponding to the values in x
.
J.K. Lindsey
fn <- function(y,x) (x*y-y^2)/x^2 soln <- runge.kutta(fn,2,seq(1,3,by=1/128)) ## exact solution exact <- seq(1,3,by=1/128)/(0.5+log(seq(1,3,by=1/128))) rbind(soln, exact)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.