# runge-kutta-4

> The fourth order Runge-Kutta integration method.

Latest version **1.0.5** (published 2016-07-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install runge-kutta-4
pnpm add runge-kutta-4
yarn add runge-kutta-4
bun add runge-kutta-4
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2016-07-27 |
| First published | 2016-07-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ou.Yancey |
| Maintainers | ou.yancey |
| Keywords | RK4, RungeKutta, Runge-Kutta method, integration, differential-equations |

## Links

- npm: https://www.npmjs.com/package/runge-kutta-4
- Repository: https://github.com/OuYancey/runge-kutta-4
- Homepage: https://github.com/OuYancey/runge-kutta-4#readme
- Issues: https://github.com/OuYancey/runge-kutta-4/issues
- npm.io page: https://npm.io/package/runge-kutta-4

## Recent versions

- 1.0.5 (latest) — 2016-07-27
- 1.0.3 — 2016-07-26
- 1.0.1 — 2016-07-25
- 1.0.0 — 2016-07-25

## README

# runge-kutta-4

> The fourth order Runge-Kutta integration method.

## Introduction

Wikipedia: [Runge–Kutta methods](https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods)

## Installation

Normal way:
```javascript
<!-- use the min file -->
<script src="[path]/dist/runge-kutta-4.min.js"></script>
```

Easy with npm:
```bash
$ npm install runge-kutta-4
```

## Examples

- use CommonJS
```javascript
var RungeKutta4 = require('runge-kutta-4')

/**
 * this is the target differential equations
 * @param  {Array}   y     It is an unknown function of x which we would like to approximate
 * @param  {Number}  x     x
 * @return {Array}   dydx  The rate at which y changes, is a function of x and of y
 */
var derives = function(x, y) {
    // you need to return the integration
    var dydx = []

    dydx[0] = y[0] + y[1]
    dydx[1] = 2 * y[1] + y[2]
    dydx[2] = 3 * y[2]

    return dydx
}

var xStart = 0,
    yStart = [1, 5, 10],
    h = 0.0001

var rk4 = new RungeKutta4(derives, xStart, yStart, h)

console.log(rk4.step())
// [ 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
```

---
_Source: https://npm.io/package/runge-kutta-4 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
