Section 6: Programming Basics

79

For example, ´b´A becomes ´bA, ´m´% becomes ´m%, and O´# becomes O#. The removal of the ´ is not ambiguous because the ´-shifted function is the only logical one in these cases. The keycodes for such instructions do not include the extraneous ´even if you do key it in.

User Mode

User mode is a convenience to save keystrokes when addressing (calling up) programs for execution. Pressing ´U will exchange the primary functions and ´-shifted functions of the A through E keys only. In User mode (USER annunciator displayed):

´shift

 

A

B

C D

E

 

Primary

 

 

¤ ' @ y ∕

 

 

shift

 

x2

LN

LOG %

Δ%

Press U again to deactivate User mode.

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) = Ax4 + Bx3 + Cx2 + 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 _and f, 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:

Ax4 + Bx3 + Cx2 + Dx + E

(Ax3 + Bx2 + Cx + D)x + E

((Ax2 + Bx + C)x + D)x + E

(((Ax + B)x + C)x + D)x + E

Page 79
Image 79
HP 15c Scientific manual User Mode, Polynomial Expressions and Horners Method, ¤ @ y ∕, Log %