Closed veillette closed 1 year ago
For posterity, here is the formula we want for the second derivative based on the central difference $$f''(x) \approx \frac{ \frac{f(x+h) - f(x)}{h} - \frac{f(x) - f(x-h)}{h} }{h} = \frac{f(x+h) - 2 f(x) + f(x-h)}{h^{2}}$$.
Fixed on master. I included a screenshot of the parabola and triangle function, and we can see that the calculation of the first and second derivative is correct.
Good catch.
I should note that this bug was introduced while I introduced the SecondDerivative
class that calculates the SecondDerivative
based on the function f(x) (previously the second derivative was merely the derivative of the first derivative).
We can close this issue as fixed.
While looking at #302, I noticed an odd relationship between the scaling of the second and first derivative.
Although numerical values are not emphasized, it should be important to get the values right!!
The slope of the derivative is the second derivative. Evaluating from the above screen, we notice that the second derivative has the correct sign, but it numerical value should be about -1.
The culprit is here.
whereas it should be