runge-kutta-4
The fourth order Runge-Kutta integration method.
Introduction
Wikipedia: Runge–Kutta methods
Installation
Normal way:
<!-- use the min file --><script src="[path]/dist/runge-kutta-4.min.js"></script>
Easy with npm:
$ npm install runge-kutta-4
Examples
- use CommonJS
var RungeKutta4 = /** * this is the target differential equations * @param * @param * @return */var { // you need to return the integration var dydx = dydx0 = y0 + y1 dydx1 = 2 * y1 + y2 dydx2 = 3 * y2 return dydx} var xStart = 0 yStart = 1 5 10 h = 00001 var rk4 = derives xStart yStart h console// [ 1.0006001300160015, 5.002000350038337, 10.003000450045004 ] // console.log(rk4.steps(100))// [ 1.0613161367179729, 5.2035386394013905, 10.304545339535162 ] // console.log(rk4.end(0.01))// [ 1.0613161367179729, 5.2035386394013905, 10.304545339535162 ]// same as steps(100), because steps = xEnd / h