Mohammed E.
asked 12/19/19Solving for this slope function
f'(a) = [f(a+h)-f(a)]/h
its f'(a) not just f(a)
steps would be much appreciated thanks!
1 Expert Answer
Bryce P. answered 12/19/19
CRLA Certified Mechanical Engineering Tutor w/ 1,500 hrs of experience
Hi Mohammed,
The derivation:
The slope function f'(x) = [f(x+h)-f(x)]/h is called a forward difference scheme and is derived using the Taylor Series expansion of a function about x,
f(x+h) ≈ f(x) + f'(x)h + f''(x)h2/2 + f(3)(x)h3/3 + ...
assuming that h is small.
Solving for f'(x) gives us the forward difference scheme that you wanted.
f'(x)h = f(x+h) - f(x) - f''(x)h2/2 - f(3)(x)h3/3 + ...
f'(x) = [f(x+h) - f(x)]/h - f''(x)h/2 - f(3)(x)h2/3 + ...
This formula is a bit larger than the one you listed and includes extra higher-order terms that we don't want to include. These terms represent the error of the approximation. Since h > h2 > h3 ... the term f''(x)h/2 will be the driving factor behind how well the error scales and will be rewritten as O(h) to represent that the error will scale with order h.
f'(x) = [f(x+h) - f(x)]/h + O(h)
Example:
Solve the derivative of sin(x) at x = pi/4 deg and calculate the error of the forward difference approximation for h = 0.1, h = 0.01, and h = 0.001.
Exact value:
f(x) = sin(x)
f'(x) = cos(x)
f'(pi/4) = cos(pi/4) = 0.707107
Forward difference approximation:
f'(x) = [f(x+h) - f(x)]/h + O(h)
f'(x) = [sin(x+h) - sin(x)]/h + O(h)
for h = 0.1
f'(x) = [sin(x+0.1) - sin(x)]/0.1 + O(h)
f'(0) = [sin(pi/4+0.1) - sin(pi/4)]/0.1 = 0.670603
Error = 0.707107 - 0.670603 = 0.036504
for h = 0.01
f'(x) = [sin(x+0.01) - sin(x)]/0.01 + O(h)
f'(0) = [sin(pi/4+0.01) - sin(pi/4)]/0.01 = 0.703559
Error = 0.707107 - 0.703559 = 0.003547
for h = 0.001
f'(x) = [sin(x+0.001) - sin(x)]/0.001 + O(h)
f'(0) = [sin(pi/4+0.001) - sin(pi/4)]/0.001 = 0.703559
Error = 0.707107 - 0.703559 = 0.000354
Notice that each time we decreased h by an order of 10 the error decreased by an order of 10. This is what it means to have a first order error.
If we were to solve a more complex forward difference formula with O(h3) each time we decrease h by an order of 10 the error would decrease by an order of 1000!
I hope that helps. If you have any questions let me know.
Bryce
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
William W.
The derivative (at x = a) is the limit as h approaches zero of what you noted> But in order to help you, we need to either answer as a proof or we need to know what f(x) is. Is there a specific function?12/19/19