Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

runge.kutta

Runge-Kutta Method for Solving Differential Equations


Description

runge.kutta numerically solves a differential equation by the fourth-order Runge-Kutta method.

Usage

runge.kutta(f, initial, x)

Arguments

f

A function dy/dx=func(y,x).

initial

The initial value of y.

x

A vector of values of x for which the values or y are required.

Value

A vector of values of y as solution of the function f corresponding to the values in x.

Author(s)

J.K. Lindsey

Examples

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)

rmutil

Utilities for Nonlinear Regression and Repeated Measurements Models

v1.1.5
GPL-2
Authors
Bruce Swihart [cre, aut], Jim Lindsey [aut] (Jim created this package, Bruce is maintaining the CRAN version)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.