RPL program for Newton's Method Message #4 Posted by Namir on 18 Sept 2007, 8:04 p.m., in response to message #2 by Eric Smith
Eric,
Building on your tip, here a program object that applies Newton's root algorithm:
<< DUP2 _derivative_ -> F V D
<< V STO
DO
F EVAL D EVAL / NEG DUP V STO+
UNTIL
ABS 0.0000001 <
END
V RCL
>>
>>
Note: _derivative_ stands for the derivative operator character.
The variables are:
1. Variable F stores the expression whose root is sought.
2. Variable V stores the name of the variable.
3. Variable D store the derivative of the expression.
To use the above program, enter the input in the following sequence:
1. An initial guess for the root, such as 4.
2. The expression whose root is sought, such as 'EXP(X)-3*SQ(X)'.
3. The name of the variable in the above expression, 'X' in this case.
Invoke the name of the program object to obtain a refined guess for the root.
The beauty of the above RPL object is that it obtains the derivative symbolically and uses it to evaluate the derivative in each iteration. For once, I don't have to worry about calculating an approximation to the derivative. Wooohoooo!
Namir
Edited: 18 Sept 2007, 8:06 p.m.
|