I am desperately looking for a JavaScript that can calculate the first derivative of a function. The function always includes only one variable, x.
function slope (f, x, dx) { dx = dx || .0000001; return (f(x+dx) - f(x)) / dx; } var f = function (x) { return Math.pow(x, 2); } slope(f, 3)