Challenge - 5 Problems
Numerical Differentiation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of forward difference approximation
What is the output of this MATLAB code that approximates the derivative of f(x) = x^2 at x = 2 using the forward difference method with h = 0.01?
MATLAB
f = @(x) x.^2; x = 2; h = 0.01; derivative = (f(x + h) - f(x)) / h; disp(derivative);
Attempts:
2 left
💡 Hint
Recall the formula for forward difference: (f(x+h) - f(x)) / h.
✗ Incorrect
The exact derivative of x^2 at x=2 is 4. The forward difference with h=0.01 gives approximately (4.0401 - 4)/0.01 = 4.01.
❓ Predict Output
intermediate2:00remaining
Output of central difference approximation
What is the output of this MATLAB code that approximates the derivative of f(x) = sin(x) at x = pi/4 using the central difference method with h = 0.001?
MATLAB
f = @(x) sin(x); x = pi/4; h = 0.001; derivative = (f(x + h) - f(x - h)) / (2*h); disp(derivative);
Attempts:
2 left
💡 Hint
Central difference formula is (f(x+h) - f(x-h)) / (2*h).
✗ Incorrect
The exact derivative of sin(x) at pi/4 is cos(pi/4) ≈ 0.7071. The central difference with h=0.001 approximates this closely.
🔧 Debug
advanced2:00remaining
Identify the error in backward difference code
This MATLAB code attempts to compute the derivative of f(x) = exp(x) at x = 1 using the backward difference method with h = 0.01. What error will it produce when run?
MATLAB
f = @(x) exp(x); x = 1; h = 0.01; derivative = (f(x) - f(x - h)) / h;
Attempts:
2 left
💡 Hint
Check if the code syntax is correct and variables are defined.
✗ Incorrect
The code correctly computes the backward difference and outputs approximately exp(1) ≈ 2.7183. No error occurs.
❓ Predict Output
advanced2:00remaining
Output of second derivative approximation
What is the output of this MATLAB code that approximates the second derivative of f(x) = x^3 at x = 2 using the central difference formula with h = 0.001?
MATLAB
f = @(x) x.^3; x = 2; h = 0.001; second_derivative = (f(x + h) - 2*f(x) + f(x - h)) / (h^2); disp(second_derivative);
Attempts:
2 left
💡 Hint
Recall the second derivative central difference formula: (f(x+h) - 2f(x) + f(x-h)) / h^2.
✗ Incorrect
The exact second derivative of x^3 is 6x. At x=2, it is 12. The central difference with h=0.001 gives approximately 12.0000.
🧠 Conceptual
expert2:00remaining
Error behavior in numerical differentiation
Which statement correctly describes the error behavior when using the central difference method to approximate the first derivative of a smooth function as the step size h approaches zero?
Attempts:
2 left
💡 Hint
Consider both truncation and round-off errors in numerical differentiation.
✗ Incorrect
Central difference error has two parts: truncation error decreases with smaller h, but round-off error increases for very small h due to floating-point precision limits, causing total error to first decrease then increase.