You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
// Determine the second derivative using the naive assumption that all original points are smooth. We will handle exceptions laterthis.points[index].y=(point.getSlope(nextPoint)-point.getSlope(previousPoint))/(2*this.deltaX);
whereas it should be
// Determine the second derivative using the naive assumption that all original points are smooth. We will handle exceptions laterthis.points[index].y=(point.getSlope(nextPoint)-point.getSlope(previousPoint))/(this.deltaX);
The text was updated successfully, but these errors were encountered:
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.
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).
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
The text was updated successfully, but these errors were encountered: