Post Reply 
HP-41C T register duplication disabling
02-21-2020, 01:49 PM
Post: #11
RE: HP-41C T register duplication disabling
(02-20-2020 09:03 PM)Garth Wilson Wrote:  I have however seen instruction sequences that take advantage of the fact that T gets duplicated as the stack drops.

One of them is the evaluation of polynomomial expressions using the Horner method.
Quoting from the HP-15C manual, pages 79 and 80:

----------------------------------------------------------------------------------

Polynomial Expressions and Horner's Method

Some expressions, such as polynomials, use the same variable several times for their solution.
For example, the expression

f(x) = Ax⁴ + Bx³ + Cx² + Dx + E

uses the variable x four different times. A program to solve such an equation could repeatedly 
recall a stored copy of x from a storage register. A shorter programming method, however, 
would be to use a stack which has been filled with the constant (refer to Loading the Stack 
with a Constant, page 41).

Horner's Method is a useful means of rearranging polynomial expressions to cut calculation 
steps and calculation time. It is especially expedient in SOLVE and ∫x,y, two rather long-running 
functions that use subroutines.

This method involves rewriting a polynomial expression in a nested fashion to eliminate 
exponents greater than 1:

Ax⁴ + Bx³ + Cx² + Dx + E
(Ax³ + Bx² + Cx + D)x + E
((Ax² + Bx + C)x + D)x + E
(((Ax + B)x + C)x + D)x + E


Example: Write a program for 5x⁴ + 2x³ as (((5x + 2)x)x)x, then evaluate for x = 7

Keystrokes        Display

g P/R               000-                    Assumes position in memory
                                            is line 000. If it is not, clear
                                            program memory.

f LBL B             001-42,21,12            
5                   002-       5
*                   003-      20            5x
2                   004-       2      
+                   005-      40            5x + 2.
*                   006-      20            (5x + 2)x.
*                   007-      20            (5x + 2)x².
*                   008-      20            (5x + 2)x³.
g RTN               009-   43 32         
g PR                                        Return to Run mode. Prior
                                            result remains in display
7 ENTER ENTER
ENTER               7.0000                  Loads the stack (X-, Y-, Z-,
                                            and T- registers) with 7.
f B                 12,691.000

----------------------------------------------------------------------------------           
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP-41C T register duplication disabling - Gerson W. Barbosa - 02-21-2020 01:49 PM



User(s) browsing this thread: 1 Guest(s)