To calculated the value of the derivative of a given function Func at a given point x, to get a good precision one would think this:
a = Fun( x - Number.MIN_VALUE)
b = Func( x + Number.MIN_VALUE)
return (b-a)/(2*Number.MIN_VALUE)
Now for any x + Number.MIN_VALUE
(or x - Number.MIN_VALUE
) both return x in javascript.
I tried of different values, and 1 + 1e-15
returns 1.000000000000001. Trying to get more precision, 1 + 1e-16
returns 1
. So I'll have to use 1e-15
instead of Number.MIN_VALUE which is 5e-324
.
Is there a way to get a better precision in this case in javascript?