Polynomial Expressions and Horner's Method
Some expressions, such as polynomials, use the same variable several times for
their solution. For example, the expression
uses the variable x four different times. A program to calculate such an expression
using RPN operations could repeatedly recall a stored copy of x from a variable. A
shorter RPN programming method, however, would be to use a stack which has
been filled with the constant (see "Filling the Stack with a Constant" in chapter 2).
Horner's Method is a useful means of rearranging polynomial expressions to cut
calculation steps and calculation time. It is especially expedient with SOLVE and
∫
FN, two relatively complex operations that use subroutines.
This method involves rewriting a polynomial expression in a nested fashion to
eliminate exponents greater than 1:
Example:
Write a program using RPN operations for 5x
evaluate it for x = 7.
Keys:
(In RPN mode)
¹ £ ¹
r Ë Ë
¹ Ó
P
¹ Ç
X
Ï
Ï
Ï
5
¸
2
12–24
Simple Programming
File name 33s-E-Manual-1008-Publication(1st).doc
Printed Date : 2003/10/8
4
3
2
Ax
+ Bx
+ Cx
+ Dx + E
4
3
2
Ax
+ Bx
+ Cx
+D x + E
3
2
(Ax
+ Bx
+ Cx + D ) x + E
2
((Ax
+ Bx + C ) x + D )x + E
(((Ax + B )x + C ) x + D )x + E
Display:
Page : 386
Size : 13.7 x 21.2 cm
4
3
+ 2x
as (((5x + 2)x)x)x, then
Description:
Fills the stack with x.
5x.