Created
December 23, 2022 16:06
-
-
Save yikuansun/7fb6c0eaa4c1fa1b826f73e9810ad12a to your computer and use it in GitHub Desktop.
Evaluate definite integrals in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Math.integrate = function(fn, a, b, deltaX = 0.0001) { | |
var out = 0; | |
for (var x = a; x < b; x += deltaX) out += deltaX * fn(x); | |
return out; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment