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
//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 |