12–24 Simple Programming
File name 33s-E-Manual-1008-Publication(1st).doc Page : 386
Printed Date : 2003/10/8 Size : 13.7 x 21.2 cm
Polynomial Expressions and Horner's Method
Some expressions, such as polynomials, use the same variable several times for
their solution. For example, the expression
Ax
4
+ Bx
3
+ Cx
2
+ Dx + E
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:
Ax
4
+ Bx
3
+ Cx
2
+D x + E
(Ax
3
+ Bx
2
+ Cx + D ) x + E
((Ax
2
+ Bx + C ) x + D )x + E
(((Ax + B )x + C ) x + D )x + E
Example:
Write a program using RPN operations for 5x
4
+ 2x
3
as (((5x + 2)x)x)x, then
evaluate it for x = 7.
Keys:
(In RPN mode)
Display: Description:
¹
£
¹
r
Ë
Ë
¹
Ó
P
¹
Ç
X
Ï
Ï
Ï
Fills the stack with x.
5
¸
5x.
2