Exercise 3: Forward vs. Central Difference on x^2 — A Special Case — Possible Solution ==================================================================== GIVEN ------------------------------ f(x) = x^2, x=1, h=0.5. True derivative: 2x = 2. STEP 1: FORWARD DIFFERENCE ------------------------------ (f(1.5) - f(1)) / 0.5 = (2.25 - 1) / 0.5 = 1.25 / 0.5 = 2.5 Error: |2.5 - 2| = 0.5 STEP 2: CENTRAL DIFFERENCE ------------------------------ (f(1.5) - f(0.5)) / (2*0.5) = (2.25 - 0.25) / 1 = 2.0 / 1 = 2.0 Error: |2.0 - 2| = 0.0 RESULT ------------------------------ Central difference gives EXACTLY 2.0 - zero error, even at a fairly large step size of h=0.5, which is far larger than any of the step sizes needed to get comparable accuracy in this chapter's own x^3 example. DOES THIS MATCH THE x^3 PATTERN? NO - AND HERE'S WHY ------------------------------ This is NOT the same pattern as x^3, where central difference was dramatically more accurate than forward difference but still had a small, nonzero error. For x^2 specifically, central difference is EXACTLY correct, for any h at all, not just very accurate. This happens because central difference's own error term depends on the THIRD derivative of the function (this is a genuine mathematical fact about how the central difference formula's error behaves, tied to how quickly the function's own curvature is changing). For f(x)=x^2, the third derivative is 0 everywhere (the second derivative of x^2 is the constant 2, and the derivative of a constant is 0) - so central difference's error term vanishes completely for any quadratic function, regardless of h. x^3's own third derivative is a nonzero constant (6), which is exactly why central difference still had a small residual error there. WHY THIS WORKS AS AN ANSWER ------------------------------ Both differences are computed explicitly with real numbers rather than assumed to follow the same trend as the earlier x^3 example, and the surprising exact-zero-error result is explained using a specific, correct mathematical reason (central difference's error term depending on the third derivative, which is zero for any quadratic) rather than just noting the numbers happened to come out differently.