MathosProject / Mathos-Project

The Mathos Core Library
Microsoft Reciprocal License
26 stars 7 forks source link

Derivative improvement #2

Open artemlos opened 9 years ago

artemlos commented 9 years ago
artemlos commented 9 years ago

a good h value(for the double type) is in the order of 10e-14. Now, the current method uses forward differentiation, however, it's better to switch to centered differentiation instead. The h value might need to be adjusted in this case.

artemlos commented 9 years ago

example in GO:

func Derivative(x func(x float64) float64, point float64) float64 {
    const h = 1e-14 //not sure what to take here. Anyway, I think our derivative function has to test the errors (flactuation) in advance. Say we start at 1e-10 to 1e14.
    return (x(point+h) - x(point-h)) / (2 * h)
}