Skip to content

Instantly share code, notes, and snippets.

View Bobingstern's full-sized avatar

Anik Patel Bobingstern

View GitHub Profile
@Bobingstern
Bobingstern / integrate.js
Last active June 11, 2022 16:20
JavaScript Numerical Integration
//Simpsons use rule fourth derivative for error calculation and minimisation
let GR = (Math.sqrt(5)+1)/2
function maximum(f,a,b,error){
error = error == undefined ? 1e-4 : error
let c = b - (b-a) / GR
let d = a + (b-a) / GR
while (Math.abs(b-a) > error){
if (f(c) > f(d)){
b = d