Thanks, and a programming example... Message #12 Posted by Karl Schneider on 25 Feb 2005, 1:10 a.m., in response to message #11 by Tom Sherman
Tom posted,
Quote:
Nice to see Karl's reference to the symmetric definition of the derivative as:
lim (h->0) [f(x+h) - f(x-h)]/2h
This is a form which seems to be well known to numerical analysis people, but which is often ignored by calculus textbooks.
From considerations of symmetry, it makes sense that a chord across a curve will better approximate a tangent to a particular point if the x value of that point is in the middle of the chord rather than at one extreme.
Thank you, Tom. Of course, it goes almost without saying that f(x) must be evaluable and differentiable at the point "x" for the result to be valid. Neither 1/x nor |x| pass both tests at x=0.
Selecting a value of "h" in the ideal range will give the most accurate results. Larger values of "h" can reduce accuracy due to coarseness; too-small values of "h" can reduce accuracy due to roundoff error in the machine used, as significant digits are dropped when "f(x+h)-f(x-h)" is evaluated. HP's introduced prior to the Saturn processor (1984) carry 10 digits; most HP's introduced thereafter carry 12 digits.
Here is a program for the 11C and 15C (and 16C, 33C, and 34C?) to evaluate [f(x+h)-f(x-h)]/(2h) for a user-defined function:
LBL A
STO 1 x
RCL 0 h
+
GSB I f(x+h)
STO 2
RCL 1
RCL 0
-
GSB I f(x-h)
RCL 2
x<->y
-
RCL 0
2
*
/ df/dx = [f(x+h)-f(x-h)]/(2h)
RTN
- Program your function f(x) using a label other than "A".
- Store the numerical identifier of that label in register I.
- Store the value of "h" in register 0.
- Put the value of "x" in stack register x.
- Do "GSB A" and view df/dx evaluated at "x".
For linear and quadratic functions, I expect that the correct answer will result for any value of "h" that does not cause overflow or underflow.
For other functions, note that increasingly larger "h" reduces accuracy, while increasingly smaller "h" reduces accuracy, and eventually produces a result of zero.
-- KS
Edited: 25 Feb 2005, 1:31 a.m.
|