├── .editorconfig ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── README.mdtex ├── examples └── circle.js ├── gulpfile.js ├── images ├── begineqnarray-yt-ft-yt-yt_0-y_0-endeqnarray-0d72e38d4c.png ├── begineqnarray-yt-ft-yt-yt_0-y_0-endeqnarray-870096dfab.png ├── delta-t-9813ae7971.png ├── n-66e1b1ee17.png ├── t-3f19307093.png ├── y-adb83ba1d7.png ├── y_n1-y_n-ft_n-y_n-a622b96922.png ├── y_n1-y_n-ft_n-y_n-delta-t-7e1ddc48e6.png ├── yt-ft-yt-4304a0aa5e.png ├── yt-ft-yt-fae25965d3.png ├── yt-ft-yt-yt_0-y_0-309707f928.png ├── yt-ft-yt-yt_0-y_0-f7515619c6.png ├── yt_0-y_0-42d14f447f.png └── yt_0-y_0-d7b398c658.png ├── lib └── index.js ├── package.json └── test └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | 3 | # Logs 4 | logs 5 | *.log 6 | 7 | # Runtime data 8 | pids 9 | *.pid 10 | *.seed 11 | 12 | # Directory for instrumented libs generated by jscoverage/JSCover 13 | lib-cov 14 | 15 | # Coverage directory used by tools like istanbul 16 | coverage 17 | 18 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 19 | .grunt 20 | 21 | # Compiled binary addons (http://nodejs.org/api/addons.html) 22 | build/Release 23 | build 24 | 25 | # Dependency directory 26 | # Deployed apps should consider commenting this line out: 27 | # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git 28 | node_modules 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.12" 4 | - "0.11" 5 | - "0.10" 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Ricky Reusser 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ode-euler [](https://travis-ci.org/scijs/ode-euler) [](http://badge.fury.io/js/ode-euler) [](https://david-dm.org/scijs/ode-euler) 2 | 3 | > Integrate a system of ODEs using the Euler method 4 | 5 | 6 | ## Introduction 7 | 8 | This module integrates a system of ordinary differential equations of the form
'+img+'
' : img 32 | }) 33 | })) 34 | .pipe(texFilter.restore()).pipe(mdFilter) 35 | .pipe(gulp.dest('./')) 36 | }) 37 | -------------------------------------------------------------------------------- /images/begineqnarray-yt-ft-yt-yt_0-y_0-endeqnarray-0d72e38d4c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/begineqnarray-yt-ft-yt-yt_0-y_0-endeqnarray-0d72e38d4c.png -------------------------------------------------------------------------------- /images/begineqnarray-yt-ft-yt-yt_0-y_0-endeqnarray-870096dfab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/begineqnarray-yt-ft-yt-yt_0-y_0-endeqnarray-870096dfab.png -------------------------------------------------------------------------------- /images/delta-t-9813ae7971.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/delta-t-9813ae7971.png -------------------------------------------------------------------------------- /images/n-66e1b1ee17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/n-66e1b1ee17.png -------------------------------------------------------------------------------- /images/t-3f19307093.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/t-3f19307093.png -------------------------------------------------------------------------------- /images/y-adb83ba1d7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/y-adb83ba1d7.png -------------------------------------------------------------------------------- /images/y_n1-y_n-ft_n-y_n-a622b96922.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/y_n1-y_n-ft_n-y_n-a622b96922.png -------------------------------------------------------------------------------- /images/y_n1-y_n-ft_n-y_n-delta-t-7e1ddc48e6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/y_n1-y_n-ft_n-y_n-delta-t-7e1ddc48e6.png -------------------------------------------------------------------------------- /images/yt-ft-yt-4304a0aa5e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/yt-ft-yt-4304a0aa5e.png -------------------------------------------------------------------------------- /images/yt-ft-yt-fae25965d3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/yt-ft-yt-fae25965d3.png -------------------------------------------------------------------------------- /images/yt-ft-yt-yt_0-y_0-309707f928.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/yt-ft-yt-yt_0-y_0-309707f928.png -------------------------------------------------------------------------------- /images/yt-ft-yt-yt_0-y_0-f7515619c6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/yt-ft-yt-yt_0-y_0-f7515619c6.png -------------------------------------------------------------------------------- /images/yt_0-y_0-42d14f447f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/yt_0-y_0-42d14f447f.png -------------------------------------------------------------------------------- /images/yt_0-y_0-d7b398c658.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scijs/ode-euler/7cf782a33f1adceabcc8ee8c7d9f10bd6252d526/images/yt_0-y_0-d7b398c658.png -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = IntegratorFactory 4 | 5 | var Integrator = function Integrator( y0, deriv, t, dt ) { 6 | // Bind variables to this: 7 | this.deriv = deriv 8 | this.y = y0 9 | this.n = this.y.length 10 | this.dt = dt 11 | this.t = t 12 | 13 | // Create a scratch array into which we compute the derivative: 14 | this._ctor = this.y.constructor 15 | this._yp = new this._ctor( this.n ) 16 | } 17 | 18 | Integrator.prototype.step = function() { 19 | 20 | this.deriv( this._yp, this.y, this.t ) 21 | 22 | for(var i=0; i