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

euler_heun

Euler-Heun ODE Solver


Description

Euler and Euler-Heun ODE solver.

Usage

euler_heun(f, a, b, y0, n = 100, improved = TRUE, ...)

Arguments

f

function in the differential equation y' = f(x, y).

a, b

start and end points of the interval.

y0

starting value at a.

n

number of grid points.

improved

logical; shall the Heun method be used; default TRUE.

...

additional parameters to be passed to the function.

Details

euler_heun is an integration method for ordinary differential equations using the simple Euler resp. the improved Euler-Heun Method.

Value

List with components t for grid (or ‘time’) points, and y the vector of predicted values at those grid points.

References

Quarteroni, A., and F. Saleri (). Scientific Computing with MATLAB and Octave. Second Edition, Springer-Verlag, Berlin Heidelberg, 2006.

See Also

Examples

##  Flame-up process
f <- function(x, y) y^2 - y^3
s1 <- cranknic(f, 0, 200, 0.01)
s2 <- euler_heun(f, 0, 200, 0.01)
## Not run: 
plot(s1$t, s1$y, type="l", col="blue")
lines(s2$t, s2$y, col="red")
grid()
## End(Not run)

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

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