An Easy Course in Using The HP-42S - OCR
An Easy Course in Using The HP-42S - OCR
An Easy
'Cou-r se In
c
(
. rJ
-· . ('
r
('
('
(
(
(
(
(
c
(
('
(
c
(
~
(
(
(
(
(
(
(
(_
(
(
An Easy Course In
Using The HP-428
by Dan Coffin
and Chris Coffin
Illustrated by Robert L. Bloch
)
Notice Of Disclaimer: Grapevine Publications, Inc. makes no express or implied warranty with )
regard to the keystroke procedures and program materials herein offered, nor to their merchantability )
nor fitness for any particular purpose. These keystroke procedures and program materials are
made available solely on an "as is" basis, and the entire risk as to their quality and performance )
is with the user. Should the keystroke procedures and program materials prove defective, the user
(and not Grapevine Publications, Inc., nor any other party) shall bear the entire cost of all necessary )
correction and all incidental or consequential damages. Grapevine Publications, Inc. shall not be
)
liable for any incidental or consequential damages in connection with, or arising out of, the
furnishing, use, or performance of these keystroke procedures or program materials. )
)
)
CONTENTS
)
SOLVING PROBLEMS: )
Using Your Power Tools .................... 304 )
)
The~ Menu ....................................................................... 306
Negative Numbers In The ~ Menu ........................... 310
)
Fractions And Integers And Bases ..................................... 313
The !!Im Menu ...................................................................... 314 )
Solving Problems in~· ................................................. 317 )
Matrix Multiplication ............................................................ 317 )
Simultaneous Equations ....................................................... 319 )
)
)
The [STAT] Menu .......................................................................... 322
What Are Statistics, Anyway? ............................................. 323
Entering Some Statistical Data ........................................... 325
Checking and Editing Your Data ........................................ 328
Just Plain Mean .................................................................... 330
A Moving Average ................................................................. 331
A Weighted Mean .................................................................. 332
Deviations From The Average ............................................. 335
Two-Variable Statistics .......................................................... 339
Getting Trendy: Regression and Estimation ............... 340
Solver And Integrate: Power Tools That Use Programs ...... 350
The ~ Menu ................................................................... 351
Spikes, Asymptotes, And Other Beasties ....................... 356
The~ Tool ................................................................. 359
What ~ Is Really Doing ...................................... 362
Guess the Answer: Telling llSOLVERJ Where To Look .. 363
Don't Be Misled By False Solutions ......................... 364
The Good News ............................................................ 365
Powerful Problems ..................................................................... 373
Powerful Solutions ..................................................................... 374
Yes, there's a lot to be done- and a lot to learn - but remember that the
)
hardest part of learning anything new is simply )
)
Beginning )
This means you've just finished the hardest part of this Course!
But you're not quite completely finished yet. You've begun with a
powerful problem-solving workshop (your HP-428), and now, with this
Easy Course book, you're going to master that workshop and its tools.
It's not a long apprenticeship - just a few good hours. But do it! The
rewards will definitely be worth your while; when you finish, you'll
know enough to solve problems that haven't even been invented yet!
How's that?
It's like this: The goal here is not just to leave you knowing how the
buttons work or remembering a handful of keystrokes and formulas.
You're going to get a fundamental understanding of problem-solving,
so that whenever you encounter new problems, you'll be able to analyze
and solve them confidently. No more the apprentice, you'll be the
master of your own workshop!
Now then....
)
)
........ ______ ~
·--- ·--.. .
)
)
)
Before You Get Your Hands Dirty )
)
)
What's In This Machine?
Inside the HP-428 you'll find a wonderland of tools that are useful in
solving real-world mathematical problems of nearly every kind. And
you can use these tools to build even more wondrous tools - to get you
to those "hard-to-reach" places. Congratulations on a wise choice!
Now you simply need to learn how to use and master the tools and
possibilities your HP-428 offers.
Your part of the work is in defining the problem correctly for yourself
and then restating it for your calculator. After all, only a human being
can really understand our human world (and even then it's tough
sometimes)!
This translation skill isn't really very hard to learn. It's a lot like
learning to use any sophisticated tool - like a typewriter, a car, a lathe
or a forklift. Everything seems strange at first, but after some training
and practice, you'll be doing things quite proficiently - without even
thinking much about them! And that's where this book comes in....
As your mentor, this Course will introduce you to the tools available in
the shop, watch over you as you use the power tools for the first time,
demonstrate some of the more useful operations that a Craftsman has
to know, and make sure that you know how to keep your working en-
vironment clean, orderly and inviting.
It's because you can control how fast you learn things. You needn't
worry about showing off or competing with anybody. You can repeat
your lessons whenever and as often as you wish-without making your
teacher the least bit grumpy. After all, it's your Course!
)
What's Not In This Book?
For example, you'll get an overview of the higher math tools available
on your machine, but not an exhaustive and detailed survey of them;
some of those tools will be discussed more fully than others. This isn't
because those tools are any more important in the Great Scheme Of
Things; rather, it's because they're the most complicated to learn how
to use correctly, so they deserve more space in the book.
But this book you're now reading is not a reference manual; it's an
entirely different approach, with a careful selection of topics that are
meant to be taken in order. So start here at the beginning and stay on
Course!
Now, roll up your sleeves, flex your fingers, oil your thinking cap
and ... go ....
The best place to begin your first tour is to look at the Big Picture -the
"floorplan" of your HP-428 workshop.
Now, before you turn the page, consider what you're likely to see: What
would you expect to find in a craftsman's workshop?
• There would also be tool storage areas - say, one area for hand tools
and one area for power tools;
You'll be spend-
ing a lot of your
time here, with
the Stack acting
as your "work-
bench."
Power Tools-+ )
()
These are com-
plex and power- ~ ~
()
ful tools, each in mJIWJU ()
its own "room." EDI
)
)
)
Hand Tools-+
)
These tools per-
form most of the
)
"simple chores"
)
and are stored
on "shelves" (i.e. )
in menu collec- )
tions) here. )
)
)
)
18 An Easy Course In Using The HP-428 )
)
The HP-42S Storage Area
• Thememoryavail-
able in your HP-
Latest, Greatest Program 428 Storage Area
Third Program I
Programs I will depend on the
Real# • The.CATALOG)key
Variables
or Alpha also lets you view
Strings
all the available
hand tools.
You may have noticed from studying the Big Picture that your work-
shop apparently has no outside doors.
You'd better find the entrance: To get into your workshop, press the
button in the lower left corner of your calculator - the button marked
[EXIT), with ON written in silver below it and OFF written in orange
above it.
Well, if you push the button when the calculator is turned off, it acts
like the@ffibutton. You "go into the workshop." If you push the button
when the calculator is turned on already, the button acts as the (EXIT)
key (details about the (EXIT) key later.)
Is your calculator on? All right, now turn it off again, by pressing the
[OFF) key....
)
Hmm ... the machine doesn't turn off simply by pushing that same (EXIT)
)
key again, does it?
)
Since the word OFF is written in orange above the (EXIT) key, you need )
to press the blank, solid orange "shift" key(.) before pressing [Ex1n )
Now it works, right? )
)
20 An Easy Course Jn Using The HP-428 )
..I
Starting With A Clean Shop
OK, press@ffi again. Now, the best way to start making sense of that
Big Picture is to look at your HP-42S display.... what do you see?
That's hard to say, actually. Since your HP-42S has continuous mem-
ory, it will look now just as it looked when you last used it. So, to be sure
that you're starting with a clean slate, here's how to reset the machine.
Warning: You're only doing this now to be sure that you can follow
along on this Course. This procedure completely wipes out all mean-
ingful information in the machine. This is not something you want to
do very often. There are plenty of other, safer ways to selectively erase
parts of its memory. This reset is an Equal Opportunity Erasure! It
erases everything without regard to its importance or value!
Drum Roll, Please: Press and hold down the [EXIT) key. While
holding it down, press and hold down the~
key (upper left corner). While holding both
those keys down, press and release the [XEO)
key (upper right corner). Now release the~
key, then the [EXIT) key. You should see this:
[MeMory Clear
x: 0.0000
Can you see and read the display comfortably? The LCD (Liquid
Crystal Display) is hard to read if you're not looking at it from a certain
angle - but you can adjust that angle to whatever's best for you!
()
()
Try It: With the machine still on, press and hold down the [EXIT) key. ()
Then press and hold the (±) or the 8 key and watch how the )
display's best viewing angle varies .... )
)
)
The Display's Two Lines )
)
There you see it, a machine with utter amnesia. But notice that even )
now, in its emptiest state, your HP-428 uses its two-line display to tell
)
you what's happening-so when in doubt, look at the display for clues!
)
With two lines of display, the HP-428 offers more power and flexibility )
(and possible confusion) than do calculators with one-line displays. So )
it's time to learn what the HP-428 is telling you with its display.
)
)
22 An Easy Course In Using The HP-428 )
)
The Message Display
This kind of display is what should be showing right now: the top line
hasamessage(MeMory Clear)and the bottom line shows x: 0. 0000
Now, press the~ key to clear the message line. You should see:
ly, 0.0000
x: 0.0000
This is the second type of display, the Stack Display. By clearing the
message, you've now uncovered the top line of this display.
These two numbers are the ones that your calculator happens to be
ready to work on at the moment. You can think of them as "sitting on
the workbench" right in front of you in a sort of stack, waiting for you
to grab a hand tool and start pounding or cutting on them or something
(and of course, you'll learn all about the relationships between the x:
and Y: numbers and the rest of the Stack later in this chapter).
You'll find a third type of display by pressing •CATALOG] (i.e. the solid
orange key, then the(±) key with the orange CATALOG written above
it). You should see the following Menu Display:
)
00•{ 0-Byte Pr9M ) )
01 . E~lD.
Again, don't worry yet about what the information in this display is.
This is just to get you familiar with the types of displays you'll be seeing.
The whole point of these first lessons on the display is: Always let the
display orient and remind you "where you are" in the workshop:
l
A First Tour OfYour Work•hop 25
The Annunciators
Besides the two full lines of information in your HP-428 display, you
also have some space above them. This space is for the annunciators.
Press the• key and look at the display above the top line. You should
see a small upward pointing arrow: ~-
Now press the• key again while you watch the display. The arrow
went bye-bye. This arrow is a good example of an annunciator.
You may have wondered why your display shows exactly four decimal
places in every number. This is usually enough for most technical cal-
culations - and HP had to decide on some such display setting for the
HP-428 to "wake up" in after a total memory reset (recall page 21).
"But is this the best precision you can get?" Not at all. In fact, every
number carries 12 digits of precision, no matter how many you can see
at the moment.
y: 0.0000
x: 4,562.86553109_
Now press~:
y: 4,562.8655
x: 4,562.8655
Was the 0. 00003109 lopped off by the calculator?
Find out by pressing(±) to add these two numbers:
y: 0.0000
x: 9, 125. 7311
The machine kept all 12 digits, even when you couldn't
see them (if it hadn't, you'd now see 9, 125. 7310).
"OK, so how do you tell the machine to display more (or fewer) digits?"
[DISP] Your
First Menu:
How Many Digits Do You See?
Since the display shows you only requested portions of the full 12-digit
numbers, you have certain tools you can use to "change your request."
To bring these DISPlay control tools to your "workbench," press the
~key. You should see this menu:
x: 9, 125. 7311
m!Jllmllmlimlrnm::Jm!I
Notice a few things here: Notice the little boxes in the menu items that
look like this: Im and li!m. Those boxes remind you which "choices"
you've currently selected. Right now, the mil tells you that you have
a "FIXed" number of decimal places (and you can see how many digits
this is simply by looking in the number above).
The 1iJ.7J1J stands for "RaDiX," which is the technical term for the
decimal point. At the moment, it is a point. In Europe, they would
choose the other option, a comma.
So how do you choose which options you want? How do you use a menu?
Like This: Press the ~keys, then the [xEaJkey. What happens?
x: 9.125, 7311
m!JllmllmlimllB!Rm
"Why the~ key?" Because that's how the menus work: Whenever you
see menu items in the display, they are aligned and matched with the
keys in the top row ofthe keyboard (directly beneath them). You choose
menu items by pressing the corresponding top-row keys!
Result:
x: 9,125.73106218
IECIDl~l:l!JllBIB:!ml
Of course, there's a lot more to using this calculator than just knowing
what the display is telling you. It's now time to look at all the keys (but
if you already know these keyboard basics, then jump now to page 34).
Look first at the white writing on the actual key-faces themselves. See
how the digit keys <@}-®) and the four arithmetic functions ([±J,8,(8),
and EJ) are all conveniently placed together on the lower four rows?
After all, you shouldn't need to search around just to add two and two!
But (as you'll soon see), there are other keys that you could consider as )
being arithmetic/math keys also: There are the (ENTER], [+/-],and (ID 0
keys, and the (B key is for correcting mistakes (just in case you should )
ever make one). Then the top two rows contain other mathematical
)
functions common to most scientific calculators (e.g. @ill,[ cos],@, (ill)).
)
And don't forget the shift key. You've already been introduced to this )
plain orange key, (which will appear in this book as•). It activates all
the orange-printed functions on the keyboard-similar to the shift key )
on a typewriter. But unlike a typewriter, you don't hold the• key down
)
while pressing the orange-printed function you're after. Just press and
release •• and then press the key you want. The~ will always tell you J
when the "shift" is in effect. (Notice also that the shift is cancelled after )
every use; you need to re-press the• for every orange-printed function )
you want, because •is not a "Caps Lock"). )
J
30 An Easy Course In Using The HP-428 J
)
Menus And Their Pages
All right, so far, you've looked at the display and keyboard of your HP-
428, connecting what you see on your machine with the Big Picture.
Next up: menus and how they work ....
A£; you can tell by looking at the Big Picture (on pageslS-19), most of
the orange functions in the lower part of the keyboard are names of
"storage shelves" in the your workshop. Here's where you'll find many
useful collections of "hand tools."
Each such collection is a set ofrelated tools (such as the DIS Play tools,
for example), stored on its own shelf and marked with an appropriate
name. That name appears (usually printed in orange on the keyboard)
as a menu key. Therefore, in the Big Picture, each "shelf' in the Hand
Tool Storage Area is headed by the name of a menu key:
~
lllBI DI]
lml
ED
um~
lmlllml
In the next few pages, get acquainted with each of these menu keys on
your HP-428 (and though you've already seen the [DISP] Menu, you'll
review it now, too, because there are some other points to learn) ....
()
Notice: Look at the~ Menu (press~): )
,.... )
x: 9, 125. 73 )
mll:Dl!Dl!lilmJml
)
Only six menu choices are visible, but there's also an an- )
nunciator (T.&.). The ,..._ means there are more choices
available but not visible. To find these other choices, use
)
the@ and[!) keys (just above the• key) ....
)
Get the idea? Try a few more .. . )
)
32 An Easy Course In Using The HP-428
)
Many of the bins in your HP-428 Storage Area are for storing various
kinds ofdata. And what's data? "Data" asit'susedhereisjustanother
name for computer information, namely, "numbers and characters."
You probably have a good feel for what a number is: it's a quantity with
which you (and your HP-428) can do numerical calculations. In this
sense, it's an abstract idea; how you represent this idea to your own eye
and mind is irrelevant. The quantity "twelve" can be represented as
J--HI J..-1-11 I I or 12 or XII . The idea of the quantity you're
talking about is always the same, no matter what symbol you use.
You can also combine or link numbers and characters into other data
structures or types. For example, if you link two numbers together in
an ordered pair, you get a vector. If you link two characters, you get a
string. By thus linking simpler data types, you make more intricate
(and presumably, more useful) data types.
With that in mind, consider the various storage bins in your workshop:
With the help of this register, the computer can store and manipulate
characters (also called ALPHA characters to remind you that they are
indeed only letters and symbols - not numerical quantities).
Now ... what kinds of data types can you build and store, using simple
numbers and characters -and using the Stack and the ALPHA register
as your "working containers?"
Your HP-428 will let you build and store these four types of data:
L Real numbers
2. ALPHA strings
3. Complex numbers
4. Matrices
L A real number data type is just a single real number - plain and
simple;
These are the forms in which you can store and manipulate data. But
you might have lots of examples of each form - so you need a way to
store and identify each datum.. .. )
Whenever you build a datum, it will have one of those four data types.
And if you want to store it somewhere, that "somewhere" will be a
variable. As you can tell from the Storage Area in the Big Picture (page
19) variables are eraseable, namable storage bins. They vary because
you can delete them altogether - or change their names or sizes.
Of course, there's an HP-42S variable type for each data type. So,
keeping your thumb marking page 36, look briefly now at each of the
four variable types (don't worry yet about how you actually build and
store these variables yet; remember that this entire chapter is just
your first guided Tour of your HP-42S workshop) ....
ALPHA Variables
Of course, you can also have an ALPHA string with fewer than six char-
acters, but this won't save you any storage space; it will use the same
amount of space as a full six-character string (or one real number).
)
)
The interchangeability of real and ALPHA variable types in the HP-
42S makes it just as convenient to refer to all such variables as "real."
So when you see references to "real" variables-either here in the book )
or in the menus of your HP-42S-you need to realize that, unless it's )
stated otherwise, this means ALPHA strings too. )
)
38 An Easy Course In Using The HP-428 )
)
Complex Variables \
As with the simpler real variables, the complex variable type is fixed
in its size: You just can't squeeze any more into it than two real
numbers - one for each part. But unlike real variables, you cannot
substitute ALPHA strings for real numbers in the fixed spaces of a
complex variable. Your HP-42S is absolutely stubborn about this:
Alpha data is invalid in a complex variable type.*
*"Dave ...... Dave? ...... What are you doing, Dave? .... ........ Sorry, Dave, I'm afraid I can't do that.... "
Here's the "big-ey" - the real macho variable type: You can actually
enter, store and manipulate entire matrices, using named storage bins
that are matrix variables.
And here's where you can play around with the size of variables: If you
have, say, a two-by-two matrix of values, you can actually re-size it to,
say, a three-by-two matrix, then enter the two extra values!
Not only that, you can change the type of values that go into the matrix:
If that three-by-two matrix you just filled up is a matrix of real
numbers, you can actually convert it to a matrix of complex numbers
instead (all the real values in it will be converted)!
This means that matrix variables are re-sizable two different ways -
the number of elements and the size (type) of the elements themselves.
()
Not bad, eh? Of course, this means that larger dimensions or complex
types will eat more available memory, but it sure is nice to know you )
)
)
40 An Easy Course In Using The HP-428 )
)
J
Now look again at the Big Picture of the HP-42S Storage Area (page
19). You'll see a long, skinny matrix already stored under the name
REGS in the "Matrix Variables" section .... What is that beast, anyway
- and what's a variable doing in your HP-42S already? You didn't put
it there, did you? Nope - this one's a built-in variable ....
"So why are they shown as a variable - and in matrix, of all things?"
m
It's because you can do certain things to this ofregisters that you can
normally do only to a matrix variable - things such as changing the
type from real to complex, and changing the number of elements . And
yet you can also do something with this REGS matrix that you cannot
normally do with matrix variables: You can call each element by its own
"register-like" name (e.g. R12 , R19' etc.).
There is one other kind of container that can be named in your HP-428
- but it isn't a data variable (see page 19 one more time). It's called a
program, a set of automatically executing instructions by which you
can actually add to your collection of tools: A program is a tool you build
from other tools - the most powerful thing you can build in your
workshop.
Like variables, programs can be varied in their sizes and names - and
they take up space in your HP-428 Storage Area, but that's about
where the similarities end, since programs are not "raw materials,"
but customized tools of your own design.
As with all aspects of this First Tour, you'll see plenty of detail on
programming later. Right now, it's enough that you remember that
programs also must share the Storage Area in your calculator with the
variables you create - and that's why the Big Picture shows them
stored as you see on page 19.
Reviewing Your Storage Area
Here's the bottom line from this chapter: Your HP-42S Storage Area
is divided into areas for programs, variables, and still-available space.
And everything you store will use some of that available space.
The .CATALOG)Menu
IEI gives a complete list of all the functions (hand tools) available;
IED gives a list of any programs you've stored (none yet);
~ lists all the real (and ALPHA) variables you've stored (none yet);
l!D lists all the complex variables you've stored (none yet);
lml provides a list of all matrix variables (you have none of your
own as yet, but you always have the REGS matrix - that built-in
matrix of "registers" - of either real or complex numbers);
Gm] tells you how much memory you still have available (you must
hold down this menu key to continue viewing the memory).
That• CATALOG] menu shows you what you've got stored - but it doesn't
let you do anything about it. If you want to keep your storage areas
well-organized and free of clutter, you need to use the ~Menu.
This menu lets you clean out your data, variables, programs, etc.
selectively (i.e. you don't clear the entire machine to get rid of one item).
Press [EXIT) and then •CLEAR.CLEAR) to see this menu (it has two
"pages," so you'll need to use the~ and~ to see all the selections).
Although there are some items on it that won't mean much to you yet,
notice these selections (try them, too, if you wish):
Just remember this - in keeping with the idea ofregisters vs. vari- )
ables: When you use the ~Menu to clear a register, you remove )
the data but leave the container; but when you clear a variable, you )
delete it entirely - data and container.
)
)
44 An Easy Course In Using The HP-42S )
)
Pop Quiz
No sweat - just make sure you can answer these general questions:
7. Name the four display types. How do you move between them?
9. What if you left for Katmandu without turning off your HP-428?
menu has more "pages" -that you'll see more choices if you press
the ~ or (!) keys. The - announces that you've pressed the
orange "shift" key(.), so the machine will interpret the next key
you press in terms of the orange writing above the key instead of
the white writing on the key itself (see pages 26 and 32-33).
)
5. The four data types are: real numbers, ALPHA strings, complex
numbers, and matrices. Complex numbers are linked pairs of
real numbers; matrices are linked sets of either complex or real
numbers (but not mixed). An ALPHA string data type is allowed
anywhere a real data type is allowed. See page 36 to review.
6. Variables are storage containers that you can create, name, fill,
empty and delete entirely. By contrast, registers are perma-
nently-created-and-already-named storage containers that you
can only fill and empty- but not delete from existence al together.
7. The four display types are: Message, Stack, Menu, and Program.
Much of the movement between displays is automatic, but you
have some control over it. To move from any other display to the
Stack Display (your "work- bench") you press [EXIT) (sometimes
more than once). To move from the Stack Display to a Menu or
Program Display, you select a function that requires that type of
display (see pages 23-24).
9. After about 10 minutes, your HP-42S would turn itself off. Then,
if you returned later and turned it on, its display (and memory)
would be the same as before. As long as its batteries last, your
calculator will continuously remember everything you store in it.
All right- so you have this whole HP-42S workshop full of tools to try
out. Where do you begin?
Probably right there in front of you- at the workbench itself, no? After
all, you can't do much else until you learn the basics of "number-
crunching" with your favorite tools and workspace - the Stack.
If this is your first experience with Reverse Polish Notation CRPN, for
short), you'll want to spend some time in this section. And even ifyou're
an old hand at HP-42S arithmetic, you're going to need a detailed
knowledge of the Stack in order to write good programs - so a review
with this section may be just the ticket.*
So turn your machine on (ifit's not on already), and make sure you see
the Stack display, showing both the X- and Y-registers.
*But, if you really do know your way around the Stack, and you're already quite comfortable with
doing arithmetic on your HP-42S, including negative numbers and scientific notation, then feel
free to go on to page 74 now.
OK, but try "saying" the solution to this: 19 - l l{(5 .79 + 25) + 34.6)
{40 x 22)
"uh ... 19 minus the quantity 11 times the quantity 5.79 divided by 25,
plus 34.6, divided by the quantity 40 times 22 equals ... ?"
A person could get a sore throat with all those "quantities," which are
meant to denote the parentheses, right? And it's pretty hard to tell
where the parentheses should open and close, isn't it? If you get
several nested sets, it's a real pain to make sure you've got a closing ()
parenthesis for every opening one. )
)
The point is, all those troubles are still with you if you use a calculator )
that tries to mimic the way you "say it out loud" -a calculator that uses
()
"algebraic notation," rather than RPN.
)
With RPN, you never use parentheses (no matter how complex the )
calculations get) nor do you even need an G key (notice that your HP-
428 has neither CIIIJ keys nor an G key).
)
)
"How is this possible?" Glad you asked!. ...
)
)
50 An Easy Course In Using The HP-428 )
)
The main "strategy" with RPN is: A. Key in a number;
B. Do something to it.
And most RPN calculations are just repetitions of this simple pattern!
Example: Press (EXIT) so that you see the Stack, then add 5.79 and
34.6 on your HP-428.
A. Keyin~.
B. Press [ENTffi) to "finish" it.
A. Key in @:8Effi;
B. Press(±) to add it to the previous number.
Result: x: 40. 39
Putting the action at the end of the sequence of numbers is what makes
RPN so different - and so much easier - than the way you're used to
"saying" a solution (and it's also what puts the R in RPN*).
For one thing, it eliminates the need for an B key, since pressing (±)
signifies that you're ready to have the operation performed. But the
biggest advantage is that you never need parentheses, because you're
always "combining as you go." You don't need to give the machine the
entire problem before beginning to solve it!
*See the footnote on page 42 ofyour Owner's Manual for more details about how RPN got its name.
The Stack is what makes RPN arithmetic possible: You don't need to
key in an entire problem at once with an RPN machine because it can
accumulate the intermediate results (partially completed calcula-
tions), letting them "stack" up until it's time to use them.
The first thing to realize about the Stack is that whenever you key a
number into your HP-42S, you're keying it into the X-register. All
numbers are keyed into the X-register.
T: 56.87
)
,------------,
I
Z: 43.6
10.02
y: I
)
L _x.:_~--------- _J
Solution:
OK, but what's really happening when you press that (ENTER] key?
What Is Stack-Lift?
Take a closer look at the inner workings of the Stack as you re-solve the
previous Challenge ....
In these diagrams, the visible portion of the Stack (what you see in the
display), is outlined in the dashed boxes. And the ?'s mean, "some
number is there, but for the purposes of the example, it doesn't matter
what it is."
T: ?d T: ?b T: ?b
Z: ?a Z: ?a
T: ?a T: ?a T: 56.87 T: 56.87
Z: 56.87 Z: 56.87 Z: 43.60 Z: 43.60
- - - - - - - r-------1 - - - - - -----
1y: 43.60 II y: 43.60 II y: 10.02 11 y: 10. 02
l~:_43._§.0___ I ~:J0. 02 _ __ x:J0. 02_ _ x: 6_
IENTER]j'~GI~I::I:§:IIlj'~ !ENTER] j'~ 0 j'
Study this diagram and compare it with your HP-42S display as you
re-solve the example (press (B to clear the 6_ if it's still in your display).
Notice a few things that tell you a lot about how the Stack works ....
1. Often, when you key a number into the X-register, the numbers
in the other registers are "bumped" up one notch (and the value
that was in the T-register is bumped off the top - gone for good,
never to return). This is how the Stack automatically saves your
partial results when you're doing a big arithmetic problem: as
you key in the next number, the previous (partial) result bumps
up a notch, "floating around" above until you need it.
Finally, you disable the Stack Lift- so that ifyou now key in a new
number to the X-register, it will not bump everything else up, but
simply overwrite the previous contents of the X-register.
Right now, you might be thinking that this is an awful lot of detail to
have to remember just to do arithmetic - but don't worry. It takes only
a little practice and the Stack will become as automatic as, say, driving
a car or riding a bicycle!
Putting Two And Two Together
Do This: With your Stack properly set up from the previous Chal-
lenge, press the~ key to multiply together the contents of
the X- and Y-registers.
Result:
ly, 43.60
x: 60.12
( )
Look at what happens to the stack during this multiplication: )
T: 56.87 T: 56.87
()
Z: 43.60 Z: 56.87
----- ----- <)
1 y:10.02 11 y:43. 60
x:-6_- - - - x:-60.12 )
----
~@ j' )
)
When you press the ~ key, several things happen:
)
) And (best of all) at the end of the operation, the stack is left enabled,
so that you can now key in another number to the X-register, and the
previous result (60. 12) will "bump" up to the Y-register- all ready to
be combined with your new entry!
Nuthin' To It: Just key in Gffi, then press 8 * Here's the result:
ly, 43. 60
x: 18.12
And notice how the subtraction operation subtracts the X-value from
the Y-value (i.e. it's "y minus X"), not the other way around. Each
operation that combines two numbers has a specific order (although in
some operations, order doesn't matter).
*Notice, by the way, the efficiency ofRPN here: If this were not an RPN machine, then to do this
example, you would need four keystrokes <8~8. rather than three ~8)!
Chain Calculations
By now you can begin to see the advantages of the RPN Stack -
especially when Stack Lift is enabled for subsequent ("chain") calcula-
tions. For that very reason, most operations will leave the Stack Lift
enabled (indeed, (ENTER) is one of very few keys that disable it).
Now try this problem as a fuller example of the Stack, its lifting and
dropping - and the beauty and simplicity of RPN:
A Solution:
That's not too hard - remember how you were taught to analyze such
involved, chain-calculation problems in school?
T: 18.12 T: 18.12
Z: 18.12 Z: 28,791.50
----- -----
1~ 28,791.50 II~ 8,064.84
x:_?l..06~84 x:_.?~57 __ _
[±) _j' 4 03ill) _j' ~ [8J
Notice that any operations, such as (8) and (±), that combine two
numbers into one result will cause the Stack to drop, but an operation
such as~. will affect only the "X-value," as the name implies.
Of course, there are other solutions, too. For example, you could have
chosen to key in the numbers in the order you encounter them in the
problem: @ITOilENTffi)~~(±)(8)
But this takes more keystrokes than the other way. And besides, if you
limit yourself to this left-to-right method, you simply can't solve a prob-
lem like this one: 112 - (386,000 + {35.7 x (67.12 + {89.43)2)
You have only four Stack registers, remember; and the whole idea of
RPN is that you key in only part ofthe problem at once, reducing it and
simplifying it as you go. So the best way is always to work from the
"innermost" parentheses "outward."
~~~@BlliJ~G~
fil:Ifill~@BlliJB
Answer: 1. 30 ::=- /, 2 9 CJ 7
Getting easier, isn't it? And of course, with practice, you won't be
needing even to think about what's really going on in the Stack as you
do this. After all what would be the point of a more efficient form of
arithmetic if you spent a lot of time trying to remember how to do it and
why it works? ()
)
For now, though, check the Stack diagram opposite, just to be abso- )
lutely sure you know what you're really doing....
)
)
)
)
)
)
)
J
60 An Easy Course In Using The HP-428 )
)
T: 18.12 T: 18.12 T: 18.12 T: 28,791.50
Z: 18.12 Z: 28,791.50 Z: 28,791.50 Z: 28,791.50
----- 1-------1-------~ -----
1y: 28, 791.50 II y: 28, 791.50 II y: 28, 791.50 II y: 44.89
x~8, 791_.20 ~:J.J.=. ___ J ~:_:l4.§_9___ u x:_4=----
'---7 (fil1J _j' ~ ~ _j' ~ 0 _j'
T: 28,791.50 T: 28,791.50
T: 28,791.50 T: 28,791.50
Z: 28,791.50 Z: 28,791.50
----- -----
(8) --7 I y: 10.14 1 y:28, 791. 50 I
x: 7.80 x: 1. 30
Answer: -46. 47
)
)
62 An Easy Coune In Using The HP-428 )
)
That(IDKey
Solution: 2 5 0 0 0 0 0 ENTER 3 0 0 0 0 0 0 X
Answer: 7. 50E 12
Solution(s): r:n:::TilII+/-~~EJ, or
@IJ+/-~~EJ,etc.
Answer:-8.18E 15
But still, nobody's perfect. What do you do if you make a mistake while
keying in a number?
Not To Worry: This is the main reason for the (B key. When you're
keying in digits, it is indeed a simple backspace
key, so use it as such....
)
) OK, but what if you want to get rid of the entire number (i.e. "start
over") altogether? What if it's not just a digit or two-the whole thing's
bad? .. .
) 1 •61803398875ENTER
First, you had the [ENTER) key; now there's l!!ll, too.
)
Yes, But: Now repeat the previous problem - exactly- except
) this time do it the long way: "back out" the erroneous
number with the ~key.. ..
)
Not only that: If you're not keying in a number at all, then~ is not
"backspace" at all - it's 11!!!1 then, also!
Prove It: Do some arithmetic (or anything else that leaves Stack
Lift enabled): O]ENTm)@)(±).
So remember: [ENTffi) and l!!ll are the two common functions you'll use
that disable Stack Lift. And except when you use it to "back out" part
) of the number you're keying in, the~ key is also a convenient l!D key.
Hmmm - come to think of it - is there any way you can check the
current contents of those other two registers (Z and T) - without
messing up the values in the Stack?
T: 8.00
Z: 3.90
r._:-----------,
I y. 4.60 I
L 2<~9~~-------- _J
The@) Key
The@) ("roll down") key causes the Stack to do just that - its contents
rotate or "roll down" by one register. The value in the T-registeris sent
down to the Z-register; the Z-value down to the Y-register, and so on,
and the value in the X-register is "rolled" up into the T-register to
complete the rotation.
So in a@), no numbers are lost; only their locations are changed. The
Stack registers are linked in a circular pattern (hence the "roll"), where
the bottom register (X) is connected to the top register (T).
This means that four consecutive [jff) 's will roll the Stack completely
around once -back to its original state. This is how you can quickly look
at all four values without changing any of them.
So in this last solution, the trick was to roll the Stack down twice - to
get the doomed 3. 90 into the X-register where you could clear it out
with the (B key. Then (because the (B key acts as a l!JJI in this case,
as you know), the Stack was left disabled, so you keyed in o:r::TIJ, then
rolled the Stack down twice more - that's now four@)'s in all - to get
back to the original positions of the values. Pretty slick!
)
)
There's one other key that you'll often find useful to manipulate your
Stack registers: The [x~y] key. Suppose that you wanted to ...
T: 8.00
,--:-----------,
I
Z: 1.30
4. 60
y. I
L 2<:__9~~-------- _J
Now, the challenge is to reverse the order of these values.
The [x~y] key ("X exchange Y")simply exchanges the values of the X- and
Y-registers-which is handy for all sorts of things (not just stupid little
exercises like the one above).
)
For example, the 8 and8 keys are defined only as "y + X" and "y - X"
-not the other way around. So, to divide or subtract in the other order,
you just use (x~y] once to swap the two numbers, then use 8 or 8 . )
)
70 An Easy Course In Using The HP-428 )
)
,)
)
T: T: T: T:
Z: Z: Z:
~ ~ ~ ~
- ----<
Z: Z: Z: Z:
----- 1-------- - - - - - - - - - - - - - -
1-------ill~Y_
: ------ill~Y_:----ill~Y_:- - - - i
x: x: x:
T: T: T: T: - - - - - - i
1
Z: Z: Z: Z:
,-------~,-------i ------- -------
1Y: II y: ll y: ll~Y_:- - - - i
x: x: x: x:
~ ~ ~ ~
1 ------i
Z: Z: Z:
) r-.------ 1- .- - - - - - -.------~
1-------il I y. 11 y. 11 y. I
!:__ _____ J12<:______ I~:__ ____ _
j'~ j'~ _1'
)
The L-Register
OK, ok, now that you've got a little Stack practice "under your fingers,"
it's finally time to let you in on the big secret: "What-in-Lis the L-
register?"
In other words, operations that alter numbers (such as(±),@, and EJ)
will indeed save a copy of the X-value in the L-register before changing
the original in the X-register. But functions that clear or move numbers
around (like (B, [X~YJ,@l, and (ENTffi]) do not do affect the L-register.
"Fine- so what ifyou ever need to make use of this back-up copy? How
do you retrieve it?"
) Here's the key for retrieving that "emergency copy" of the X-register
because you've made a little goof-up during your calculation.
Keep in mind that when you use the ~ key, you're bringing a
copy of the L-register to the X-register; that same back-up value will
stay in the L-register until you next alter the contents of the X-register.
And you can also use~ simply to save yourself keystrokes ...
Answer: 80, 06
All this time (the last 25 pages), you've been learning and practicing
with the tools that are most immediate to your workbench- the Stack.
And look at what you know already:
• You know something about arithmetic - and about how Stack Lifts
(and drops) happen as you're doing a calculation;
• You know that most operations leave Stack Lift enabled-so that it's
ready to lift when the next number is put into the X-register- except
for (ENTER) and l!!lll;
• You know that the~ key can act either as a "backspace" (when
you're keying in a number) or as a convenient way to l!D;
• You know at least a few tricks for manipulating the values in the
Stack- moving them around without changing them -with the [x~y]
and @] keys.
• You know how to use the L-register and the~ key to recover
from an error with a back-up copy of the value previously in the X-
register.
So, in theory, you're perfectly comfortable with all these things, right?
) 1. To double the number in the X-register, you can use the keystrokes
(ENTs=!)@J(8) (three keystrokes). Can you accomplish the same
thing with only two keystrokes?
3. Without using the (ENTffi) key, set up the Stack to look like this:
T: 1.6000
Z: 3.5000
1-.------1
1 y. 2.2000 I
x: 4.7000
4. Using the Stack you just set up in the previous problem - and
without keying in any numbers, compute:
(3.5 -2.2}2+4.7
1.6
) 5. What four keystrokes can completely clear all of the Stack reg-
isters? Don't use the menus for this procedure.
Answer: 1. 90.
Do you see how you can use the [+/-] and ~keys to effectively
reverse the order of 8 and 8. respectively?
0
)
3. First, notice that the display should be set to FIX 4 decimal places
(press~. thenlilllJ@ENTER)). Notice also that the number in )
the X-register should be terminated (i.e. it must have no trailing )
cursor like this: 4. 7_). Here are some of the possible solutions:
u
)
crr::::IT) [x~y JlIEffi [x~y) ffi:::TIJ [x~y [fil) (1Eli) [x~y) or
)
GEITJ[ x~y) (B1Effi[x~y)CIT:li) [x~y)CIEli®) or
ffi:If)[x~vJx~y)~@IJ]J~[x~y), etc. )
The point is, almost any non-digit keystroke except [ENTER) or~ )
(l!!ll) leaves Stack Lift enabled and terminates your digit entry
(whereas [ENTER] disables Stack Lift and terminates digit entry).
Answer: 8. 9988
Well, there is such an animal. It's a "hand tool" - like all the
Stack-manipulation tools you've been using up to now - but it
isn't used often enough to merit a key of its own. You'll find it,
therefore (along with all the "hand tools"), listed in the• CATALOG~
under IEll ("FunCtioNs").
Bigger Hammers:
Higher Math And Other Number-Crunchers
All right, now that you've been introduced to the Stack and its tools,
you're going to start using them as you look at the other tools in your
workshop.
You'll notice that most of the common Stack functions have keys of
their very own (e.g. the arithmetic operations, [x~y),@), (ENTER),~' etc.)
- because you use them so often. You might say that the keyboard is
like a shelf built right over your "workbench," where you keep your
most-used tools "within easy reach" (i.e. you don't have to use menu
keys to go to the hand-tool storage area to "get" these functions).
'
Exponentiation: Roots, Logs, And Powers
) The keys you need for any root, logarithm or power problems, are
located in the top row on your HP-428 keyboard.
Now go the other way: Ifyou have a number that is the result ofraising
a known base (say, 10) to some power, how do you find out what that
power was? You take a logarithm.
Hmmm ••• : The LN function is the Natural Logarithm (base e); the
LOG function is the common LOGarithm (base 10).
Verify this for the common LOG base (i.e. use x = 100 and )
b = 10: )
Next, move down a row, and look at those functions on the three right-
hand keys. It's time you got comfortable with your basic trig tools ... .
What would you do, for example, if you encountered a problem like
this?
Atan(sin(22°) + cos(7t/6) + tan(-125°))
The word trigonometry itself means "the measure of the trigon." And
if a pentagon is a five-sided figure, then a trigon must be ...yep-a three-
sided figure (also known as a triangle).
Each triangle is formed from a radius through the point and a line
segment perpendicular from the point to the horizontal (x-) axis.
The important question is how you know exactly which point on the
circle you're talking about. The points above have been given names
A,B,C, and D, but that isn't a very precise system.
Look at point A above. In order to get to A from the positive x-axis, you
must "sweep out an arc:"
So, how do you measure this circular arc -in what units? The HP-428
offers you three different ways:
One way to measure arc is to split up the circle's total swept angle into
360 equal pieces. There are 360 degrees of angle (or arc) in a circle.
5
-,·~
The total distance around the circle (its circumference) is always equal
to 21t times the radius of the circle. So if the ant walks around the circle
for a distance of exactly one radius, it will have walked an arc length
of exactly one radian. There are 21t radians of arc length in a circle.
Thus, you can measure circular arc either by the angle it sweeps out
(degrees) or by its length (radians).*
)
*The third method of measuring circular arc, as offered by your HP-42S, is not as common as the
other two, but you should know what it is. It was developed probably because 360 degrees is an
awkward, non-decimal number to work with. Thus, there are 400 grads of arc in a circle - or
exactly 100 in each quadrant (quarter part of a circle).
So how do you tell your HP-428 what units you're using in your trig
calculations - whether you're talking in, say, degrees or radians?
But do you remember why you want to measure arcs in the first place?
What does all this have to do with SIN, COS, and TAN -you know... trig?
The ratios of the sides of these right triangles are what make them so
handy for finding distances and angles that you can't easily measure
- such as the height of a skyscraper or the distance across a lake.
Here are those ratios for a right triangle defined by an arc measure of
angle 9:
)
x
)
SINe(()) = ~
r CO Sine(()) = f TANgent(()) = ~
• find the point on the circle at 22 degrees of arc from the beginning
point (on the positive x-axis);
• look at the right triangle defined by that point;
• calculate the ratio y/r for that triangle.
And keep in mind that ATAN(x) means "the Arc (or Angle)
whose TANgent is x." There happen to be a lot (mathe-
maticians say "an infinite number") of angles that have
x as their TANgent (and the same is true for ACOS and
ASIN) - because you can continue to sweep out arc by
going around the circle repeatedly (after all, 22° is the
same point on the circle as 36,000,022°, right?).
~cos)~l!JBOlfill+/-lTANE]
Cill@ffi miliffi
)
88 An Easy Course In Using The HP-428 )
)
One More: Find cos 2(37°) + csc2 (48°) + sec2(156°)
)
Solution: There are two new problems here. First of all, in what
order do you use [cos) and~ Is it first the (cos] and then
the~ - or vice versa?
~
~~(±)
OJ:ill]~~(Yill)
Answer: 3. 6468
Chances are, you're heartily sick of trig by now. But it's nice to know
you have all this right there "near your workbench" (on the keyboard).
The~Menu
Solution: You're really just asking how many ways you can com-
bine 21 objects, taking them 6 at a time. The COMBina-
tions selection in_ this PROB menu will tell you; press:
~ l!!Im Answer: 54, 264. 0000
1----------i~
I
A Deep Breath
To avoid even further marble loss, you'd better stop for a moment now
and survey where you've been and where you're going. This machine
is so jam-packed with stuff to learn that it's going to be very easy to get
lost in the forest while you're trying to learn about each tree:
• Now in this chapter on Tools, so far you've learned only about the
Stack, RPN arithmetic, and some other some number-crunching
tools, including exponentiation, trig and probability.
Not yet. Actually there are many other tools, but they don't all appear
in this Tools chapter. That would be a HUGE chapter-way too much. )
Besides, many of those tools wouldn't even make sense to you yet. )
)
Sure -there are some more you're ready for now-you'll see those next.
But others deal with variables (they'll be covered in the next chapter)
or programming (the chapter after that). And the Power Tools are
even big enough for a chapter of their own. u
So don't worry - you'll encounter each tool when it makes the most
sense to. Just keep this larger perspective as you continue now....
)
92 An Easy Course In Using The HP-428 )
)
A Complete Inventory Of Tool Menus
To help keep that larger perspective, go back and look at the Big
Picture (pages 18-19) once again.
You know now about the Stack, your arithmetic keys, Stack manipu-
lation keys, and some of the other "keyboard functions" that form your
"workbench and tools within easy (keyboard) reach." But now look for
a moment at all the tool menus in your workshop-menus that are part
of the different Storage Areas:
Uses Of Tools
(Up to now, you've seen the first five of these menus, because they're
useful in "number-crunching" on the Stack. But as for the others, you'll
see them when you learn about programming, later.)
(Of these, you seen only the •CATALOG] menu so far, and now that you
know the basics of RPN "number-crunching" on the Stack, the other
Special Use Menus are what you'll see next.)
(Each of these power tools is involved enough to get a section all to itself
)
- but that's later - after you study variables and programming.)
)
94 An Eaay Course In Using The HP-428 )
)
}
Special Use Menus are named such because they just aren't like the
other tool menus. Make no mistake: They are tools - and important
ones. But they're somehow related to other menus in unusual ways,
and so they fall into this catch-all category.
For example, you've already seen the •CATALOG) menu (page 43).
Remember how it worked? You could use it to find and select any tool
or variable you wanted - no matter in what menu you could otherwise
find that tool or variable.
Well, one way to think about the other Special Use Menus is that they
all provide some kind of "special access" to certain tools or menus.
}
The~Menu
Solution: First, press~ to get back to the first page of the menu.
..
Then: IETilm:J:llrnm!. . mml_.mml . . CE!Em!ll
!EiB_!i§i!ll1. .IETillDl~. .!i§i!ll1~rnm!. .
~~
In this particular case, you "called" the llAlPBAJ menu right from your
"workbench" (the Stack). But keep in mind that you can also "call" the
~menu from within any other menu - and when you finish with
your typing (with [EXIT)), the machine will return you right to the menu
from which you "called."
Prove It: Enter another menu, say, llPROB). Now call the~
menu. There'stheALPHAregisteragain: HELLO THERE!
The main task of the ~ Menu is to help you create your own
•CUSTOM] Menu - gathering together whatever collection of tools and
variables you might find convenient.
So, what items do you want to gather into your •cusroMJ Menu? ()
)
)
)
98 An Easy Course In Using The HP-428 )
)
How About: Back on page 77, you noticed how useful the "roll up"
tool could be for Stack manipulations. The problem
was, it took a lot of "thumbing" through the pages of
the •CATALOG) menu to get to it.
But did you notice that when you pressed 8ASSiGffi, the display showed
some quotation marks- as ifthe machine expected you to spell out the
name of what you were going to assign?
Solution:
See how the [ALPHA] key helps you spell out the name
(and signal when you're done)?
This is usually true whenever you're going to use the ALPHA menu to )
spell out the name of a tool, variable or command (rather than put
actual data into the ALPHA register): you don't need to press• first;
the context of your other keystrokes (in this case, 8ASSiGN)) will tell the
machine what you mean.
)
)
100 An Easy CouNe In Using The HP-428 )
)
J
Now Undo It: You don't really want two copies of the 1111 tool on
your •CUSTOM] menu, so here's a good opportunity to
learn how to "unassign" an item from that menu:
One More: Just so you know - besides tools, you can also put
variable names on your •CUSTOM] menu.
As you learn about these Special Use Menus, it's important to realize
that there's a certain hierarchy to all the menus in your HP-42S.
That is, there are some fairly simple rules about which menus you can
"call" from which- and whether you will return to the "calling" menu
after finishing with the "called" menu.
(-~~~~~~~P_o_w_e_r_~_o_o_ls~~~~~~__...)
()
( Hand Tools and Special Use Menus )
)
( ALPHA Menu )
(
)
If you call a menu lower than where you are, when you return, it will
be back to the menu from which you did the calling.
)
However, if you call a menu higher than your own level, you'll actually
be "jumping" to the highest level (the Stack) and "calling" from there;
for when you return, you'll return to the Stack.
Ofcourse, whether your returns are automatic or require you to use the )
[EXIT]key will depend on the circumstances. This hierarchy merely )
shows your return "destinations." Experiment with it until you get the
)
idea. Where do you return from a call at the same level where you are?
)
102 An Easy Course In Using The HP-428 )
)
/
With this hierarchy in mind, it's a lot easier to understand the reason
for this last Special Use Menu. You might have wondered why the folks
at HP put the six top-row keys onto its own menu as well ....
Try This: "Call" the Power Tool .SOLVERL Don't worry about what
you might be doing there. Just suppose you're there and
now, for a side calculation, suppose you find yourself
needing to compute (113)·5 •
Over the last 30 pages or so, you've seen quite an inventory of the
various tools in your HP-428, and its time you "graduated on to the
next part of the Course" to build something with all these tools.
But before you get going, maybe you'd better check your understand-
ing so you don't get bogged down later on.
log(122 +~)
2. Find
eJ
L~or~
Answer: 3, 0000
Finding the "eighth root" is the same as "taking the l/8th power."
And then (6561) 118 is the same as (((6561) 112 ) 112 ) 112 , which is also:
../vv6s61.
3. ~CIT:TIJ8)~(filB@(fil)
Answer: 18, 8739
}
106 An Easy Course In Using The HP-428 )
)
5. sin(180°): ~lffillo:IillJ@m Answer: 0. 0000
sin(rt): ~IBti@m Answer: -2. 0676E-13
The difference is due to the fact that you're not really taking the
SINe of 7t radians. You're taking the SINe of 3.14159265359
radians - and that's different. Like any finite machine, the HP-
42S is limited to using an approximation ofa, not 7t itself. Nobody
can ever use the "exact" value ofany irrational number (one with
an infinite number of non-repeating digits).
Nope. That's a problem .... Ah, but isn't Acot(37t/4) the same as
Atan(4/37t)? (think about it- and review page 86 if you need to).
To compute this, first make sure the machine is in RAD mode (by
pressing~ Bm!, if necessary).
.CONVERT)mE
Result: 22. 9970 (these are decimal degrees, remember)
)
)
)
(b) When you then select a hand tool menu, you'll see (the first
page of) that menu. For example, press m@Q@.
(c) When you select a hand tool from that particular Menu, the
display will automatically revert back to the Power Tool
(unless you had pressed the hand tool menu key twice upon
entering that menu - step (b) above - in which case, the
display would return to the hand tool menu). For example,
press GB.
If the functions and operations are the "tools" in your HP-428 work-
shop, then your "raw materials" are the data you "crunch" with them.
Remember (from page 36) that your HP-428 can handle four types of
data: real numbers, ALPHA-characters, complex numbers, and matri-
ces. It's time now to learn the details about how to name, store and
retrieve these various data types.*
Most of the data you've used so far have been only temporarily useful.
That is, you used the numbers only once during a quick problem-
solving session; it hardly seemed necessary to name or save them.
You would save this number in one of those data-bins you can create
and name - a variable.
*Unless, ofcourse.you already feel comfortable with some of these things, in which case you should
skip ahead. So, ifyou already know about storing and retrieving real and ALPHA variables, skip
to page 126; ifyou also know about complex variables already, go to page 134; and ifyou also know
about matrices already, jump ahead to page 155.
Solution: First, obtain the value of e (at least its 12-digit approxi-
mation): press~·
Notice that with ISTO] you don't need to press the• key )
)
)
)
Try Another: Store the value 6.92 into a variable named FRED.
Yes, but how do you know that your calculator has really STOred your
numbers? Is there a way to find out for sure - to verify this?
There are a few important things to know about the [STO) key and what
you're really doing when you use it:
• First of all (as you probably already know), [sro] stores the value
that's currently sitting in the X-register. This means that if you
want to store a value now sitting somewhere else, you'll have to
bringit to the X-registerfirst (probably by using the [RCL)key), right?
• Secondly, [sro] is a copying process. That is, when you [sro] a value
into a variable, you are storing a copy of the value that's currently
sitting in the X-register. Notice in the previous examples that when
you finished ~ng, the value was also still in the X-register; only
a "clone" was sent into the variable.
)
• Since it is a copying process, [sro) doesn't affect the Stack very much.
It certainly doesn't lift the Stack or alter any value in the Stack
registers. But keep in mind, that, like most functions on your HP-
42S, [sro] will leave Stack Lift enabled - so that if the next action
taken brings a number to the X-register, the Stack will preserve the
X-register's previous contents by bumping the whole Stack up.
And now notice these details about [RCL) (compare them with (STo)):
• [RCL) recalls the value from wherever you specify and brings it to the
X-register - nowhere else.
• Whenever you [RCL] a value from a variable, you are actually making
a copy of that variable's value and placing this copy in the X-register.
• [RCL) does affect the Stack of course, since it's bringing a value to the
X-register. Does this new value "bump" the Stack up in a Stack Lift?
That depends. {RCL}behavesjust as if it were "keying in" the value:
If Stack Lift has been left disabled by the previous action (say, [ENTER)
or [B, for example) then this (copied) value that (RCL] is bringing to
the Stack will overwrite whatever had been in the X-register
previously-just as you would do if you were keyingin a value under
these circumstances.
However, if Stack Lift has been left enabled, [RCL] will bump every-
thing up and insert its new value underneath - again, just as it
would work for you ifyou were keyingin a value to an enabled Stack.
See how [STO) and [RCL) work together to help you save and retrieve data
conveniently? To make sure you understand, try a few more ....
Solution: Yep - press@) four times to check. ... The 1. 0000 that
had been in the X-register is now in the Y-register. This
is because the keystroke immediately prior to the (RCL)
was a digit-entry keystroke (a [D), which left Stack Lift
enabled. Remember that most keystrokes - including
the digit-entry keys - leave Stack Lift enabled.
What If: You press @[sro) !iilE [RCL) !ii!E. How many copies of
4. 0000 will this produce? Where will they be located?
Solution: You'll have three separate values of4. 0000: the original
you key in, the copy of this original that you save into
IJll:E by pressing [STO), and then a copy of this copy that
you put back into the X-register when you press [Rel).
That's two 4. 0000's in the Stack (the original in the Y-
register, the second copy in the X-register) and one (the
)
first copy) in !ii!E!
)
116 An Easy Coune In Using The HP·42S )
)
And now, discover a few more places you can store things:
Try This: Calculate 5.67 x 7.833 and store the result in the data
register R08 (recall from page 41, these registers are the
individual elements that make up that built-in matrix
called REGS. By special design, remember, you're al-
lowed to refer to these elements individually by name).
Challenge: Put 8. 7900 into the Z-register without using lim or@).
)
J
There's one other clever thing that [STo) can do, too: It can work in
combination with the four basic arithmetic operators((±), 8 ,(8), and EJ)
to alter the contents of a variable or register.
And where does the answer end up? It's not in the X-
register-it's in FRED! Press [RCL)~ and see that it no
longer contains 6. 9200 (its previous value), but now
34. 6000 (fives times as much).
)
118 An Easy Counte In Using The HP-428 )
)
OK, so how about [RCLT? Can you do this kind of shortcut with the [RCL)
key, too? Hmm ... how do you suppose a keystroke sequence like [RcLG
would work?
Try This: Divide the value of EE into the value of R08 and take the
square root of the result.
-A
Real Variables
'
All this storing and recalling you've been doing so far has involved just
a couple of variables (EE and FRED).
And these are real variables because they contain real-number values,
right? So you should have a good grasp of how to create real variables
- but just to be sure, try one more.
Behold: ~®::Iill)~~B
That's the calculation (Answer: 3. 7104 ).
And now, whenever you [RCL) or look in the •CATALOG], you'll find the
variable LORI along with EE and FRED.
0
)
All this should seem pretty familiar by now, no? )
)
)
120 An Easy Course In Using The HP-428 )
ALPHA Data And The ALPHA-Register
All right, so much for real variables. But recall (from page 38) that a
real variable is a named "storage bin" that can contain either one real
number (as in EE, FRED and LORI) or an ALPHA string (up to six
ALPHA characters), right? So, try one with a string now....
HOWDY!
This is because you were at the ALPHA menu (in "ALPHA mode") at the
time, thus STOring something directly from the ALPHA- register into
the named variable. In other words, you were Alpha-STOring.
Try This: Put the ALPHA-string, THE ANSWER IS, into a variable
named YEP.
Just remember that you're dealing with ALPHA data and the ALPHA-
register (and that you can't do any math with it).
But you haven't used ARCL yet! The (RCL) you used in the last example
was a normal (RCL) that put a copy of YE P's contents into the X-register
(remember? you pressed (RCL)after you had [EXIT)ed from ALPHA mode).
Just as ASTO had a few details to learn about, so does ARCL. ...
Such As: Use A(B£g to recall a copy of the contents of FRED to the
ALPHA register.
()
124 An Easy Course In Using The HP-428 )
<)
Yes, But: That phrase in the ALPHA-register isn't quite "pretty"
yet. Fix this small glitch and put in the missing space.
OK, [EXIT) from ALPHA mode and press •CATALOGl#l• to confirm that
you've now created five real-type variables: ~'.::rm, l!illl), (ifil, and
IBlll (remember: variables containing ALPHA characters are real-type
variables, too)!
Complex Numbers
The first of these is the complex data type. Complex numbers are
mixtures (linked pairs) of real and imaginary numbers. A complex
number is the sum of a real number and an imaginary number.
Well, real numbers and imaginary numbers are truly different "direc-
tions," mathematically, and so you can't mix them directly. Instead,
you represent their mixture (a complex number) as coordinates (i.e. as
a vector) on a "map" (the complex number plane); the horizontal direc-
tion is the real direction and the vertical is the imaginary:
i3
Imaginary i2 • Complex number
i1
2 3 4 5 6
Real
-i2
The problem is, just as there are many ways to give directions to any
one destination on a map, there are many different ways to represent
complex numbers in the complex plane.
So how do you know which notation to use with your HP-428? Well,
there are two common strategies or formats used to describe a complex
number's "destination" - rectangular and polar.
Your HP-428 will always display the rectangular form as 3 + i2. The
3 is the real (or x-) cofficientand the 2 is the imaginary (ory- )coefficient.
The other way to describe a destination is to give a distance and an
angle "north of east" (in either degrees or radians). This is the polar
format:
Imaginary i2 (3.6L33.7°)
i1
x
2 3 4 5 6
Real
-i2
Notice that simple trigonometry will tell you what the two rectangular
legs of this triangle are - simply from knowing the hypotenuse (the
distance) and the angle:
And then remember that you can specify an angle either in degrees or
radians: 3.6(cos 33.7° + isin 33.7°) =3.6(cos 0.6 + isin 0.6), right?
Finally, you could dispense with any reference to the rectangular form
(i.e. omit the i notation altogether) and just describe your destination
with the bare minimum - the direct distance and angle: 3.6L33.7°
Since this latter form is so short and succinct, it is the polar form used
by the HP-428.
And what does the answer look like in polar radians mode?
To find out, press m. Answer: 5. 0000 .il 5708 I
)
)
The point is, it's always the same number; the~ menu simply )
offers you different display formats -just different descriptions of how
)
to get to the same complex destination:
)
)
)
)
130 An Easy Course In Using The HP-428 )
)
Seeing Vs. Doing: The Difference Between The
•MODES) and •CONVERT) Menus
Back on page 85, you learned how to change the units of angular
measure with the ~menu. When you went back and forth be-
tween, say, DEG and RAD, the number didn't change, did it? In order
to actually change the numerical value in the X-register, you had to use
the Cml and~ selections in the •CONVERT) menu, right?
In the case ofreal numbers, your HP-428 was saying, for example, "The
44. 4506 in the X-register is 44.4506 degrees right now, as far as I'm
concerned." Then, when you chose lirn!I, it said, "OK, now it's 44.4506
radians" (and it turned on the annunciator to alert you to this re-
interpretation). But it still had the value 44.4506 in the X-register. Now,
with complex numbers, there are simply more ways to alert you to the
current interpretation: The display changes the format of the number
itself - not just an annunciator. But the underlying value in the
machine's memory is still the same. You cannot actually alter a nu-
merical value with the lfMODES}menu - only with the •coNVERT}menu.
All right, now that you know how the HP-42S handles and interprets
complex numbers, you'd better learn how to enter them, no? So far,
you've encountered them only as results of your calculations. But what
if you want to key them in - build them from scratch?
)
)
132 An Easy Coune ln Using The HP-428 )
)
And naturally, you create complex variables to store complex numbers:
If you press [EXIT)[RCL] you'll see that you now have two
menu pages of variables that you can [RCL] (the T•is on),
since you now have more than six such variables. And
pressing mB confirms that you've done it all properly.
The Bad News: It's time for a review of the basics of complex-number
arithmetic.
I
I
)
2. (5L166°) - (-4L39°) )
4. ~rn~lil'illlffi+/-}ENTs=!]l[iijEN@J
~~~fi~(18
.COMPLEX]E)
Answer: 0. 7500 .i1. 6755
*See page 92 of your Owner's Manual if you'd like more details about this conversion.
Well, for one thing, remember that a complex number is nothing more
than a two-dimensional vector - a pairing of two different coordinates
or directions (recall page 126). And those directions don't have to be
limited to "real" and "imaginary."
Thus, you could use the two parts of a rectangular complex number to
represent, say, a position (north and east) on a map. Or you could rep-
resent a velocity (speed and direction) as apolar complex number.
)
Challenge: Assume the pilot of a plane has its nose pointed on a
heading of 95 at an airspeed of 450 mph. But he also has
a hefty cross-wind of56 mph blowing at a heading of167.
What is the groundspeed and true heading of the plane's
flight?
Solution: The engine velocity and the wind velocity must be added
together to find the total plane velocity. You can add
these two vectors by treating them as complex numbers.
So the problem becomes: 450L95° + 56L167°.
Notice that this navigator's coordinate system is different than the one
you saw on page 128 for complex numbers (and on page 83 for trigo-
nometry). But this vector math still works!
The beauty of vector math is that it doesn't matter where you call
"zero," as long as you're working with a rectangular or polar coordinate
system; you'll always get answers consistent with- and correct for -
the system you're using!
George
W 270° f--~!}----~~~Ernie
Frank
180°
s
Solution: Like velocity, force is a vector quantity, with both mag-
nitude and direction. To solve this problem, you must
sum the three force vectors: George's force vector is
195Ll05°, of course, and Ernie's is 180L90°. The bearing )
at which Frank is pushing is (105-30), or75, so Frank's )
force vector is 175L75°.
)
)
So the boulder rolls away at a heading of 90.6° (almost exactly the
direction Ernie is pulling - very efficient of them). And the total force
acting on the boulder is 537.4 N. )
)
138 An Easy Course In Using The HP-428 )
J
Again (as these examples illustrate): Although complex numbers are
themselves mathematically meaningful (and there are plenty of opera-
tions that use them as such), you 're not limited to using them just as
complex numbers. You can also use them as two-dimensional vectors.
In fact, you can even use them for non-vector applications - simply as
a convenient ways to group related number pairs. Because you can pull
complex numbers apart and put them back together again, you can
give your own meanings to the complex number data type in the HP-
428 - meanings unrelated to the mathematical concept of complex
numbers or directional vectors of any kind. You can use complex
variables simply to store and manipulate ordered pairs of real num-
bers - information objects for you to use in whatever way you see fit.
~~COMPLEXITIIJENTERfIGJ•coMPLEX)
®I)[ENTER)@li).coMPLEX]ffi±).
Matrices? .... Ah, yes .... Looks like you're now ready to study this fourth
and final type of data. Matrices are the most powerful and most
involved of all the variables and data types - so much so, in fact, that
the HP-428 workshop has an entire work area dedicated to helping you
build matrices (see the Big Picture on pages 18-19 for a quick
reminder) .... Welcome to your first Power Tool!
l
2x3 3x2 1x5 3x3 3x1
l
[4 5 9
2 -2 I
[~ ~ l [-3 9 0 7 2 J 1 0 0
[ 9 -3 5
2 7 -1
The number ofrows is always listed first, then the number of columns.
Hmm ... If you think about it, a complex number (or any two-dimen-
sional vector) is really just a small (1 x 2) matrix, right?
Matrices are incredibly useful tools for solving problems. That's why
your HP-428 devotes so much power and memory to them. They allow
you to solve large (or small) systems of simultaneous equations in ways
much faster and easier than any other. You'll find these systems in
physics, engineering, economics, business, and most other sciences
and social sciences.
And best of all, matrices give you the only feasible way to calculate
physical phenomena in higher dimensions (part time! on weekends!).
With matrices, you can describe how subatomic particles move through,
oh, say, 10 or 11 dimensions -whatever you need to make your calcu-
lations come out right (without even building a clay model)!
So how do you get a matrix into your calculator? You need to start
learning to use that Power Tool Room now.
Well, the very first thing to do is tell your machine the dimensions of the
matrix you're about to enter. It needs to prepare the necessary amount
of storage space before you dump in a bunch of data.
Press •MATRIX) to enter the Matrix Power Tool Room. You'll see its
Main Menu:
The annunciator, T .a., tells you that there are more pages of menu items,
- but first things first: Choose Cim, to declare this new matrix you're
)
creating, and notice what happens ....
)
142 An Easy Course In Using The HP-428 )
)
See? Your calculator has combined the row and column dimensions you
just entered into one single dimension statement (similar to the way
• COMPLEX]combines theX- and Y-registers into one complex datum) in the X-
register:
TA
x: [ 2x2 Matrix J
Ciml!aDDiIBmmmmD
In effect, your HP-428 is now saying, "OK, I've got this 2 x 2 matrix
sitting in the X-register, all ready to edit or crunch."
Great.
Only problem is, there's nothing much to edit or crunch yet. This
newborn matrix is still full of zeroes and unnamed; in order to put some
meaningful data into it, you need to use the Matrix Editor!
You find the Matrix Editor by choosing Im):
.......
1:1=0.0
IDll!l!l. . . .rnm. .
This menu now tells you that you've taken this current matrix (the one
that was in the X-register) into the Matrix Editor, where you must go
to enter or change any of its data.
While in the Matrix Editor, you'll see only one element at a time. For
example, upon first entering the Editor here, you'll see the upper-
leftmost element in the matrix: The notation, 1: 1=0, 0, means that
the matrix element at row 1, column 1 is currently the real value 0, 0.
[ ~ 1]
You need to key in 0 in this window and then move the window one
column to the right by pressing llJlll.
Finish keying in the matrix: @)11110 and then (EXIT] the Matrix Editor
(going back to the Main Menu of Matrix). This essentially places this
newly-edited version of the matrix back into the X-register, replacing
the previous version.
)
.J
Storing Matrices
Before going any further, you should store your matrix into a named
matrix variable. After all, entering the data into matrix is a tedious
task, and you don't want to do it more than once. Remember that this
matrix can get bumped off the top of the Stack just as easy as any other
datum!
So press (SfOfACP8A) MATT[ALPHA) (by now, you've certainly got the hang
of using the ALPHA menu to spell out names and things, so you're not
going to see all those hideous "typing" keystrokes anymore - just the
letters themselves - you know what to do, right?).
It's just as simple as storing into any other kind of variable, right? You
now have a brand-new matrix variable named MATT.
Try recalling it: First press~ to clear the X-register. Then [RCL) lmll.
There's MATT!
Editing Matrices
Done!
[ 7 6 -3 ]
3 4 8
Now reenter the Matrix Editor with Imm. mii) and find
the last value in the first row 1: 3: 1: 3=3. 0
[74 63 ] - - - - - 7 [7 6 3j'
4 0 0
Back on page 40, you learned that a matrix can contain either all real
elements or all complex elements, but not a mixture. It's time to see
how complex matrices work.
10 + i4 i58 ]
Example: Create this complex 2 x 2 matrix: [
-3 + i2 -17
How To: First, create a real 2 x 2 matrix: ~@}ENTER) mm.
Next, copy it to the Y-register, (ENTER), then combine the
two real matrices into one complex matrix by pressing:
• COMPLEX]-just like you did to create a complex number )
from two real numbers! 0
Whether it's real or complex, there are a number of things that you can
do to a matrix once you get it into the X-register.
The first category of things you can do is called scalar arithmetic. This
is where you do something - the same something - to each element in
the matrix. In the world of matrices, a simple number is called a scalar.
Example: Multiply the real matrix, MATT, by the real scalar 4.7.
That is, multiply each element of MATT by 4.7.
Ofcourse, you can combine a matrix and a scalar in any ofthe four basic
arithmetic operations.
Solution: [D[sroB lmill: That's it. And if you edit MATT now,
here's what you'll see:
[6 5 -4]
2 3 7
How about some of the other one-number functions- such as@ or~
How do they work on a matrix?
Try One: Make sure you're looking at the Matrix Main Menu,
then [RCL) MATI and choose Dm. What happens?
You also have these two functions that let you expand or shrink a
matrix - by a whole row at a time:
Of course, you may not yet see when and why you'd want to use such
)
reshaping functions, but it's good to know that they're there (you'll see
some examples of their uses in upcoming problems).
The first of these, El'.I, is the inverse or reciprocal function. Recall from
your school days that the multiplicative inverse of a number is what
you must multiply it by to get 1. So, for example, 1/3 is the multiplica-
tive inverse of 3, because 3 x 1/3 = 1.
But what's the inverse of a matrix? There's nothing you can multiply
by a matrix to give you 1. Besides, you don't want a 1, anyway; you want
the matrix equivalent of 1-the matrix identity, which, when multiplied
by any matrix, gives you the matrix back again Gust as multiplying any
number by 1 gives you the number back again).
Identity matrices are all square matrices with 1'son their left-to-right
diagonal elements and O's everywhere else, as in these examples:
1 0 0
[0 1 0
0 0 1
l 1000 ]
[0 1 0 0
0 0 1 0
0 0 0 1
The multiplicative inverse of a matrix, then, is another matrix, which,
when multiplied by the original, gives you an identity matrix in the
pattern of those above. And it turns out that the only matrices that have
these inverses are square matrices.
Try One: Make MATT into a square matrix by deleting its last
column. Then find the inverse matrix of MATT.
Now you can delete that entire third row by entering the
Matrix Editor (IEII), moving to that row with the arrow
keys, and pressing~ m!jlEXff).
[ 0.375 -0.625
--0.250 0.750
l
Now [EXIT) the Matrix Editor and store this inverse
matrix as TAM.
Solution: For TAM, you need only press IDI, since TAM is still
sitting in the X-register from the previous problem.. ..
Answer:0.125
Now that you have an idea about what you can do with only one matrix,
what types of manipulations can you do with two matrices?
OK, but before you get started with that, consider this: When you do
operations involving two matrices, it's important to pay attention to
their dimensions. There are strict rules about how matrices can
combine with another. And when you violate these rules on your HP-
428, it'll tell you: Di Mensi on Error . So remember these rules:
[~ ;l[
-1 1
4 -3 -2 0 =
1 -2 0 3
l
3(4)+2(1) 3(-3)+2(-2) 3(-2)+2(0) 3(0)+2(3) J [ 14 -13 -6 6
[ 4(4)+5(1) 4(-3)+5(-2) 4(-2)+5(0) 4(0)+5(3) = 21 -22 -8 15
-1(4) + 1(1) -1(-3) + 1(-2) -1(-2) + 1(0) -1(0) + 1(3) -3 1 2 3
1. B + E 2. D+ F 3. A+C 4. CE
5.AC 6.CA 7. B+ F 8. BF
And there are two other types of common matrix multiplication, also:
That's about it for this chapter on data and variables. They are indeed
the raw materials used by your calculator to shape solutions for you.
The next step is to learn how to fashion your own tools from the
workshop's built-in tools.
But first, of course, you need to test yourself- to be sure that you don't
ever become exasperated, perspirated, and otherwise unduly vexed
with data and variables ....
u
160 An Easy Coune In Using The HP-428 )
4. Sometimes you can take the square root of a matrix and some-
times you can't. Why?
[~ -~ l
Now find the inverse of this, then the determinant of the inverse.
7. During this chapter you created and stored the matrices, PIXY,
MAT, and TAM. Calculate the determinant of the solution matrix
to the following problem:
)
3. a. Because the number in X is complex, pressing• COMPLEX] will
split this complex number into two real-number parts. The
first part (formerly the real part of the complex number) will
be stored in Y, the second (formerly the imaginary part of the
complex number) in X. The other complex number (that had
been in Y) is bumped up into the Z-register.
4. You can always take the square root of a complex matrix without
worrying about whether any of your elements are negative. But
when working with a real matrix, you can take the square root
only when all of the elements are positive in sign. Otherwise,
you'll be trying to put complex elements into a real matrix.
5. KeyinandnameA: ~Cimmil@J._Cfil
. . @+!-)[EXIT)[STO) lliJm.
[ 0.167
0.083
0.250
-0.125
l
Find the determinant of this: [EXIT] IHI Answer: -0. 042
)
c x B: [EXIT) [RCL) . . [RCL] . . (!) ~
Answer: [ 0.000 0.000 -28.000]
The answers are opposite in sign! )
)
164 An Easy Course In Using The HP-428
7. Go to the Matrix Main Menu. Then [RCL) mi.I [RCL) lml [IJE)[RCL)
Programming
J
Programs: A Different Kind Of Tuol
Up to this point, you've worked with various hand tools and data types
- the raw materials that you manipulate with your tools.
What about programs? Are they a special type of tool or a type of data,
or what?
At one level, programs do look a little bit like data. After all, they're
stored in memory and are assigned names. But that's about as far as
the resemblance goes. Programs are really tools: they do things to
data you've entered - just like the built-in tools you've already seen.
You can think of programs as little robots that you build to take care
of the more repetitive tasks in your workshop. So this chapter is
dedicated to the building of little HP-42S "robots" - tools that know
how to follow your instructions.
\ \
r
A Little Memory Reminder
Before you get started on building programs, you'd better review how
programs affect the amount of memory available in your machine.
As you recall (page 43), you can review the contents of your various
storage areas by pressing •CATALOG] and selecting one of the menu
choices to see the names of the objects stored in each area. So do it:
You have 6444 bytes of memory with which to create your programs (of
course, if you've stored additional variables, you'll have less than 6444.
But how much memory is a byte? To get some feel for this, clear a few 0
variables to see how many bytes you "free up." 0
168 An Easy Course In Using The HP-428 )
( )
Do This: Clear matrix variables A, Band C, and then check to see
how many Bytes this clears.
Another: Now clear the complex variable PLEX, and find out how
much memory you save.
One More: Clear the real variable, FRED, to find out how bigit was.
All right, those are variables. Now how fast do programs "eat up"
memory? To find out, you'll need to begin working in Program Mode.
The first thing to notice about the~ key (sitting there on the
bottom row of your calculator) is that it is your access to a "mode," - not
a menu like most of the other "shifted" functions on your keyboard.
And~ activates such an important mode that it gets its own key
instead of being relegated to the 9MOOES)Menu.
When you're in "normal" mode (often called Run Mode) and you use a
tool or store a variable, you're actually doing something with your data
at that moment - directly "crunching" as you press the keys. Data is
moved around in the stack, values are calculated or stored, etc.
)
But in Program Mode, most of your actions are treated as a "set of )
recorded instructions" - instructions for doing something in the future .
And when you've written these instructions and given them a name,
you've built a program.
Of course, when you're ready to run your program, you must then get
out of Program Mode (back into Run Mode -yep, that's why it's named
that).
• The first two digits of each line are line numbers - 00 and 01 here.
• The first line of every program is numbered 00, and it tells you about
the size of the program. Here, because there isn't any program yet,
it says just that: you have a 0-Byte PrograM.
• There's a small arrow c•) following the line number. This is the
program pointer, which is what the machine uses to "keep its place"
in program memory. Since you may occasionally be unsure of the
position of the program pointer, this little arrow in the Program
Display is your reminder.
Try This: Find out how many bytes a digit takes up when you key
it in as an instruction in program memory.
Try This: Find the keystrokes you need to convert 97°F to °C.
Well, running through these keystrokes fifty times (once for every tem-
perature you took in your experiment) is going to be no fun at all. You'll
be repeating the same eight final keystrokes ((ENTER]@ITE)(ill9(ffi)
over and over - once for each temperature datum. A big, big drag.
Did you know you were already programming (at least, on paper)? The
keystroke sequence you developed as a solution to this equation is
indeed a program.
Right now, the program is not stored in your calculator, but in your
mind (and on the previous page). When you worked through the
sequence of keystrokes to convert a Fahrenheit temperature to Cel-
sius, you actually visualized ("called up") a logical sequence of instruc-
tions in your mind and (possibly with the help of your fingers) worked
through these, step-by-step, starting with [ENTa:I] and ending with EJ. )
)
All you need to do now is to turn this set of mental instructions into
ones that your HP-428 can understand.
How To Start A Program
At the beginning of this chapter, you observed that programs and vari-
ables are somewhat alike because they both have names. That's true,
but the name of a program is more often called a label.
Solution: Make sure you're in Program Mode. Then use the ~key
to clear that experimental line 01 58_, so that you see
the Permanent • END. on line 01 .
00 ( 9-Byte PrgM }
01KBL 11 FIRST 11
What happened to the. END. in this example? Press(!) and find out.
Aha! It's now down on line 02. You have inserted the label between the
00 line and the • END. Press ~ to go back to line 01.
But, whenever you use a Menu, the~ and(!) keys will revert to their
traditional function of cycling you through the menu pages - even in
Program Mode. Therefore, to BST and SST when a menu is showing
in the display, you'll need to use the ~ and ~ keys ....
Try This: Choose the •PGM.FCN] menu and then step backward to
line 00 of your program. Now step forward to line 02.
Solution: •PGM.FCN]~~~
)
Get the idea? Press [EXIT~
Challenge: Now finish keying in this program, 11 FIRST 11 that con-
verts a Fahrenheit temperature to Celsius.
II.___~~.~ _II
Notice how each line you key in will be inserted following the line you're
viewing. And the pointer then moves to the new line.
OK- that's it, then. You've got this program all ready to go ... right?
How do you tell the calculator that you're finished entering a program?
You tell it to END.
END is an instruction like any other. It tells your machine that this is
the last instruction in the program. There are three ways to put this
instruction at the end of your program:
• You can select END from the •CATALOG] (El Menu: •CATALOG] (El
~rnl!I and then [EXIT].
The [xEa) key will become one of your favorite programming keys as
you get to know it better. It allows you "spell out" any function from
any menu - as an alternative to pressing a key or choosing a menu )
item.*
• Or, you could press~- This means "Go TO the END with
the two c:J's - the Permanent , END. - and prepare for a new
program." In doing this, the calculatorautomatically places an END
instruction as the last line of your program (if there's not one there
already).
*Of course, this means you need to know how to spell the function correctly. You can find th e correct
spellings of all the functions in your Owner's Manual's Operation Index, starting on page 310.
So choose one of those three methods and do it now.. .. When you finish,
notice that you're still in Program Mode cEND does not change that), but
you're now positioned to line 00 of a brand-new program.
Try This: Confirm that you've properly entered your END by look-
ing at the program FIRST again.
Solution: [EXIT) from Program Mode, then press •GTO) [illil m:PRGM),
which should bring you to the Program Display with
yourprogrampointeron: 01KBL 11 FIRST1'. Now, using
the~ key, BST around to line 09, where you should see
an END.... ... sure enough!
Answer: When you see • END. in your display, you know the pro-
gram pointer is positioned to the very end of program
memory (and the last program in memory- the one just
"above" this. END. -is always the oneyoukeyedinmost
recently). There is only one. END • .
Notice that when you pressed [XEO], the label "FIRST" appeared as a
selection on an XEQ Menu. Your machine knows that when you want
to execute (run) something, you're going to be referring to a label.
But why did you use the [XEO] key for only the first datum, but then just
the [RIS) (Run) key after that? Because after the first time through your
program, you knew that your program pointer is positioned within
)
that program. So when the machine stopped after encountering the
END instruction, a mere [RIS]was all that was necessary to get it to cycle
around and start at the top again. But on the first time through, you
didn't know where the pointer is; it could have been in another )
program entirely - so you used [xEa) to jump to the correct label.
( )
Editing A Program
Suppose now that you want to include the FIX 01 procedure in the
program Fl RST -so that the program would automatically change the
display precision. How could you go back and add in this feature?
Solution: ~~0.
I
/
:'/ ! '
I
I l
/ / I/
I I .
.
Moving Around In Your Program
• You can also go immediately and directly to any line in the current
program without using SST or BST. For example, to move the
pointer to line 07 in your FIRST program, you could ...
Like This: Without using SST or BST - but while in Program Mode
- go to (i.e. move the pointer to) the label, 11 FIRST 11 •
Nothing to it!
But Notice: Press~ a couple of times, then [EXIT] out to Run Mode.
Now move the pointer back to label "FIRST" again:
)
)
( )
What Do You Know?
• You know how to find the permanent • END. and prepare for a new
program;
• You know how to move around within a program, either step by step,
or more rapidly;
• You know how to "run" or "execute" a program using the [RIS] and
[xEa] keys respectively;
• You know how to find out how much memory you have left.
Suppose you want to write a program to calculate the volume and total
surface area of a cylinder, given the radius (r) and height (h). The
relevant equations are:
There'll be two inputs (radius and height) and two outputs (volume and
area) in this problem, right? You'll have to be careful to avoid mixing
them up. How are you going to do this?
First: Write out in words exactly what you want your program
to do.
All right, that's not asking too much of your HP-428-especially if you
take these "wants" one at a time, in the order you listed them here.
That's the essence of programming - breaking a large problem down
into an orderly series of smaller, simpler problems. )
)
186 An Easy Counte In Using The HP-428 )
)
But before you start on these problems, you need to prepare a space and
a name for the new program ....
That Is: Begin a new program in program memory and name it with
the label 11 CYL 11 •
Like So: •GTO EE)m:PRGMJ takes you to the end of program memory
and puts you into program mode.
Now begin the new program with a label to name it: Press
•PGM.FCN.PGM.FCN) (twice because you'll use this menu
often while programming), andl!]]l llll!Il . . l!EiB . .
~--(ALPHA).
Now, the first thing you wanted the calculator to do is to prompt you
for the "inputs" -making it clear as to which one it wants, so that you
don't mix them up.
Well, you can actually tell it when to expect a particular input by using
the llm!IJfunction.
Try It: Tell your calculator to stop, prompt for, and store two
inputs. The first one should be stored in a real variable, )
R (for radius) and the second one in a real variable, H (for
height).
)
)
)
188 An Easy Course In Using The HP-42S )
)
Well, it is simple. The INPUT instruction does a lot automatically for
you. Whenever a running program encounters an INPUT instruction,
it does several things. Take a look:
• Next, it prompts you for the value you want to store into that
variable - by replacing your normal view of the X-register with a
prompt, showing the name ofthe variable and the variable's current
value (which will be zero if it has just been created).
• Now it's your tum: You key in the new value to store in the variable
and then press the[RIS)(RUN)keyto continue (of course, since you're
being shown the current value in the prompt, if you decide you don't
want to change that, all you do is press [RIS), without keying in any
value).
And now you've handled all your input problems for your CYL program
with just two uses of this command- one for each input. So much for
the first of your three problems ....
)
)
190 An Easy Course In Using The HP-428
Does the program work - at least the portion you've done so far?
Test It: Use CYL to find the volume and surface area of a
cylinder with a radius of 8 cm and a height of 18 cm.
Solution: First [EXIT) from Program Mode. Then press [XEO) l6i)
and see the R?0. 0 prompt on the lower display line
(where the X-register is usually shown). You're being
shown the current value of Rand then asked to INPUT
m
its new value. So press and then [RIS) to continue.
One More: Find the volume and area of cylinder with a radius of 4
cm and a height of 9 cm.
Since you just finished using the program CYL once, it's
the current program and you can just press [RIS) to start
it running again. Notice the R? and H? prompts: They
now show the values from the previous example.
Well, the program CYL is fine and dandy as long as you remember
which answer is which. But suppose you're not the only one to use your
program. Sure -you understand it because you did the programming,
but your friend might easily get confused.
So how can you make your calculator give more helpful instructions
and messages? By using Imm, CPillll, and m!ID.
Test It: [EXIT) Program Mode and press [XEO) fill (R?S[R2S). Aha! )
Now the volume is labeled-and so you also know that
the other entry (in the X-register) must be the area!
So, you can see how the l!ll!ll function is used: to display the name of
a variable alongside its value. This is very useful in labelling the
results of calculations at the end of the program.
But how can you have your program display other types of messages,
that can help you (or your friend) figure out what to do?
That's where !1111m] and m!ID come in .... Both !1111m] and m!ID can cause
the contents of the ALPHA-register to be displayed - and the program
to stop running.*
Of course, this means you need to have your message already stored in
the ALPHA-register prior to using AVIEW or PROMpt. Thus, you need
to do two things for each message you want your program to display:
• You must use AVIEW or PROMpt to then display the contents of the
ALPHA-register.
With that understood, you're ready to make your program sit up and
speak ...
) *The PROMpt function always stops the program, whereas this is optional with AVIEW. You'll
learn how to exercise your options a bit later in the Course.
)
~INPUT RADIUS{ALPHA]
But wait - both INPUT and PROMpt will stop the pro-
gram from running - you don't want it to stop twice for
each input. Hmmm ...you need to delete one of these two
statements. But which one?
(B
~INPUT HEIGHT (ALPHA]
.PGM.FCN)~m!JD
(STO]lllll
~:
VOLUME=628.3
x: 408.4
Generally, INPUT works the same no matter which data type you're
using-but it always assumes that your response will be in the X-register
when you press (R/S}to continue the program. That's not true when you
key in ALPHA data to the ALPHA-register, is it? And besides, you need
to have access to the ALPHA menu, too; using INPUT doesn't automati-
cally give you this access.
Sure, even with all these problems, you could still use INPUT, but this
would force you to do (or program) a lot of extra steps - to get to the )
ALPHA register, key in the data, then store this data into the X-register
and return to the Stack. What a pain.
That is, if you want to stop a program to enter some ALPHA data, you
should include an AON instruction immediately before a PROMPT
statement in your program (and an AOFF immediately after). That
way, when the program stops and prompts you for input, the ALPHA
Menu is already showing and you can immediately input characters
)
rather than numbers. Walk through an example .. ..
~ 00 { 0-Byte PrgM }
.PGM.FCN]l!a NAME{ALPHAJ 01 LBL "NAME"
~YOUR1STNAME~ALPHA] 02 "YOUR 1ST NAME?"
• CATALOG) (Elffj Gilli 03 AON
• PGM.FCN J(!) rn!IIII 04 PROMPT
.ALPHAJ[STOfOF)[EXITJ 05 ASTO 04
• CATALOG) (Elffj rl!Tiii 06 AOFF
~HI, (ALPHA] 07 "HI' II
~~(EXIT] 08 ARCL 04
.PGM.FCN]Ciml) 09 AVIEW
ff] 10 •END.
Press (EXIT] and then [XEQ] cmm. Input your first name and
press [RIS]. ... Not bad, eh?
Notice that if your name has more the six letters, you'll only
see the first six letters displayed. This should remind you that
you can have a maximum of six ALPHA characters when you
store an ALPHA string as a datum in a variable or register.
Line 02 prompts for the input and the AON in line 03 displays the
ALPHA Menu (and the message, of course, since it's in the ALPHA-
register by then). When the PROMPT in line 04 stops the program, you
can key in your name, then press [R/S)to re-start the program. Notice
that you're inputting directly into the ALPHA-register, so that the
program must use ASTOre to store the first six letters of your name into
a register (register 04, in this case).
The ALP HA-register is turned off (you must be tidy!) using AOFF in line
07. Then, after putting 11 HI, 11 into the ALPHA-register, your name is
added onto the end of the 11 HI , 11 using ARCL. Remember from page
124 that ARCL adds to the ALPHA-register and doesn't simply replace
the contents. Finally, the results are displayed with AV I EW .
In sum: 0
)
• To prompt for numerical data entry, use the INPUT statement,
pressing the [RIS) when you're through keying in each datum.
• To prompt for ALPHA data entry, use the AON, PROMPT, AOFF
sequence - as you just saw in the program, NAME.
)
INPUT and PROM PT are very useful tools, especially for short, straight-
forward programs. However, the folks at HP have taken great pains
to give you another, even slicker, way to key values into a program (and
they would be greatly hurt if you didn't come to know and love it) ....
) Variable menus can be a lot of fun. Certainly they make it very easy
for a program user to input variables - and in any order!
The two special functions used to make variable menus can both be
found in the •PGM.FCN~ Menu: W'll!il and l'mil).
The VARiable Menu (l'llli!D) function tells your calculator to build the
special menu for a particular program - a menu that may contain any
or all of the variables used by that program.
The Menu VARiable (ln'.rnil) function tells the VARM function which
variables should be put on the Menu it is creating. You use the MVAR
function only for those variables you want to appear on the menu.
Look at the next page, which compares the program CYL with a new
program, NCYL, that does the same thing, but uses variable menus
instead of input prompts.
03 PROMPT 03 MVAR H II II
05 INPUT HEIGHT"
II B 05 INPUT VARIABLES
II 11
06 PROMPT 06 PROMPT
07 STO "H" 07 EXITALL
-------------------------------
08 PI 08 PI
--
09 RCL R 11 11 09 RCL R 11 11
10 Xt2 10 Xt2
11 x 11 x
12 RCL H 11 11 12 RCL H 11 11
13 x 13 x
14 STO VOLUME
11 1114 STO VOLUME 11 11 )
15 LASTX 15 LASTX ()
16 RCL R 11 11 c 16 RCL R 11 11
)
17 + 17 +
18 LASTX 18 LASTX
19 x 19 x )
20 PI 20 PI )
21 x 21 x
22 2 22 2
23 x 23 x
24-VIEW-"vOLUME11 ____ D___ 24VIEW 11VOLUMf 1_ _ ___ )
-------------------------- -- -----
~-~~----------~---~~~~-----------
)
200 An Easy Course In Using The HP-428 (
I
Study the preceding page carefully - and notice these things:
• NCYL stops just once for data input (line 06), whereas CYL stops
twice, at line 03 and line 06.
• There are some instructions in NCYL that you've not yet learned
about!
First of all, the two MVAR instructions must come right after the label,
11 NCYL 11 • Why? Because the VARM 11 NCYL 11 instruction tells the
machine to "find the MVAR instructions immediately following the label
11 NCYL 11 and build a variable menu with the variables named in those
MVAR instructions." In this case, it will find two MVAR instructions (for
R and H) and therefore build a menu with just those two choices.
As for line 07 EXI TALL, its purpose (as its name implies) to EXIT ALL
Menus, so that both lines of the Stack Display are visible once again.
This is important in this NCYL program because both display lines are
needed at the end to show the two answers: the volume is displayed
in a friendly message covering the Y-register, and the surface area is
displayed in the X-register.
)
202 An Easy Course In Using The HP-428
Next Job: Finish keyingin the rest of NCYL, then use it to calculate
the volume and surface area of a cylinder with a radius
of 15 cm and a height of21 cm.
Like So: Press [RIS] to run the program again, thus regenerating
the variable menu. Then• and hold down llrtl to view
its current value. Result: R= 15. 0
Some kinda wonderful, eh? By using MVAR and VARM, you can both
store and view variable values - in any order you want!
Now that you know all the different ways of getting numbers into a
program, how about trying to improve what the answers look like as
they come out?
VOLUME=30,394.9
x: 5,466.4
That is, only one of the two answers is labeled. Now, this probably
doesn't cause too much confusion the way it is, but wouldn't it be nice
if you could label both outputs - putting each output on its own line?
Of course it would. But to accomplish this task you'll need to use two
important new characters that live in and around the ALPHA Menu.
)
204 An Easy Course In Using The HP-428
.J
You're going to combine more than one program line into one single
ALPHA message using the APPEND character, I-.
)
To review, then:
APPEND (r) allows you to add ALPHA strings to the end of mes-
sages already in the ALPHA-register.
And use ARCL to recall (changing any number into a numeral) and
APPEND to the ALPHA-register, all in one swell foop .
Now you're ready to put all of these ALPHA tricks to good use as you
really fix up your NCYL program....
VOLUME=30,394.9
SURFACE AREA=5,466.4
u
208 An Easy Course In Using The HP-428
)
Review
Already in this chapter, you've learned a lot of new things about pro-
gramming your HP-42S. Pause here and look at what you now know:
• You can find the permanent • END. and prepare for a new program.
• You know how to begin and name programs using labels.
• You know three ways to END them.
• You know how to change a program.
• You know how to move around within a program, either step by step,
or more rapidly.
• You know how to "run" or "execute" a program using the [RIS) and
[XEO) keys respectively.
• You know how to find out how much memory you have left.
• You know two different ways to input values into a program.
• You know how to use the VIEW instruction to label an output.
• You know the program instructions needed to store messages in the
ALPHA-register.
• You know how to use the PROMPT and AVIEW instructions to
display those messages.
• You learned that the EXITALL instruction exits all menus, taking
you to a Stack Display.
• You know how to use the APPEND and LINE FEED characters to
develop longer, more complicated, even two-line messages.
)
4. Name three instructions that can cause a program to stop run-
ning and wait for you to press a certain key.
)
)
How do you restart the program after each of these instructions?
)
210 An Easy Course In Using The RP-428 ( )
)
5. The formula for the volume of a sphere is
V =:l7tr3
3
3. a. You can either [EXIT] Program Mode and press •GToIor stay in )
program mode and press •GTO]c:J [ALPHA]C (ALPHA]. Then (in
)
either case), press •GTo]c:J and @]]TITIJ or (flENTERJ.
)
)
212 An Easy Course In Using The HP-428 I
4. Three instructions that will always cause a program to stop
running are: INPUT, PROMPT, and STOP (which you get by
pushing the [RIS) key while in Program Mode):
• INPUT has an additional function for both the display and the
program. When the program encounters an INPUT, the user
will see the name of a variable and a ? , which means that the
user should then key in the desired value for that variable.
Then, when the program is restarted, the value in the X-
register will be stored in that variable.
• PROM PT affects only the display. When the program stops be-
cause of a PROMPT, it displays the current contents of the AL-
PHA-register until the program is restarted.
• STOP affects neither the display nor the the program. When
the program halts because of a STOP, it just stops - nothing
more happens.
0 03 3
llrJ 04 YtX
ti 05 PI
~ 06 x
GJ 07 4
~ 08 x
0 09 3
8 10
[srol'Mil 11 STO 11 VOLUME 11
.PGM.FCN) f1ImlE!!J 12 VIEW VOLUME 11 11
)
~ 13 .END.
When you actually use the program, the INPUT statement makes )
the display actually say RAD I US?, so that you won't forget what
needs to be keyed in.
Then the VIEW statement at the end of the program labels your
answer, VOLUME=. Since it's your only output, you don't need to
worry about any more complicated ways of labeling it.
)
214 An Easy Course In Using The HP-428 )
)
6. This program is similar to the one you did earlier, on page 206.
You need to plan your spacing carefully: You can put a maximum
of 22 characters on each line, and there are 38 characters in the
message, so you'll have six left over on the second line.
The program listed below gives you the following display (includ-
ing the three spaces before " AT YOUR SERVI CE ! " and three
after):
THE RADIBOLICAL HP-42S
AT YOUR SERVICE!
~ 13 x
[RCL}ALPHA)~ 14 RCL 11w11 )
~ 15 x )
8 16 -:-
11 DENSITY = )
~DEN (ALPHA] 17 II
Since all of the MVAR statements must come right after the label
11 DENS I TY 11 , the earliest you can FIX the display setting is step
06. And it's a good idea to do it there, so that when you're keying
in your inputs, those values will be echoed back to you in the
same precision as the final answer.
This shouldn't come as too much of a surprise. You already know that
the instructions XEQ ("execute") and GoTO are used to make the
program pointer jump to particular labels, right?
When you press [GTO) CmJ, for example, you're telling the program
pointer to search all of program memory for the line containing the
instruction LBL 11 NCYL 11 , and to jump and place itself there. Similarly, )
when you press [xea)CI!i) you also jump to that instruction, but then
the program will begin running right at that point. )
The next thing you need to learn about, then, is that there are really
two kinds of labels - global labels and local labels.
If you already know all about this, then you may skip to page 223.
)
218 An Easy Course In Using The HP-428 I
)
Global Labels Vs. Local Labels
The rumors are true: There are two types oflabels - global labels and
local labels.
Global labels may be used for jumping between any two points in
Program Memory. Local labels can be used only for jumping within a
program. You can always tell a global label, because it always uses
ALPHA characters and is surrounded by quotation marks.
01 LBL FREE 11
11
02 LBL 01
03 LBL B
04 LBL 11 Q11
05 LBL 99
06 LBL 11 99 11
Answer: 01, 04, and 06 are global; 02, 03, and 05 are local labels.
Local labels are ... well, local. The only time the HP-428 can "see" a
local label is when the program pointer is positioned within the pro-
gram containing that label. If there's an END statement between the
program pointer and a local label, the HP-42S won't find that label.
~ 00 { 0-Byte PrgM )
.PGM.FCN)~ COUNT [ALPHA) 01 LBL 11 COUNT 11
@J 02 0
.PGM.FCN]~@ID 03 LBL 01
.PGM.FCN](!JllD 04 PSE
(The PSE function briefly PauSEs a running program.)
CD 05 1
(±) 06 +
.GTO]@ID 07 GTO 01
(!) 08 • END.
it listed (as E!TI!J3) in the menu. But LBL 01 doesn't appear on the list
because it's a local label accessible only from within COUNT.
Line02 "keys in" the starting zero to the X-register. Then line 08 serves
as the beginning of the counting "loop" (local labels often serve this
purpose). Next, line 04 pauses the program to display the contents of
the X-register. Then lines 05 and 06 add 1 to the X-register, and line
07 sends the program pointer back up to line 08 to repeat the loop -
which will begin with a 1 this time, then a 2 next time, etc.
Now Try This: Stop the program ([RJS)), key in(]), and restart it by
pressing [RIS) once more. The program starts its
counting at 5, right? OK, stop it again and key in
(}@, but then restart it by pressing~·
What Gives? The second restart method works also - but only
because the program pointer was still somewhere
within the program, COUNT, where it could find
that local label, 01, when you "called" it.
But Try This: Press [RIS) to stop the program, then •GTo lffi to
go to new memory space. Now key in Cim and
press ~to start it counting up from 12.
What Happens: You get the message, Label Not Found! Why?
Because you're asking the HP-428 to find a local
label when the program pointer is not in the pro-
gram containing that label. You need to press
•GTO)E!!l!l:lfirst, and then~-
OK - so when should you use a global label and when should you use
a local label? Why worry about local labels at all? Why not simply use
global labels for everything?
First of all, you must use a global label at least once in every program
- so you can "call up" that program from anywhere else in Program
Memory. In fact, you should use a global label at any point in a program
that you want to be able to "jump" to from another program.
Global labels are more convenient, but it's best to use them conserva-
tively, because they can cost you in two important ways:
• Global labels use more memory than do local labels. Why eat up
bytes unnecessarily?
• Global labels can slow down a program when it's running. You see,
when your machine searches for a global label, it must search
through all of Program Memory, one global label at a time, to try to
find the one you've called. And this search is in one direction only )
(starting from the , END, ), so even if the label you want is "nearby,"
the pointer won't necessarily find it any the quicker, since it doesn't
)
just "look around" to see ifitcan spot it quickly; it goes through this
methodical search, which can take awhile. )
So use local labels to make jumps within a program. This will usually )
make those internal jumps faster and take up less memory than if you
use global labels for the same purpose.
}
Branching Out With[GTO)And [XEO)
All right, now that you've got a good idea about labels, it's time to try
some programs that use them to branch and "jump about."
02 GTO 11 TN 11 02 TONE 9
03 BEEP 03 END
04 TONE 0
05 BEEP
06 TONE 4
07 BEEP
08 TONE 8
09 END
)
Now, press [XEO)Billl!I to hear the longer of these two pieces ....
)
Hmmm ...something's wrong!
The GTO at line 02 of SONG is like a fork in the road. It's no temporary
sight-seeing trip - it's a heavy commitment. Whenever the pointer
jumps to a label because of a GTO, it forgets all about where it jumped
from and just forges on, following whatever instructions it encounters
in its 'brave new world."
That's better, no? So why does the XEQ work where the GTO didn't?
.I
224 An Easy CouT'!le In Using The HP-428
Well, if you listen closely, you'll hear a TONE 9 (high pitch) before the
first BEEP. The pointer jumps to the TN program, sounds the TONE 9,
and then returns to the point it branched from in the SONG program,
)
to continue on from there.
The program pointer knew how to do all that because of the XEQ - that's
what XEQ really tells it: "Start from this point, search for this label, and
when you find it, follow your nose through the instructions after it until
you encounter either a ReTurN statement or the HlD of a program.
From there you must return directly back to this XEQ and continue
following the instructions that follow on from here."
Notice that even when you manually pressed the keys, [xEa)~, you
were telling the computer this same "do something and return here"
message: Before you pressed the keys, it wasn't doing anything. And
sure enough, it returns to "doing nothing" after it finally encounters
the END of that program.
In fact, all the built-in functions and tools in your HP-428 are really
little XEQ side trips, too - complete with built-in Re TurN statements.
After using any of these tools, your machine returns to whatever it was
doing previously, whether it was running a program or just sitting
around.
When you build such side-trips into an HP-428 program with XEO,
they're usually called subroutines. And you can even have "sidetrips
within side-trips within sidetrips ... ," etc. - nested subroutines up to
8 levels deep. That can be a mess, so before you try anything so
intricate, practice building and using some simpler subroutines.
line 05. Now you can replace the PROM PT with two
steps: a CF 21 and an AVIEW, then three PauSEs.
The Clear Flag 21 will keep the program from stop-
ping when it encounters the AV I EW (you'll more about
this shortly). Here are the keystrokes:
(B~lmll~·PGM.FCN)riWm)~DJI
D]IDJI [EXIT)[EXITJ.
where
Hint: That last part is the tricky part: You need to convert °F
to °C before you use a temperature in the equation. So,
why not use your first program, Fl RST (remember pages
) 175-177?) as a subroutine for this HEAT program?
Work on this. See if you can get the whole thing. Then
turn the page to see one possible solution ....
(RIS) 07 STOP
(RCL)(ALPHA) TF (ALPHA) 08 RCL urFu
(EXITJXEO)(!)lifm 09 XEQ FIRST 11
11
)
Answer: Q=4, 888. 9 (calories)
)
Now, having familiarized yourself with the use ofGTO and XEOjumps
to labels within a program, you're sure to appreciate the Program-
mable Menu.
This is where the Programmable Menu could be very useful: You could
write a little program to give you a menu with choices for which kind
of conversion routine you wanted to run. Then you could choose the
proper routine for each datum.
[EXITJ and [xEa]mg. Now try 68°F and 34°C to see what )
happens. Pressing~ converts the temperature, but
pressing arll does not, right?
)
See how the Programmable Menu works? Here's how you use it....
)
230 An Easy Course In Using The HP-428
To create a Programmable Menu, you use these three instructions:
• KEYX ("on KEY eXecute") works just like KEYG function except
that the named label will be called with an XEQ instead of
a simple GTO when a particular menu key is pressed.
The KEYG and KEYX instructions require two programming lines for
each item you want on the menu.
On the first line you must enter an ALPHA string that will appear as
the menu selection itself. Notice that a selection does not need to be
named with the label it calls.
The second line must begin with the actual command, KEYG or KEYX.
Then you tell the calculator on what key to "place" this menu item, by
pressing one of the eligible keys (the 6 top-row keys and~,~. and [EXIT]
can be used, and they're numbered 1-9 in that order).
Then you finish the second line by specifying the label to GTO or XEQ
when that menu item is chosen.
OK, But: Suppose you then decide that you don't really want to use
llEll in your menu, but 1:J11 instead (it's friendlier). And
you really wanted to assign it to the 0J key, not the~·
0
So: You want: 02 11 HI ! 11 and 03 KEY 3 XEQ 11 HOWDY 11 • )
To make these changes, step to line 03 while in Program
Mode, then press:~~ HI! (ALPHA).PGMFCN)~ IHBI
)
@~ llEI!El-
)
232 An Easy CouNe In Using The HP-42S
Now try out this modification: Press (EXIT) and [XEO] lm!ill)....
Hmmm ... What's that IE!1I item still doing there on the menu? Didn't
you "kill" it by replacing it with the l]]I item? Apparently not. What
does it take to get an item off of the Programmable Menu once it gets
put there, anyway? Do you need to clear the entire program?
Now, just to make double-sure that these items are gone from the
Programmable Menu, run another program that creates and uses that
menu. (XEO)m:il once again ....
You've actually killed ("deleted" is the more civilized term for it) only
the instructions that assigned "BOO!" and "HI!" (and their associated
XEQ and GTO commands) to the [ill and@ keys, respectively. DIT!ll
and IIlll are still assigned there, even though the instructions that put
them there are now gone. Your HP-428 stores the nine programmable
key assignments in its built-in system memory, but it doesn't auto-
matically clean this storage area out when you delete the instructions
that made those assignments. You need to do that yourself.
Result: You've done it! You've gotten rid of the ghosts! The only
Programmable Menu items are those actually being cre-
ated now by the current program QCF. You're no longer
HAUNTed by past menus or their ancestors.
It's a very good idea to include a CLMN instruction at the END of every
program that uses the Programmable Menu - so that you don't go
populating the menus of other programs with ghosts! You could also
0
()
make it a practice to begin each program with a CLMN instruction, too.
That way, you know you're slate is clean. ()
One more thing: If the current use of MENU happens to assign items )
where previous assignments had been, then of course, the new assign-
)
ments will overwrite (replace) the previous ones. So that's one more
way you can clear old assignments - overwrite them with new ones.
-----·-
Multi-Page Programmable Menus
tlPGMFCN).PGMFCNJ~I:1~~~(~~~----0_!_l~l:_~~~f_ 1 ~-
~ 02 LBL A
~DO!-( ALPHA] 03 II DO-!- II
~rn:.m(B@ID 04 KEY 1 XEQ 01
~RE(ALPHA) 05 11 RE 11
rn:.m~(fil] 06 KEY 2 XEQ 02
~Ml(ALPHA) 07 11 MI II
2
rn:.m@CillJ 08 KEY 3 XEQ 03
~FA( ALPHA) 09 11rn11
rn:Illl[LOG)@TI_) 10 KE\r 4 XEQ 04
~SO( ALPHA) 11 11 S0 11
C!m(IBJ (ill) 12 KEY 5 XEQ 05
~~ 13 11 LA 11 (
IB@JQEal.@]]J_ ________________ ~~~~~~~-~-
( )
m:!I!l~[ALPHA)B(ALPHA) 15 KEY 7 GTO B
m:!I!l(!J[ALPHA )B(ALPHA) 3 16 KEY 8 GTO B
()
~~~~~----------------~!~~~~~-~-
llilll!I 18 MENU )
4 19 STOP
~~LPHA~ALPHcl _ _ _ _ _ _ _ _ _ _ _ _~Yl~~-----
rnJI B[ALPHA) 21 LBL B
~(!JrmID 22 CLMrnu )
23 11 TI II )
5
~m:EJ(B@ITJ 24 KEY 1 XEQ 07
~OOt[ALPHA) 25 11 DOt 11
lli@~0!J-----------------~~~~~~~y~_ )
m:!I!l~[ALPHA) A (ALPHA) 27 KEY 7 GTO A
m:!I!l(!J[ALPHA) A (ALPHA) 6 28 KEY 8 GTO A
~[EXIT)®ij 29 KEY 9 GTO 99
)
236 An Easy Course In Using The HP-42S
iiilli!f--------------------~M~m------
(0 7 31 STOP
~~LPHA@ALPHfil ____________~Yl~~-----
lfilll@TIJ 33 LBL 01
~lmIJCD 34 TONE 1
~IEI 35 RTN
1m1 (ill] 36 LBL 02
~lmIJ0 37 TO~lE 2
~IEI RTN 38
l!Bl(fil) LBL 03 39
~lml)~ TONE 3 40
~IEI RTN 41
lml(ill) LBL 04 42
~IEIJ8J TONE 4 43
~IEI 8 RTN 44
lml(ill) LBL 05 45
~DmfI) TONE 5 46
~IEI RTN 47
lml(ill) LBL 06 48
~lml)@) TONE 6 49
~liilll 50 RTN
lml(fil) 51 LBL 07
~nmm 52 TO~lE 7
~IEI 53 RTN
lml(ill) 54 LBL 08
[!l!)Dmffi 55 TONE 8
(!:(!) liilll 56 RTN
-------------------------------
lml(ill] 57 LBL 99
~~cmm 9 58 CLMENU
.CATALOG]IEll~mml 59 EXITALL
---------------------------------
BUILDING YOUR OWN TOOLS: Programming 237
Lumpl begins the program and labels it with a meaningful
global label <"MUSIC 11 ), so that you can call this program
from anywhere else in Program Memory.
Lump7 displays the second page of the menu, and then uses an-
other trapping loop to "trap" the display of page two of
the Programmable Menu and render [RIS) harmless (to
see how critical these loops are to the smooth function-
ing of the program, try temporarily deleting them and
then use the program!).
Lump8 contains all of the small little subroutines that cause the
notes to be played. Notice how each one ends with a RTN
that sends the program pointer back to below the MENU
statement that sent it.
Have Fun: See if you can play "Mary Had A Little Lamb."
Ml-RE-DOl--RE-Ml-Ml-MI
RE-RE-RE
Ml-SO-SO
Ml-RE-DOl--RE-Ml-Ml-MI
RE-RE-Ml-RE-Dot.
But up to this point, your calculator hasn't had to make any such
decisions. It has merely presented you with the options. Well, that's
fine for the really important decisions, but ifyou, the user, are required
to make every decision in a program of any complexity, it soon becomes
so tedious that programming isn't worth the trouble.
Of course it would....
There are three main strategies that you can use to get your calculator
to make its own decisions:
• Conditional tests
• Loop counters
• Indirect Addressing
Conditional tests are just that - functions that test particular condi-
tions in your calculator. They are always questions which can be
answered with "yes" or "no" (or "true" or "false"). That means it's best
to use them when you want to do one thing for a "yes" answer-say, XEQ
a subroutine - and quite another thing for a "no" answer-say, display
a message.
The key is that you don't know the answer to the question in advance.
Only as the program is running will the answer be known. Using a
conditional test is one way of making an automatic decision.
In your HP-428, the conditional test functions are all those that
contain question marks (?) as part of their function names. These
functions are spread out in several menus - primarily in the •PGM.FCN]
and ~Menus - and all work similarly:
)
• If the answer to the question in "no," then the calculator skips one
step - the step immediately following the conditional test- and then
continues executing the program normally.
This general pattern is called the "Do-If-True" rule: The next step will
be done only ifthe answer to the test is "true" or "yes."
Solution: The new COUNT might look like this (keystrokes are
given only for new steps - the rest are easy now, right?):
Keystrokes Display
00 { 0-Byte PrgM )
01 LBL COUNT
11 11
02 10
03 STO 00
04 0
05 LBL 01
06 PSE
(@@E) 07 RCL 00
.PGM.FCN] (!)EiilESil 08 X=Y?
[RIS] 09 STOP
@] 10 R-l-
11 1
12 +
13 GTO 01
14 END
After pausing to display this current count value (line 06 ), the program
then recalls a copy of the ending value (10) to the X-register, which
bumps the current value to the Y-register.
Next, at line 08, the conditional test asks the question, "Is the value in
the X-register equal to the value in the Y-register?" As long as the
answer to this question is "No" (which will be the case as long as the
current count value in the Y-register hasn't reached 10 yet), then the
STOP statement will be skipped. The machine will go on to perform
lines 10 through 12, which add 1 to the current counter value. Finally,
at line 13, it will go to the top of the loop (back to LBL 01 ), ready to
repeat the loop with a new current count value.
When the count value has reached 10, however, the answer to the test
will become "Yes," so the STOP statement is then performed, and that
halts the program!
Notice also that you can easily modify this new COUNT program to
count from any number to any other number- up or down, by one's or
any other increment-simply by changing the numbers that are placed
on lines 02 , 04 and 11. *
Bonus Answer: Delete line 02. Then the STO 00 will store
whatever value you've keyed into the X-register
before you run the program.
*If you were to change the increment value, you'd better be sure that it will eventually give you the
ending value exactly-not skip over it. That is, the difference between your starting value and the
ending value should be a whole multiple of the increment value. Otherwise, your current value
would eventually become greater than the ending value without ever having satisfied the
conditional test (and thus the loop would go on forever), because the test would always be answered
as "No." Remember that the question it's asking is whether two values are equal (exactly)-not
equal-to-or-greater-than.
So, you've used a simple conditional test to make the COUNT program
more flexible. In that case, the test compared the value in the X-
register with that in the Y-register.
But there's another kind of conditional test that doesn't have anything
to do with the X-register. This test is called a/fog conditional test. A
f/,ag is an indicator with two possible, opposte values: Set or Clear*
You can see right away, for example, that a flag is an excellent way to
)
remember the yes-or-no answer from a simple conditional test (such as
the X=Y? that you've already seen) long after the question was origi- )
nally asked. It's not always convenient to retest the condition itself;
(maybe those values you need to compare aren't in the Stack anymore )
or something), but you can always retest a fiag easily.
)
)
This is because flags are stored offby themselves, not in data registers
or variable containers (look back at the Big Picture, page 18). There )
are 100 flags in all(numbered from 00 to 99), and you can test any of
them to see if they're set or clear. u
)
*You could also think of these two values as "true or false," "up or down," "yes or no," "l or O,"
)
''Yankees or Mets" - whatever.
Of these 100 flags, 45 of them (flags 36-80) are called System Flags and
are controlled only by the HP-428 (you can only test these; you can't set
them or clear them explicitly). The machine uses these flags to help it
)
monitor everything that's happening while you're using it.
Of the other 55 flags, 30 (flags 00-10 and 81-99) mean nothing to the
computer. These flags are called User Flags, because they are defined
only by you - the user. You can determine their meanings solely by the
way you use them in your programs.
The remaining 25 flags (flags 11-35) are called Control Flags because
they instruct the calculator to do something (or not to do something)
- and you can alter the states of these flags as you wish.*
Nothing, right?
OK, now set flag 26, once again (this is its more common
state): ~lll]l(Tifil.
Now try the BEEP again: .PGM.FCNI:!I!)ffill
That's better!
This is how you set and clear flags - and since flag 26 is the sound
Control flag, when you "turned it off' (cleared it), you disabled the
sound generator in your HP-428 and it couldn't BEEP at you!
*Pages 273-282 of your Owner's Manual give details about each flag in the HP-428.
)
) BUILDING YOUR OWN TOOLS: Programming 247
Challenge: Suppose you let the user choose to view the count more
leisurely: When he/she keys in a negative number as the
upper limit of the count, two PSE's should be used;
otherwise, one is enough (the count will still be done in
positive numbers). Use a flag to modify COUNT for this.
Solution: Here's one way (keystrokes are given for new steps):
00 { 26-Byte PrgM }
01 LBL COUNT
11 11
~lml@ill 02 CF 00
.PGM.FCNJ~mmm 03 X<0? )
~lmlll@ill 04 SF 00 ( )
.CATALOGJIEJlllD 05 ABS
I
06 STO 00
( )
07 0
08 LBL 01
09 PSE
~lml@ill 10 FS? 00 )
.PGMFCN]~ID 11 PSE )
12 RCL 00
)
13 X=Y?
14 STOP
15 R-l- )
16 1 )
17 +
18 GTO 01
./
19 END
So, after the label, the first thing to do is to clear the flag you're going
to use (line 02 ). That way, if you find it set later in the program, you
know for sure it was set by the program - not prior to running the
program. This is called "initializing" the flag.
Then, line 03 tests to see ifthe value in the X-register is negative, using
the conditional test X<0? ("Is the value in the X-register less than
zero?") IfYes, do line 04. If No, skip line 04 and continue at line 05.
Thus, only ifthat input value is negative (i.e. if two pauses are desired),
will flag 00 be set.
Lines 05 and 06 store the absolute value of the input number (the
"positive version" of that number) in register 00. This will be the
ending count value - the upper limit.
From here, the rest of the program proceeds as usual, except for one
minor change: At line 10, following the first PSE, you use the flag you
set (or didn't set) back in line 04. The second PSE (line 11) is executed
only ifthe answer to the fiag's conditional_~st is "Yes" (FS? 00 means
"is flag 00 set?")-because flag 00 was set only ifthe input was negative,
and a negative input meant "two pauses, please!"
Clever, no? Test COUNT now: [EXIT) from Program Mode and key in a
negative number. Then[XEO]HillI:). Now try a positive number. You
should see the difference in the length of the pause.
So that's how to use a User flag. But how would you use a Control flag
in a program?
Back on page 193, you read that the main difference between PROM PT
and AVIEW was that AVIEW sometimes caused the program to stop
running while PROMPT always stopped the program.
Try This: Key in the following short program. Then run it twice -
once with flag 21 set and once with flag 21 clear: )
)
01 LBL FLAG 11 11
04 AVIEW )
02 THIS IS A VERY
11 11 05 XEQ SONG 11 11
)
03 r- LFSHORT ONE"
11
06 END
)
250 An Easy CouT'fle In Using The HP-428
.I
J
) Here's another kind to keep in mind: There are four special conditional
tests that test the data type of the number in the X-register:
J
• REAL? asks, "Does the X-register contain a real number?"
• CPX? asks, "Does the X-register contain a complex number?"
• MAT? asks, "Does the X-register contain a matrix?"
• STR? asks, "Does the X-register contain an ALPHA string?"
You'll find all of these tests in the •CATALOG) Menu, listed alphabeti-
cally. They're useful for detecting an illegal-or otherwise troublesome
- data-type that would cause your program to stop or crash later (like
many things in life, you can often avoid a lot of pain later by detecting
and avoiding something earlier).
So, you now have three types of conditional tests at your disposal:
While Conditional Tests and Flags are clear, direct ways to get your
calculator to make decisions without your input, there are two very
convenient functions that can do the job even more efficiently when-
ever you're using repetitive program loops -as in the COUNT program.
The two functions are ISG and DSE which mean, respectively:
/
J
Just how do loop-control numbers work? Take a hypothetical case:
Suppose the number 27.0571216 is stored in register 02. If your
calculator then receives the program instruction ISG 02, it does this:
)
2. It uses the digits in the fourth and fifth decimal places (at the far
right) to form a separate integer (12 - "twelve" - here).
Thus the name: "Increment and Skip ifGreater than." Notice that in
these two conditional tests, the Do-If-True rule is reversed: Only if the
answer to the test ("Is the Integer portion Greater than the Fractional
Portion?") is "Yes," the next step is skipped.
)
)
Now, lest you be misled, the ISG and DSE functions don't form pro-
gram loops all by themselves. They still need labels and GTO's, etc.
Try This: Write (but don't key in) a program loop to count from
zero to nine, by ones.
Get the idea? Of course, these loops don't do anything constructive (not
even displaying the count), but you can see how much easier these
loops are to build than the loop you "built from scratch" in COUNT.
In this case, the control number is 200.02907, and with DSE, it's being
decremented: The first time through the loop, DSE 11 LOOP# 11 subtracts
)
7 from 200 to get 193. Then it compares this 193 to 029. Since 193 is not
Equal to or less than 29, no skipping takes place. The GTO 05 is
performed, and around you go again. )
)
On the second time around, the number stored in the variable "LOOP#"
)
is 193.02907. So DSE 11 LOOP# 11 subtracts 7from193 to get 186. But 186
)
is still greater than 29, so no skip. And here you go again - around and
around the loop, subtracting and comparing...
Finally, the value in "LOOP#" has been reduced to 32.02907. This time,
whenDSE "LOOP#" decrementsthisvalueby7,youget25.02907. Well,
25 is less than 29, so the test is finally satisfied (with a "Yes" answer),
so the GTO is skipped, the loop is exited, and that's all she wrote.
)
256 An Easy Coune In Using The HP-428
)
)
Remember:
With that in mind, go for broke with this Loop Counting Challenge ...
Keystrokes Display
00 { 0-Byte Pr9M )
01 LBL 11 COUNT 11
02 CF 00
08 X<0?
04 SF 00
05 ABS
CIIillIQJ 06 1000
8 07 +
[x~y) 08 XOY
lJiillillilll 09 100000
8 10 +
[±] 11 +
12 STO 00
[delete 18 0]
18 LBL 01 (
@illD 14 RCL 00
.CONVERTI!)Eill 15 IP
16 PSE
17 FS? 00
18 PSE
[delete lines 19-24] )
.PGM.FCNI!}ID 19 I SG 00 )
20 GTO 01
21 END
)
)
The first five steps are nothing new. They test for a negative number
and adjust flag 00 accordingly. For your trial run (with -39 as the
ending value), flag 00 will be set, requesting two pauses per loop cycle.
Next (lines 08 -10 ), the contents of the X- and Y-registers are exchanged
so that you can horse around a bit with the increment value. Since the
increment value in a loop-control number is always found at the fourth
and fifth decimal places, you need to divide by 100,000 to move it there.
In your trial example: 3 + 100,000 = .OOOQ3.
Line 12 stores the loop-control number in register 00, and then you're
ready to enter the loop itself, denoted by the LBL 01 at line 13.
Finally, line 19 and its I SG 00 increment the integer portion of the loop
control value each time through, then compares this with the frac-
tional portion (first three digits), and decides (correctly) when to skip
the GTO 01, thus ENDing the count and the program.
So much for conditional testing and loop counters. It's time to look at
the most subtle -yet, in many ways, most powerful - way to have your
computer make automatic decisions: What is this stuff - "indirect
addressing?" What's wrong with direct addressing (whatever that is)?
Solution 2: @) [RCL](JEJll@ID
To begin with, keep in mind that indirect addressing works for other
functions besides STO and RCL. * For example, suppose you have a
program with 26 little subroutines - each with a numeric label and a
RTN statement- one for each letter of the alphabet. Each subroutine
calculates how much space and ink that letter requires on a certain
type of printer. The program might look like this:
01 LBL "LETTERS" •
02 LBL 01 • (
• •
• LBL 25
()
• •
RTN •
LBL 02 • )
• RTN
• LBL 26
• •
)
RTN •
LBL 03 •
• END
• )
*The Operation Index in your Owner's Manual gives a complete listing of those functions that can
indirectly address.
Answer: Key in the number of the letter you want (1 for A , 2 forB,
... , 26 for Z) and then press [XEO]c:Jc:Jlilll, which is the
instruction XEQ IND STX.
Also, remember that you can execute ALPHA labels indirectly. That is,
you could have labelled each of these subroutines with its own letter.
Kevstrokes Display
At line 02, the number .019 goes into the X-register. This will be the
loop-control number for the ISG loop (as a loop control number, .019 is
also 0.01901) - and it will also act as the index for indirect storage.
Inside the loop, (line 04) the first thing to do is to send a copy of the loop-
control number into the Y-register. Then line 05 extracts the integer
) portion of the original in the X-register. If the loop control number is
0.019, for example, the IP function puts the numberO in the X-register.
Then, to end the loop, line 07 brings down the unmolested copy of the
loop-control number from the Y-register to the X-register, and lines 08-
10 provide the working guts of the loop counting mechanism, incre-
menting each time and skipping the GTO when the integer portion of
the loop-control number finally exceeds 19.
Programming Basics
Programming Structures
)
• Labels: The differences between global and local (page 219)
• Subroutines: How they're "called" and how they RTN (page 226); )
Making Decisions
a. [EXIT](RJS)
0
3. Remember the Quadratic Formula from 'way back in algebra ( )
class? Whenever you have an equation of the form ()
ax 2 +bx+ c =0 ()
)
-b± Vb 2 -4ac
)
x=
2a
4 = y
x2+x-12
Then (although later you may be able to use this nested set ofPro-
grammable Menus to organize your various technical formulas
and programs on your HP-42S), simply program each sub-menu
item to display its full title. That is, pressing rn!9] gives the
message, 11 ALGEBRA 11 ; pressing mirn1 gives the message, 11 DI F-
FERENT I AL EQUATIONS 11 ; pressing l3m gives the message,
11 ELECTRICAL ENGINEERING 11 , etc.
(Hint: Since you're creating one main menu and two sub-menus,
you're really creating something like a single three-page menu.)
00 { 148-Byte Pr9M )
01 LBL 11 QUAD 11 1 26 +1-
02 MVAR A 11 11 27 STO 01
03 MVAR 11 811 28 X<>Y
04 MVAR 11 C11 29 +
05 11 INPUT COEFF 11 30 STO 02
06 f- 11 CIENTS 11 2 31 RCL 01
07 CF 21 32 RCL 00 5
08 AVIEW 33 -
09 VARMENU 11 QUAD 11 34 STO 03
10 STOP 35 RCL 11 A11
11 EXITALL 36 2
12 FIX 02 37 x
13 RCL 11 811 38 STO+ 02
14 Xt2 39 STO+ 03
15 4 40 11 X = II
23 SQRT 48 f- 11 SOLUTIONSL~
II 7
24 STO 00 5 49 AVIEW
25 RCL 8 11 11 50 .END.
(
If the discriminant is positive (and only then), the program con-
tinues on to Section 5, which finishes calculating the two solu-
tions. The first solution is STOred in register 02, the second in
register 03. )
03 4 14 VIEW "Y" 5
04 INPUT X 11 11
15 STOP
05 Xt2 16 GTO EQ
11 11
06 RCL+ 11x11
3 17 LBL 03
07 12 18 "ASYMPTOTE
08 - 19 ARCL X 11 11
6
09 20 CF 21
10 STO 11y11
21 AVIEW
22 .END.
After the beginning label (Section 1 ), Section 2 sets flag 25, which
tells the calculator to ignore the first error it comes to. That is,
if it encounters one, it ignores it but also clears flag 25.
Next, section 4 tests flag 25. Ifthere has been an (ignored) error
- such as division by zero - during the calculations in Section 3,
flag 25 will have been cleared by this point, in which case the test
at line 11 will send the program jumping to LBL 03 (Section 6)
to display the asymptote message (mind the flag 21 with AV I EW !).
14 11 ALGE 11 40 GTO 14
15 KEY 1 XEQ 01 41 LBL 02
16 11 GEOM 11 42 11 GEOMETRY 11
20 11 DIFEQ 11 2 46 GTO 14 4
21 KEY 4 XEQ 04 47 LBL 04
22 KEY 9 GTO A 48 "DIFFERENTIAL II
23 MENU 49 l- 11 EQUATIONS 11
24 STOP 50 GTO 14
25 GTO B 51 LBL 11
52 11 CHEMISTRY 11
Section 2 <LBL 8) sets up the first sub-menu, the one for GJ'E).
Notice that in line22, the[EXIT)key <KEY 9)takes you back to the
main menu. This is logical: [EXIT~ng a sub-menu should put you
back at the main menu. And (EXIT~ng the main menu should put
at the Stack Display - exactly what LBL 99 does in Section 6!
Then Section 3 <LBL C) sets up the second sub-menu in a pattern
identical to that for the first sub-menu.
So, to close off this Programming chapter, what you have here is an
example of one of these behemoths. The idea is for you to:
OK, now that you have some extra elbow room ...
Your mission, should you choose to accept it, is to modify the program
MUSIC (the one with 00-RE-Ml)sothatyoucanrecord, name, save and
play back any tune that you play on the "keyboard." Of course, the
program should also let you simply "practice" on the keyboard, without
recording at all - just as it does now.
In recording a song, every note you press will be taken as one "beat"
(one count). In 4/4 time for example, each note you press would be
taken as a quarter note. To record a half note, you must simply press
the same note twice in a row, etc. Of course, you'll need to add a "no-
tone" to your keyboard so that you can include "rests" in your songs.
)
Then, when your recorded songs are played back, each beat will be
played in steady, tight succession (no matter how haltingly you have
"recorded" it), so that two or more identical notes played in succession
will sound as much as possible like single, longer notes. Admittedly,
this won't make for very sophisticated rhythms or dynamics, but the
HP-428 isn't exactly capable of symphonic music anyway, since its
TON E's are all the same length and you're limited to one octave of a )
major scale.
This is the most important stage of all. Without doing the work here,
you run the risk of wasting lots of your valuable time doing things that
you don't need, or doing them in ways that are useless later on in the
program. This is one of the new aspects oflarge programs: it is difficult
to envision them all at one glance.
The most important part of planning is what you don't do: You don't
start out by writing out actual program steps or keying them into your
machine-there'll be time enough for that later on. The first step, then,
is to list the main tasks of your program and to consider your basic
strategies. For example, the new MUSIC program will:
• Allow you to record as you play the notes - for later playback. Call
this routine "RECORD."
• Allow you to name and store a recorded song. Call this routine
"SAVE."
• Allow you to recall a stored song and prepare it for playing. Call this
routine "LOAD."
• Allow you to play back the LOADed song. Call this routine "PLAY."
Well, from your loop practice programs (pages 252-259), you know you
can "loop" quite efficiently with the numbered storage registers (whose
numbers can be increased as necessary), and an ISG loop and indirect
addressing. In fact, you can even use indirect addressing to play the
TONEs themselves (e.g. TONE IND 00 will sound the tone whose
number is now sitting in the register 00)! ... OK. ..
)
Hmmm ... then how are you going to store recorded songs? You might
well have several of them. Are you going to put them all into numbered
storage registers? You could do this, but the REGS matrix would get )
pretty big. And how and where are you going to remember the name )
of each song? Looks like you want to store each song into its own
)
variable, with its own name, right? And obviously, the type of variable
)
to hold an ordered collection of data is a matrix- similar to the REGS
matrix: the first beat of the song is the first element, etc .... All right .... )
)
Second Major Design Decision: Each song will be stored as a )
collection of beats within a unique, named matrix variable.
Hmm ... should you rethink your First Major Design Decision? Maybe
1 Ro, 1
1 Ro2 1
5 Ro3 5
5 Ro4 5
6
6 Ros can become or [ "115566" ]
6 "5 .4433"
6 R06 5
5 RO?
Roa 4
4 Roo 4
4 R,o 3
3 R,, 3
3 R,2
So if you can't edit a song, then notice that once a song is named and
saved, the only real reason for LOA Ding it is to PLAY it (sure -you can
rename it, but you can also do that - and clear it, too - outside the
program, with standard HP-42S commands, since each song is just an
()
ordinary matrix variable). You can't use the program to do much else
with it. As a user, you'd never need to select a routine called LOAD sepa- )
rately from the routine called PLAY. So although LOAD is a separate )
routine in the program, this fact can be invisible to you, the user. )
)
Fourth Major Design Decision: The user's basic choices of activi-
)
ties within the program will be:
)
PRACTICE RECORD SAVE PLAY EXIT )
0
Clearly, you're talking about some kind of menu here - the "Main"
)
menu of choices for the user. After all, for convenience and flexibility
- both for variables and program selections - menus are hard to beat,
aren't they? And the existing MUSIC program uses them already! )
)
282 An Easy Course In Using The HP-428 )
.)
As you can see, the whole point of writing a program is to make it useful
and convenient to the user, so in designing it, try to visualize it from
the user's point of view: What will you see in the display at each point
in the program? What information will you need to input- and how
will you do this? In what order would you want to do things? And what
mistakes might you make? ... Concentrate now, and visualize ....
You know the first thing you'll encounter is that Main menu. Then
what? What could you do next? Anything except SAVE, right? There's
no recorded song to SAVE yet. You could PRACTICE for hours without
having anything to SAVE. Only after you've RECORDed something
should you be able to SAVE it, right? And you'll need to be prompted
to input a name to store it under (mental notes).
s~~tis;m 1: The Main Menu. This menu will offer the main choice of
activities (PRACTICE, RECORD, SAVE, PLAY, or EXIT).
( )
(
s~~ti2n 2: The PRACTICE Menu. This will resemble your previous
MUSIC program -just a Programmable Menu of the
notes of the scale, sounded as the user selects them.
)
s~~ti2n a: The RECORD Menu. This will "look and feel" just like )
the PRACTICE Menu, buteachbeatwillberecorded into
)
a numbered storage register as the keyboard sounds it.
)
Section 9: The EXIT routine. Although you may use this routine
only once during a program, it's important to identify
and treat it separately anyway. Here you "clean up," exit
menus, restore inconvenient system parameters, etc.
Section 0: Initializations
00 { 697-Byte PrgM )
01 LBL 11 MUSIC 11
02 FIX 00
03 CF 00
04 CF 01
05 CF 21 ()
06 SF 26 ( )
07 CF 27
08 CF 29
9 II II
)
10 ASTO NAME 11 11
No matter how good a programmer you are, it's not usually possible to )
foresee all the initialization steps you're going to need. So although
)
these steps must come at the beginning of program execution, often
you'll start this list with "whatever you can think of," then return to
amend it later, whenever you think of something else.
What you see here, therefore, didn't just ''jump out" as "immediately
obvious;" these are the final results of such an amendment process.
I
The point is, you should always have an opening section defined for just
such a purpose, so that it's easy to find and amend as you need to.
First, notice that you have absolutely no need for any kind ofnumerical
display in this program; everything of interest to the user will appear
as either a message, a menu item, or a sound. But you do need to format
numbers as single numerals (by ARCLling) - for your compacting
process when you SAVE a song - without any extra decimal places or
even a decimal point. So you FIX 00 and CF 29 (flag 29 controls the
presences of the decimal point and digit separators - the commas at the
thousands, millions, etc.).
Next, notice that you can use the same "keyboard" routine both for RE-
CORDing and PRACTICing-ifyou tell the machine which one you're
doing. You'll use flag 00 to indicate this: When this flag is clear, you're
just PRACTICing; when it's set, you're RECOR Ding. Start in "PRAC-
TICE mode" - with flag 00 clear.
Similarly, you'll notice that you need some status indicator to help the
machine remember when there's an unSAVEd but RECORDedsong(so
it doesn't let you inadvertently RECORD over something you forgot to
SAVE). That'll be flag 01, which will be set only when there is such an
unSAVEd song. So start with flag 01 clear.
Finally, since you can have only one song currently loaded into the
)
numbered registers, you'll probably need just one variable to remem-
ber that song's name: 11 NAME 11 • And you'd better put something in there
to indicate that there's no song yet: 11 11 (a blank name).
)
Section 1; The Main menu
29 LBL B 50 LBL D
30 CF 00 51 CLMENU
31 LBL C 52 11 TI 11 ()
32 DO.,l. 11
11 53 KEY 1 XEQ 07 ()
33 KEY 1 XEQ 01 54 11 DOt 11
34 RE
11 11 55 KEY 2 XEQ 08 )
35 KEY 2 XEQ 02 56 11 REST 11
57 KEY 6 XEQ 09 ()
36 MI
11 11
Section 1 (at LBL A) is the Main Menu, which you build and display
just like you've seen other Programmable Menus built and displayed
(recall, for example, pages 229-232): Each choice has a KEY associated
with it (though not allKEYs are used). Notice that it was logical to put
the EXIT routine (labelled 99) on KEY 9 which is the [EXIT] key. As for
the choices to GTO some labels (lines 18 and 20) but XEQ others (lines
22 and 24 ), these will be more self-explanatory as you go on. In pro-
gramming for yourself, you might well begin by using all GTO's and
then deciding later that XEQ's make more sense. That's fine.
Notice one new thing: The name of the currently recorded song will be
displayed above the menu Oines 12 -15 ), helping the user to remember.
)
Of course, when the program starts, that name will be all blanks - as
you've just arranged in the initialization section.
• When you want to [EXIT) from this menu <KEY 9, line 60 ), you won't
exit the program entirely, because this is not the "last layer of the
program." Instead, you'll be sent back to the Main menu, at LBL A.
To understand those two lines, it's best to consider Section 3, the REC-
ORD menu at the same time (shown opposite here)....
But notice that (among other things) the RECORD menu (at LBL E)
will set flag 00 (at line 69), and then send the pointer to the keyboard
menu via LBL C, thereby missing step 38. By providing two different
entry points to the same routine, you control which circumstances will
encounter all the steps of that routine rather than just a portion.
Then, once within the keyboard menu, since flagOO might beeither set
)
or clear (depending on how you got to this menu), you don't want to
mess with it anymore. So in restarting the menu loop in cases ofmis- )
strokes or changing pages (e.g. at lines49, 58, and 59), you don't send )
the pointer back to LBL B, but rather to LBL C, thus preserving the
current status of flag 00.
)
So how does flag 00 actually start the RECORD process? It's nowhere
in this menu is it? No - actually it's in the "sound" subroutines C01 -
09) called by this menu. In those routines, if flag 00 is set, the beats )
will be stored as well as played. You'll see those routines in a moment.
)
290 An Easy Course In Using The HP-428 )
Section 3; The RECORD Menu
64 LBL E 70 SF 01
65 FS? 01 71 NONAME
11 11
67 FS? 01 78 1. 999
68 GTO A 74 STO 00
69 SF 00 75 GTO C
Now notice what else this RECORD Menu does: First, it tests whether
an unSAVEd song is currently stored in the numbered registers, by
testing flag 01 (this is what you've defined flag 01 to mean, right?): If
flag 01 is set, the user shouldn't be allowed to RECORD over the
unSAVEd song without a warning. So you XEQ 80 - an error message
to let the user acknowledge the danger and decide if the current song
is worth SAVing. Depending upon his/her decision, that error routine
will then adjust flag 01 and RTN to line 67, which then tests it again. If
it's still set, this means the user did not want to forget it without
SAVing it, so back you go to the Main menu CLBL A).
Thus, a user can RECORD a new song only if flag 01 is clear by step 67.
If so, the program then sets flags 00 and 01, to signal, respectively, that
this is now a new RECORDingsessionand that as of now, there is a new
and therefore unSAVEd song in memory. It also gives this song the
name 11 NONAME 11 to remind the user via the message at the Main menu.
Finally, before entering the keyboard routine, lines 78 -74 start an ISG
loop counter in register 00, to help store and count each beat in
successive numbered registers (up to 999 beats in any song).
)
Section 4; The keyboard's musical subroutines (labels 01-09)
Notice how the "Rest" routine CLBL 09) sets the error-ignore /fog (25)
so that if the program tries to TONE a 11 • 11 , it doesn't crash.
)
) But after that, if you're just PRACTICing, then, since flag 00 is clear,
the test at line 106 will RTN the pointer back to the keyboard menu.
Otherwise, it stays around to store that beat's TONE value into the
register indicated by the counter in register 00.
The first trap (at line 110 ), again uses flag 25, the error-ignore flag. As
you can see, this flag is useful in that it not only lets you ignore the first
error, but it then clears itself to tell you that it has indeed encountered
an error and that your one "mulligan" has therefore been "used up."
So you as a programmer know that ifflag 25 has been cleared after the
attempt to STO I ND 00, this indicates that you've run out of registers
in the REGS matrix, in which case, before being sent on to LBL G, you
re-DIMension REGS with one more element (lines 112 -118) and then
carry out a successful beat-indirect-storage Oines 119 -120).
Finally, if you've recorded a song with 1000 beats or more, you'll fail the
ISG test at LBL Gand thus be sent on to the error message below, which
wanrs the user before RTNing back to the keyboard menu.
Notice also that at the end of the RECOR Ding session, the counter in
register 00 will be left "pointing to" (i.e. its integer value will be the
number oD the register following the register containing the last
stored beat (in preparation for the next beat - which never came).
There are a lot of details and little programming maneuvers you may
not have seen before, so look and think carefully.... )
)
Next job: Create and DIMension a new matrix variable by that name
(lines 136 - 147). This matrix, which will contain ALPHA strings, will
be n x 1, and you need to figure out what n must be - i.e. how many
elements this matrix must have.
Hmm ... you'll need one string for every six beats in the song, right? But
you can't just divide the number of beats by six; unless that division
just happens to come out even (no remainder), you'll need to round up.
In such a case, the last element in the matrix will contain a string that's
not fully six characters long, right? No big deal- but you'll need to do
this rounding and do it right.
And another thing: After you've saved this song (and "erased" it),
suppose you want to PLAY it later. You'll need to somehow load it back
into the numbered registers, set up a loop counter, then run through
that loop, read each beat and sound it, right? (All that will be in the
LOAD and PLAY routines.) But how are you going to know then exactly
how many beats were in that song? Sure -you can guess within six,
simply by looking at the dimension of the matrix it's stored in- but you
need to know exactly to set up your PLAY loop properly.
Well, you could go through an ugly process, where you take the last
element in the matrix and break down its string to figure out how long
it is and therefore how many extra beats will be in the song. Or (much
more simply), you could just designate the first element in the matrix
as a special element- the number that tells you the song's length ....
)
BUILDING YOUR OWN TOOLS: Programming 295
This is what you're going to do: As you observed on the bottom of page
293, when the recording is finished, register 00 will contain a pezfectly
good indicator of how long the song is: that register's integer portion
stopped counting just beyond the end of the song! Why not just store
that value as the first element in your song's matrix?
OK, then this means you'll need one extra element in the matrix for
this inform.a ti on -this song-length number. Thus, you'll need to divide
that song-length by six, round any remainder up and then add one.
How do you do this? See lines 136 - 14 7: You get the song length from
register 00, take its Integer Portion (put this back into register 00 for
a moment -you'll see why soon), then subtract one (because the count
went one past the last register), then divide by 6. Now, an easy trick 0
for rounding up is to add .4 and then use RND, which will round to the
0
nearest integer (either up or down). You don't want to add .5 because
this could cause a rounding up with no remainder in the division- not 0
good. But since you need to round up and add one,just do it all at once: )
add 1.4 and RND .... Voila! The proper number of rows for the matrix! )
Now put in a 1 for the single column in the matrix and DI Mension it with
the name indicated in the variable "NAME".
)
)
And once a matrix is INDEXed, you can do a great number of manipu-
lations to it, via a pair of index pointers - a row pointer and a column
pointer. You position these pointers with the STO I J command and with
the values in the Y- and X- registers ( 1 and 1 here)which represent the
desired row and column pointer positions, respectively. So now you're
positioned at the first row in the first (only) column, ready to store an
element value, which you do by recalling register 00 and using STOEL.
Now you're ready to do a loop with the actual beat tone values. First,
you move the matrix row pointer to the next row, using I+. Then you
transform the value in register 00 into an I SG counter: "count from one
to one-less-than-this-value (this transformation is done by routine 81 ).
You're pretty good with loops by now. See ifyou can follow a "hypotheti-
cal song" with, say, 16 beats, through this double loop ... .Notice the tem-
porary use of flag 02 to signal whether the inner loop has just then
completed and successfully stored a full string (in which case flag 02
will be clear), or whether a final storage of a partial string is necessary
upon exiting the outer loop (in which case flag 02 will still be set).
)
J
With PLAY, as with SAVE, you must begin by prompting for the song's
)
name (lines 179 -183 ). But notice that you'll allow the user to indicate
the current song simply by pressing (RIS) without keying in any name
(a very useful and common technique). You accomplish this with flag )
)
23, which is set whenever the HP-428 experiences ALPHA input.
) If the user does mean to PLAY the currently recorded song, so be it: off
you go to the actual PLAY routine at LBL J. If it's a different song to
be played, you'd better repeat the kind of error trap (routine 80) you
used in the RECORD routine - to prevent the user from accidentally
erasing (LOADing right over) an unSAVEd song that was meant to be
"a keeper." As you know, the status of flag 01 after this routine will tell
you of the user's intentions, so you test it again (line 189) and either
abort the mission by RTNing to the Main menu (to let the user do a
SAVE) or forget the current song and go on to LOAD and PLAY a new
one (whose name has been saved in the variable 11 TEMP 11 ,just in case).
Assuming you do go on, the rest of the LOAD routine is quite straight-
forward, now that you've been through the logic of a SAVE routine: You
INDEX the intended matrix, position its pointers at the first element,
then recall this and use it to build an I SG counter for register 00.
Then it's a loop to recall successive elements out of the matrix, into the
ALPHA-register, then use a function called ATOX to remove the leftmost
character from the ALPHA register and send its character value (the
characters 11 111 - 11 911 have character values 49 - 58; a 11 • 11 has a character
value of 46) to the X-register.* There these values are converted by
subtracting 48. A negative value here indicates a 11 • 11 , so you substi-
tute the character itself, which has been stored in 11 TEMP 11 •
Notice the test at line 207 to check whether the ATOX failed due to an
empty ALPHA-register (i.e. that string has been exhausted). Ifso, lines
)
209 to 213 refill the ALPHA-register and then do a successful ATOX.
"These character values are found in the table on pages 288·290 of your Owner's Manual.
)
I
Then it's nothing more than a simple ISG loop, starting at LBL 14,
where you recall the beat-value in each successive register and TONE )
that value through indirect addressing. Notice that you must also set u
flag 25 each time through the loop, just in case you encounter a "Rest"
value, which can't be TONEd, of course.
)
)
)
These two subroutines are just small routines that you use more than
once during the program. Subroutine 80 is the message that gives the
user one last chance to avoid erasing an unSAVEd recording. Subrou-
tine 81 builds an ISG counter and places it in register 00.
Programs don't just "write themselves;" they don't leap from your mind
onto the page and into the machine by magic. And in developing them,
you'll make a lot of mistakes in your reasoning, logic, and design. You'll
need to some testing and"debugging" Here are some rules of thumb:
• Plan and even write down some typical examples and their intended
results and use these to test each section. If those all seem to work
all right, try to purposely "crash" the program by giving strange
responses or selecting menu items in unexpected (and illogical) )
combinations. This will highlight any needs for error traps and
(
expose other flaws in your logic.
)
• Remember that you can stop a program at any time with the [RIS)
key. And then you can view the contents of any register or variable .>
- without disturbing those contents or the Stack - with VIEW and )
AVIEW. Remember also that you can do single-step execution by
moving the pointer (and executing the code it traverses) one line at
)
a time, using the(!)(~) key while in Run Mode.
• Ifyou really get stuck, take a break or turn your attention to another )
section of the program. Often, you'll hit a mental block by pounding
your head against some knotty (naughty?) little error, but if you
turn your energies elsewhere, the mental block may clear-or your
thoughts on another section may lead directly to the solution.
Sure, you may get the bugs out of some working version, but after
you've developed it, keyed it in, debugged it, and tried it a few times,
you'll almost always notice (or think of) certain things that could be
better. For example, in this MUSIC program:
• Because it take less time to generate and ignore an error than it does
to generate a normal TONE, the duration of a "Rest" is only about
half as long as that of a sounded note. Thus, when recording a song,
you need to put in twice as many beats for rests as you do for any
other note. You could experiment with the PLAY routine to try to
find a way to even out the duration of a rest without unduly slowing
down the PLAY loop.
)
q
0 .
~~--r-- \~. ..£L...£..
I
~ . ..
·11:
..
'"'_,o
I
\Ovu...i
.
"'•""'•"~
SOLVING PROBLEMS:
Using Your Power Tools
Congratulations! You've finished building your first customized "power
tool"- that MUSIC program!
But you also have some very useful power tools already built into the
machine (and after having worked so hard to make MUSIC, you can
) certainly appreciate these more now, eh?). By way of re-introduction
(and look back to the Big Picture on page 18, if you wish):
The most commonly used functions are the special display modes.
When you first press ~. you'll see four mode choices grouped on
this menu list: ll!EII, Em, EI!:m, and IE!II. Each of these displays the
X-register in a different number base. The base of a numbering system
is the number of unique symbols (digits) used to represent numbers.
Similarly, in base-8, you have the "ones" (8°) place, the "eights" (8 1 )
)
place, the "sixty-fours" (8 2 ) place, etc. So to write 9 in base-8 you need
one "eight" and one "one": 11 8 (the subscript means the number is being
expressed in a base other than base-10). )
*Your ten fingers are also called "digits." This is no coincidence- how did you learn to count?
(Again, you could check this: 725 8 =469 - already proven above -
and 7CF 16 = 7(162) + 12(16 1) + 15(16°) = 1,999. And 469 + 1,999 = 2,468)
)
This system works just like all the others - except that there are so
many fewer symbols available. The positional "place"-values in the
Bl Nary system are:
or
So the largest binary number you could write in five bits would be
11111 2 , which is 1(24) + 1(23) + 1(22 ) + 1(2 1) + 1(2°), or 31. ()
If you ask your HP-428 to so display a value outside this range, it will
instead show <T00 Bi 9), telling you that, while this number is still
stored properly, it cannot be displayed in any mode other than decimal.
Similarly, you can convert to HEXadecimal form: Just collect the bits
into groups of four and change each group into a character in HEXa-
decimal:
1111 0000 1100 1000 1101
F 0 C 8 D
Each OCT digit is three bits and each HEX digit is four bits!
Also, you know that bytes are units ofmemory in your calculator, right?
But a byte is nothing more than eight bits (the equivalent of two HEX
digits)! Each ALPHA character uses one byte of memory - one two-
digit HEX number.
)
Negative Numbers In The~ Menu
There are some other limitations you should know about when doing
base conversions on the HP-428.
000 000 ()()() ()()() ()()() 000 000 ()()() 000 000 011 1012 )
But how do you suppose you change the sign ofthis number, transform-
ing it into its opposite -the Bl Nary equivalent of -29?
1()() 000 ()()() 000 000 000 000 ()()() ()()() 000 011 101?
No, it's just a different form of logic. Negative numbers are repre-
sented in the •BASE) Menu by something called the "2's-complement"
of its positive binary number.
Suppose you reset a tape counter to 000 and then press the rewind key
so that the counter moves backward by one unit. You'd see the number
999 - and you'd know this is really a -1, right?
Right. Now imagine that this three-place counter has, on each of its
wheels, instead of 10 symbols, only two: 0 and 1. OK, you reset this
unique counter to 000 and then, again, move the tape backward by one
unit. What would appear? It would show 111, wouldn't it?
)
Hold that thought. Now, notice that in the binary world, zeroes and
ones are "complementary." Since there are only two possible values for
any digit, the complement of a binary number is simply that number
with its digits exchanged: You change the zeroes to ones and the ones
to zeroes. So 001becomes110, 11101becomes00010, etc.
That's not a very startling observation, but notice that you'll get the
negative of a binary number (as in the tape-counter analogy) ifyou add
1 to its complement: The negative ofOOl is its complement, 110, plus 1,
or 111! The negative of 010 is its complement, 101, plus 1, or 110.
(
In 36 bits, the negative of
( I
()()() ()()() ()()() 000 000 000 000 ()()() ()()() 000 011 101 (
(
- which is exactly the answer that your calculator gave you in the last
example! This process of reversing each digit, then adding 1, is called
taking the 2 's complement of a number.
Now that you have some feel for how integers can be represented in
various number bases ...
Try This: Key in 47.35 and convert it to HEX. Convert back to DEC,
then key in 47 and convert it to HEX.
While you're in the ~Menu and in any mode other than DECimal,
all fractions are completely ignored in the display. The HP-428 places
a period after the integer part to remind you that the number displayed
value has a fractional part that is not being displayed.
It wasn't until 100 years after George Boole invented this binary logic
that the first primitive electronic computers were made. The man who
really made the connection between logic and computer science was
Claude Shannon. He developed the idea of"switching circuit theory,"
the idea being that electronic switches being ON or OFF could exactly
represent Boole's system, where every assertion is either TRUE or
FALSE.
{ l
Well, the rest is history: To this day, Boole's system - called Boolean
Algebra, or binary math - is the actual way that your calculator (and
nearly every computer) performs arithmetic. )
)
To get an idea of how this Boolean Algebra works try the following:
(
Example: Perform the following Boolean operation: 37 AND 14
Which makes no sense at all until you see it at the Bl Nary level:
When the computer does a logical operation (such as AND) with two
Bl Nary values, it treats each pair ofcorresponding bits independently:
000 000 000 000 000 000 000 000 000 1 I 1 1 (37)
000 ()()() ()()() 000 000 000 000 ()()() ()()() 1 1 (14)
000 ()()() ()()() 000 000 000 000 ()()() ()()() ()()() ()()() 100 ( 4)
Now consider the statement, '1 am male AND I have blue eyes."
This statement is true (1) only if both the individual statements are
true (1 ). Mathematically, then, (1AND1) =1. But (1AND0) =0, (0 AND
1)=0, and (OANDO)=O, since if either individual statement is false (0),
then the entire combined statement is false.
The point is, to perform an AND on two BlNary numbers, your machine
performs an AND on each pair of corresponding bits, and places the
result in the corresponding bit in the B/Nary answer.
)
There are other logical operators, too: llillll, llIDITI, and CIIll. Using the
same analogy (two verifiable statements), the logic of each of these is:
(1OR1) = 1 (1OR0) = 1 (0 OR 1) = 1 (0 OR 0) = 0
Thus, (37 OR 14) = 47.
• if one or the other (but not both) of the statements is true, then the
eXclusive OR is true:
• NOT is simple operation that takes the complement (not the 2's
complement - just a simple flipping of bits), replacing l's with O's
( ,
and O's with l's. NOT operates on only one number at a time and
has the effect of reversing the sign and subtracting one:
And what good are these operators? ...Well, certain electronic circuits
can simulate them (open/closed= 1/0)- then combine in various ways
to build (among other things) arithmetic operators!
Your HP-42S can multiply and add only because it can AND and OR!
Now, it's time to use matrices and the 8MATRIX) Menu to solve some
problems. But before you do anything to complicated, make sure you
understand the details of matrix multiplication.
Matrix Multiplication
How so? Because this is the sum ofthe products that result when each
element of row 1 of matrix A is multiplied by the corresponding
elements of column 1 in matrix B.
Get the idea? Ah, but why do any ofit by hand with an HP-42S handy?
)
From the above definition of matrix multiplication, you can see why
the order might matter: To reverse the matrices would mean combin-
ing totally different sets of rows and columns, wouldn't it? (Use the
HP-42S to find BA: [RCL] . .[RCL]. . (8)~ rnIJ)
One of the most common and most powerful uses for matrices is to solve
systems of linear equations. For example suppose you want to find x,
y, and z such that these equations are all true, simultaneously:
4x - 3y + 2z =40
5x + 9y - 7z = 47
9x + 8y - 3z = 97
Notice that if you follow the rules of matrix multiplication that you've
just reviewed, when you find AX, you'll get this matrix:
4x - 3y + 2z
AX = [ 5x + 9y - 7z
9x +Sy - 3z
l
Aha! Comparing this matrix to the system of equations above, it's
obvious that another way to write those equations is: AX =8
Thus the three equations of three variables have thus been reduced to
one (matrix) equation with one (matrix) variable, X!
m:rnJGJ . . 0+1-JIDl@JIDl®IDl®IDICTI+1-JIDI
m.. 0 IDl@EEJ -.1Ex1TJ IElll (ill) . . CillJ-.
ffiI) . . [EXIT) mnJl... (you'll be sent right to the Matrix
Editor to see the solution) ...
*As you may or may not remember, you must always have the same number of equations as
variables if you hope to get an answer. This means that you can solve a system of three equations
in three variables, or a system of five equations in five variables, etc.
Solve: a+ b+ c+ d + e = -1
3a - 2b - 2c + 3d + 2e 13
3c +4d- 4e = 7
5a-4b + e 30
c -2e = 3
Now, aren't you glad that your calculator did that for you?
*When you substitute the answer back into any of the equations, it becomes obvious thatd must,
in fact, be exactly zero. The difference is due to the rounding done during calculation.
(
Here's are the STATistical registers in their standard "locations:"
Ix
Lx2
LY
L,y2
Ixy
n
*Unless, of course, you've already mastered the entire Menu on your own. If so, skip to page 350.
where each individual x is the rainfall amount for one of those past
years, I means to sum all the individual x's together, and n is the
number of years of data (the number of x's) that you're using.
Suppose, for example, that someone suggests that your annual amount
of rainfall depends on the average daily temperature for that year.
How could you test this? Clearly, you now have two sets of observations
(rainfall and temperature), the one supposedly depending on the other.
And this is why you have those other statistical registers on your HP-
42S: It can do either one or two-variable statistics - and the formulas
require not just Ix and LY but also Ix2, L,y2, Ixy, L.lnx, L.lny, etc. So
as you key in collections of observations - your statistical data - the
machine will keep running tallies of all these different quantities.
To do this, select the llCCEARJ Menu, then press l!B to clear all of the
statistical registers (no matter where they're located!) .... Now, FIX 00
and then ...
Tufil: ~
1978 $170,000
1979 220,000
1980 215,000
1981 240,000
1982 145,000
1983 190,000
1984 230,000
1985 240,000
1986 245,000
1987 180,000
) 1988 270,000
)
You want to use the statistical capabilities of your HP-
428 to tell you some things about this sales history. How
do you do this?
So keep going: ~
~
~ (
~
~ )
~
~
~
CilllillIBfil8
~
*It's better to use this term, "accumulate," rather than "store." It's not quite accurate to say that
you "store" your data in the STAT registers. After all , once you enter them with the [B key, you
canrwt retrieve them again as individual values; it's only their cumulative sums that are stored.
All this - every time you press that one little (g) key!
*If you're working only with one-variable statistics(" x-data") the machine will still accumulate
whatever meaningless numbers it happens to find in the Y-register, but this is harmless exercise
and will not affect the results of your x-analyses.
... Hmm ... but what if you' re not sure that you've done everything right
(or, what if you're sure that you've not done everything right)?
The first clue that you may have messed up would be that the X-
register didn't end up with 11. in it (if not, then just start over on page
326). But assuming you got that much right, how else might you check
the accuracy of your entered data?
( I
)
This is one of the drawbacks to cumulative statistics (as opposed to
storing the data values themselves): If you've mis-entered something,
there's not much to do except to start over - unless you know exactly
how you went wrong.
Even ifit's all correct, what if you simply want to amend or edit the data
list (add or subtract something, replace a figure, etc.)?
All right - now that you have the corrected set of sales figures all
accumulated properly into the STATistical register of your HP-428,
what do you want to know about your income?
Not bad.
Time Flies: Now suppose it's the end of1989-and you're curious
how this year's sales ($234,600) affected your ten-year
moving average. That is, you're always concerned
with the most recent ten-year period, so you need to do
your editing trick on the STAT registers once again -
subtracting your 1979 sales and adding your 1989
sales - and then find the average of those ten values.
Sure it does: You deleted a value of$220,000 and replaced it with a value
of $234,600. You'd therefore expect the 10-year average to go up - and
it did.
Try This: Suppose that your monthly sales revenue for 1989 went
something like this (and this adds up to $234,600, which
is what you used for your 1989 yearly total):
January $ 29,000
February 10,500
March 17,200
April 15,500
May 10,500
June 9,700
July 9,700
August 15,500
September 34,500 )
October 15,500
November 29,000
December 38,000
Strategy: You could just key all this into the STATistics register-
and find the mean ofx, exactly as you've done before. Or,
you could observe that since there are repeated values
here, it might be easier to use a weighted mean (IIJm)).
Yes, But: Since the order ofdata entry never matters, use a weighted
mean to key in each different value just once - but note
also how often that value occurs in your collection:
9,700 2
10,500 2
15,500 3
17,200 1
29,000 2
34,500 1
38,000 1
.CLEARJ~(IIENTER~(IIENTER~
@]ENTER~ffiENTER~
(IIENTER~ffiENTER~
ffiENTER~ mml Result: 19, 550
Look familiar?
Sure: A chemist knows that any sample of"pure" copper she uses is
actually composed of two isotopes (varieties that differ slightly
in mass): 63Cu (62.93 g/mol) and 65Cu (64.93 g/mol). She knows
that about 69.2% of all copper atoms are 63Cu and 30.8% are
65 Cu. She needs to use a weighted mean to find the "average"
This means that the chemist can safely assume that the best
mass to use for any random sample of copper would be 63.55
g/mol-the weighted average of the masses of the two isotopes.
Of course, any average can tell you only a certain amount about your
data. To say that you "sold a monthly average of$19,550 worth of books
in 1989" makes it sound as if you could count on that level of sales every
month, steady and predictable.
Sure, it might have happened that way. Or you might have sold the
entire year's total ($234,600) during the Christmas season rush- and
sold nothing the rest of the year.
The point is, you can't tell merely by looking at the average, because
no matter how uneven and irregular your sales actually were, as long
as they add up to $234,600 for the year, your monthly average will
always calculate out to be the same number. An average just doesn't
tell you anything about the distribution of your values.
Well, after a quick glance at your actual monthly income history for the
year, you know what your sales distribution was: It wasn't smooth-
and-regular, nor was it "all-in-one-rush." In the summer months, sales
were slow (everybody was at the beach), while in the fall and winter,
your book sales were brisk - accelerating as Christmas approached.
So exactly how even or uneven was it? How can you measure this from
a set of values?
)
That's one of the uses of the standard deviation statistic- to measure
how widely dispersed or varied from the average your actual data
values are.
j
To get the idea,
Try This: Key a set of identical values into the STATistical regis-
ters, say, four 4's: •cLEARl~H ~
.CLEARlliQ~@:@@)~~
~~~~
~~~
~~-
And if you were to compare this to similar calculations for other years,
you could tell immediately in which years you had smoother, more
uniform sales - the years with smaller standard deviations!
)
)
The formula programmed into your HP-428 assumes that your data is
really a sample of a much larger population - as if you were catching
fish to get an idea of the typical weight of any such fish in the ocean.
This is useful, obviously, when you can't actually catch and weigh every
fish in the ocean.
But for other situations (as with your monthly sales figures for 1989),
you can actually analyze all the possible data - an entire population.
And the standard deviation formula for an entire population is slightly
different than for a sample* (and the population formula is not pro-
grammed into your HP-428). But you can get your HP-428 to calculate (
the population standard deviation - by adjusting your data a tad. (
Like This: To get the population (true) standard deviation for your
1989 monthly income, you add one extra entry to your
STAT accumulation - the average for the actual data. So )
you'd first calculate this average (press !ilm), then enter )
it as a "13th value:" (g). Now you can use the built-in
)
formula, m:D, to find cr .... Result: 9, 811.
*Statisticians use different symbols for sample and population standard deviations. Sample
standard deviation is abbreviated as s. Population standard deviation is abbreviated as cr.
Two-Variable Statistics
"Sure - because more customers come into bookstores in the fall and
winter than in the spring and summer."
OK, but why? Does the average person suddenly become more
interested in books in September?
Is that when everyone can afford the time or the money to shop for
books? Would it have anything to do with the weather - the amount of
rainfall or the temperature outside?
Well, any of these ideas are possible explanations. But how would you
)
go about testing whether or not a particular explanation is a good one?
Here's where you really start to use two-variable statistics to help you
answer questions and test possibilities. And one very useful toolset is
already built into your HP-428: regression and estimation.
x y
3 17
4 22
7 37
-1 -3
20
) 10
5 10 15 20 x
It then "draws" the best-fitting curve - the curve that gets as close as
possible to as many of the data points as it can. Then the equation it
wants will be the equation of that curve.
Here'sHow: ~l!B~~~G@
0IJENTERJCfIEffi +/-}ENTER)CiI±Bf£] mil.
)
SOLVING PROBLEMS: Using Your Power Tools 341
The display should now look like this:
This new sub-Menu can be used to find the "equation" that is the
solution to a regression problem.
Try It: Use your HP-428 to find the regression "equation," assum-
ing that the best-fitting curve is a line.
Like So: First, you must tell the calculator your assumption about
the shape of the best-fitting curve. To do this, choose GI!]B. (
This selects one of the four MODeL assumptions that your
calculator can work with. You'll probably see LI Near Func-
tion selected (m:JjJ) already; if not, select it now (the other
three MODels are LOGarithmic Function, EXPonential
Function, and PoWeR Function, which you'll see shortly).
y = mx+ b
where mis the slope of the line and bis they-intercept. Your
calculator will use this notation convention, also.
Which is exactly what you knew it should be. Remember that the
number, m, is called the slope of the line, because it determines its
"steepness" as it appears on the graph. For every 1 unit you change the
x-value, you change the y-value by "m" units. So the higher the m-
value, the steeper the slope of the line. And if m is negative, the line
slopes "downhill" to the right; if mis positive, the line slopes "uphill"
to the right (as it does in the last example).
Butx is zero only along the y-axis, so that point on the line would also
be on the y-axis, and thus the line would cross the y-axis at that point.
Sob is called they-intercept value - because this is the value (the
"height") at which the line "intercepts" the y-axis.
The "slope" and "y-intercept" are also key values in MODels other than
LINear, although their interpretation isn't quite so simple as in the
LI Near case. The equations for the other three options are:
• Logarithmic: y = b + m(ln x)
You need to decide on a second variable for your data. Didn't you say
you might have some ideas as to why your sales figures vary from year
to year - some other factor-some variable condition upon which your
sales seems to depend?
Weather? ... It's possible: People read more (it's an indoor sport) as the
weather gets bad. But what measurable aspect of weather do you think
matters most? Temperature? ... Rainfall? ... Hmm ... a rainy spell in the (
summertime sends people indoors to read, even when the temperature (
remains relatively high. Rainfall might be a good variable to test.
First, you'd better state your theory (the one you're about to test )
)
~amount ofannualoooK:_safes over tfie past ten years (1980· 1989) aeperufea
OK, now when you say "depended upon," you're saying that the rain
and nothing else was by-and-large responsible for your varying book
sales. You're saying that other factors (bus strikes, the competition's
summer sale, heat waves, MTV, tax audits, cash crises, the school
schedule, etc.) didn't really cause these variations.
Fine. And now what do you mean by the phrase, "the rainier it was, the
more sales I had?" Do you mean that if the rainfall doubled, your sales
doubled? Tripled? If the rainfall is an inch more in any given year, do
you generate $10,000 more in sales? What?
Well, that's a tough one. You've only just now suggested that there is
any kind of numeric connection - a correlation - between rain and
sales, and now you're already trying to decide what the correlating
relationships might be.
Remember regression? Why not let your HP-428 decide that for you?
Why not try a simple, LI Near model, and see how well it correlates - or
fits - your data?
Ready to test your theory? All right: To put it a little more mathemati-
cally, what you're really proposing on the previous page is this:
':for tfie fast ten years, tfie annual 6ooK_sales of my 600/qtore fuis 6een airect{y
propo~.onal {on a {inear moae{} to tfie amount of rainfalL '!Frat is:
Yoole• = 111Xrainfall +b
wfiere m anab are constants.•
(
Is there a linear correlation between annual rainfall and
annual book sales?
( )
Analyze: Press •CLEARl'l!f!I ~IJHl@TI), then enter all the data
(y-data first in each set):
)
CililllTiillJ(ENTER)GTI)~
Cilllilliilll(ENTER) CffiEill~
CilliilllillJ(ENTER)QliEIB[g)
~(ENTffi)Cilll'.TI)[g)
)
CillITffiillJ(ENTffi) CillEIT)[g)
~(ENTffi)@lil~
CilllillTIIQJ(ENTER)@nEIT)~
crrm::@Iill)(ENTER)o:ITEffi~
Cilllfiliill)@I®CillEITJ[B
~(ENTffi@rr)[g)
So, are you right? Is the rain driving your book sales? That
is, how well does this line fit your data? Unlike an ideal
example, not all the data points are exactly on this line of
regression. You know that the line is the best-fitting line for
the given data, but that doesn't really tell you everything.
Hmm ... not bad. 0.76 indicates a fairly good linear correlation, though
it could be stronger (suggesting possibly that although rainfall is a sig-
nificant factor in your book sales, it doesn't explain all fluctuations).
Question: How can you make sure you always use the best model?
)
Answer: Select lllilon the GElll sub-Menu. The calculator will
check all four models for you and select the one with the )
highest correlation coefficient for that particular set of
data. Try it now .... It picks the linear model, as it should!
(
All right, assuming that your linear correlation is more or less correct,
if your cousin (the Old Farmer's Almanac expert) were to whisper con-
spiratorily that next year you'd have 30.4 inches of rain, what would
you project for your bookstore sales next year?
Like So: You need to use the ForeCaST X and the ForeCaST Y
functions on your l!iII sub-Menu. If you enter an x-
value, and press !ME, you'll find out what they-value
would be, based on the regression equation.
Butwhatyoureallywanttoknowishowmuchrainyou'd
need to get to that magic sales plateau of $300,000.
Well, at least now you know how to use some of the built-in statistical
functions and tests on your HP-42S. As you can see, your calculator
does the hard part - accumulating the data - for you, so that you can
concentrate on choosing the correct test!
Yes, you heard right. These final two power tools are really powerful,
because they allow-nay, require-you to customize them with (simple)
programs of your own.
• Each must make use of variable menus (recall pages 199-203 and
MVAR and VARMENU statements).
)
These rules aren't too tough, are they? All of the programming you
need here should seem quite easy to you (but if you do need to review
programming a bit, reread pages 173-209 now).
(
The llli!!)Menu
As you may (or may not) recall, the definite integral of a function is,
graphically speaking, an area or region, I, whose four "sides" are
defined by four things:
• The function, f(x), usually defines the "top side" of the region.
This "side" is usually not a straight line, but a curve of some sort.
• The Lower LIMit (LLIM) is a vertical line defining the left side.
• The Upper LIMit (ULIM) is a vertical line defining the right side.
LUM ULIM r
I= fuL1Mf(x) dx
LLIM
where the values of the two limits (LLIM and ULIM) appear on the
integral (f) sign, the function,f(x), follows that sign, and the variable of
integration, x in this case, is indicated by what follows the d.
• Afunction
• The limits of integration (LLIM and ULIM) (
• The variable of integration
where a= 5 and n = 3.
Next, you enter your limits. For this problem, your LLI M
is 7 and your ULIM is 12: GJmID Cil1)l!I!III.
Now, there's only one more item to deal with before you
can press . . to calculate the integral: You must use
llD to tell the machine how "accurate" you want the
result of your integral calculation.
)
"Don't I want it calculated as accurately as possible?"
Not necessarily.
The more accurate you want your result, the more time )
it will take your calculator. Besides, the limits you key )
in may already be approximations; you can't really ex-
pect an integral more accurate than the approximations
you're using to calculate it, right?
The integration routine that you've just learned works very well for all
"well-behaved" smooth functions - and as long as you pay attention to
some of the basic rules for definite integrals.
Try This: Solve the same integral as the previous example, except
this time use different limits: LUM= 4 and ULIM = 7.
Question: Why can't the HP-428 help you with this integral?
I= !.,.,, ~d.x
,.7
x-8
·:;"- - - • · 8
~m
:t\~
: !~
:;
See? the area is unbounded at an asymptote, so a defi-
nite integral is undefined for this range-even though
the calculator will give you an answer. You must use
your mathematical insight to know it's "bogus!"
)
The other "bogies" to watch out for are the "spikes." Certain functions
that are real, continuous, and usually well-behaved still "go ballistic"
once in awhile,* varying enormously over very small intervals.
I )
x
...
10 100,000
(
Ifyou choose limits too far apart- such as x = 0 and
x = 100,000- the calculator will give you a mislead-
ing answer, because, in doing the integration, it se-
lects a number of sample points from within the (
limits you set. With too large a range, its sample (
points may "miss" the region with the spike-thus
grossly underestimating the area under the curve!
*doesn't everybody?
So you see, the only difference between the assumptions of~ and
•SOLVER) is that •SOLVER) assigns a resulting value to the specified
function. And that assigned value is always zero.
No problem - you simply rearrange it: If you have 3.x2 + 4x = 35, for
instance, you could instead write this as 3.x2 + 4x - 35 =0 , ... right?
)
SOLVING PROBLEMS: Using Your Power Tools 359
Any equation can be rearranged so that it is set equal to zero. And
that's the strategy you must use when programming for the~-
Once you've created a program for the equation you want to solve, you
can use •SOLVER] to solve for any one of its variables -after you key in
known values for the other variables.
Not bad, eh? And there's no end to the "what-if' calculations you can
do once you have an equation programmed for asoLVER]!*
Solutions:
CillEIIITJ. . (iliJ.....
0BQJ . . . . . Result: 30.04 (atm).
Ikfilill: 399 46 I (K)
*And remember (from page 203) that you can always press• and hold down a menu-key to see
what value is currently stored. This keeps you from getting lost when doing lots of"what-iffing.""
As handy as •soLVER) sounds so far, you should also know that it gives
back a whole lot more information than just the answer. In fact, it fills
up the stack with information ....
Solutions
To the Solver, a "solution" occurs anytime the curve crosses the x-axis.
(After all, that's when the value of the function becomes zero-just as
your machine requires, right?)
Whenever you're working with an equation that has more than one
solution (or otherwise behaves strangely like this example graph), you
should enter two "guesses" as to the answer. Your machine will then
begin looking for an answer between those two guesses.
As you can tell from this previous example, just as with ~. you
have to know something about your functions to get reliable solutions.
It may take some exploration, and fortunately, the~ is particu-
larly handy for this exploration.
But you can still misinterpret the results if you aren't careful! There
are several types of situations that can lead the Solver to produce an
answer in the X-register that isn't exactly a solution!
If you refer back to the graph on page 362, you see the two most
common types illustrated there - Reversals and Extrema.
You don't need to worry too much about these false solutions. Indeed,
you can use them to help you find out more about your equation.
This is because your HP-428 keeps you informed about what it's doing.
It tells you when it has encounted a "Si 9n Reversal " or an "Ext re-
MUM ". It also tells you when one or more of your guesses happen to be
impossible solutions (i.e. they tell the calculator to divide by zero or
some other impossible thing). In such cases, your machine will display
"Bad Guess<es) ".
Ifby any chance your equation yields the same value no matter what
trial value is used, your calculator will wonder, "Const ant?," suggest-
ing to you that your function is a constant (i.e. a number).
I
Sometimes the answer in the X-register is actually less interesting
than what's in the other Stack registers. Every time you use •SOLVER],
all four Stack registers receive some part of the "answer:"
In the Y-register is the previous trial value - the "next best "solution.
Comparing this with the X-register gives you some idea about what the
"neighborhood" of the solution looks like.
In the Z-register is the value of the function when the "solution" is used
as a trial. Of course, if the solution is an exact solution, then the value
in Z should be zero (or very, very close to zero, in the case of irrational
number solutions).
Quizzette: Assume that your function has a graph like the one
below. For each of the following sets of guesses, what
type ofresponse will .SOLVER] give-solution, reversal,
extremum, bad guess, or constant?
1. -1 and 5
2. 10 and 19
3. 19 and 21
4. 5 and 35
5. 5 and 9
6. -8 and -10
7. 21and29
8. 5 and 19
. ....
n
..
....
..
SOL YING PROBLEMS: Using Your Power Tools 367
Solutiette: 1. Extremum. In this range, the calculator will dis-
cover the bump.
Hmm: Junior Beaver arrived home from Hydro Tech one spring, and
found his father all in a dither about ducks "ruinin' my dam
again! That's the third year in a row them ducks've landed on
th' pond so thick that the water level rose above my dam!"
Junior knew that something had happened the last few years
to flood the dam, but he had his doubts about this theory. "Pop,
how much does the water have to rise to cause a problem?"
*For these sensitive and personal measurements, Junior Beaver wishes to thank several duck
acquaintances who prefer to remain anonymous. They know who they are.
1ooof •·D·~ ((xi+ 4Dif) Acos( - _MQ_)- i{x2+ 4D2-8hD L J Jxi+ 4Di-4hD) dh
64D2 1 x 2 +4D 2 2\ 8D JV"\ D
A•D
Hmm: You'll need two programs. The first one is for the function
under the integral (call it 11 POND 11 ):
•You probably want to take Junior's word for this - unless you, too, are an Eager Beaver!
01 LBL 11 8EAV 11
02 MVAR 11 W 09 PGMlNT 11 PON0 11 16 1000
03 MVAR 11 1/ 11 10 RCL 11 011 17 x
04 MVAR 11 011 11 STO 11 LLIM" 18 RCL 11 N11
05 MVAR 11 111 12 RCL 11 111 19 RCL 11 1/ 11
06 MVAR 11 X11 13 + 20 x
07 MVAR 11 L11 14 STO 11 ULIM" 21 X<>Y
08 MVAR 11 ACC 11 15 lNTEG 11 H11 22 -
You use rn:II (at line 09) to tell your~ program which
other program you want to integrate. Then you use IIDIBJ to tell
your asoLVERJ program to actually begin the integration
using the specified variable as the variable of integration.
When he's finished with the entry of data, he solves for I - the
amount the water will rise due to the ducks- by pressing . .:
Result: 0. 01 (meters).
*It turned out, however, that the ducks weren't entirely blameless: After some further exploration,
Junior and his Dad discovered that the real problem was that his Dad was building his dam each
year on a deeper and deeper layer of duck droppings accumulating on the bottom of the pond. The
droppings were not as firm a base as the actual pond bottom, so the dam was settling and slipping
a little more each year. By pure coincidence, the resulting swamping happened around the same
time as the annual arrival of the ducks.
v = f,.If P-
p•O
6
p 2 sinlf> dp dlf> de
,.o
9·0
2. Yes, but you want to ignore one of the equations. Remember from
page 319 that mm calculates a solution matrix with matrix di-
vision, which involves an inversion of a matrix, and - as you
learned back on page 152, only square matrices can be inverted.
This means that you can use mm only for systems that have
matching numbers of equations and variables.
(
3. As you remember (page 345 ), the linear regression model for one
(
independent variable and one dependent variable is y =a+ bx. If
there were four independent variables, the regression equation
becomesf=a+ bx+cy+dz+ew wherefis the dependent variable, (
x, y, z, and w are the independent variables, and a, b, c, d, and e
are the coefficients of regression.
Integration Subroutines:
04 Xt2 04 RCL Q 11 11
05 SIN
06 x
*This basic format could be used to find any triple integral - all that you'd need to change would
be the specific integration subroutines (RHO, PHI, and THETA) and the limits of integration in the
mrun program so that they match the new problem.
08 0 22 PI
09 STO "LUM" 28 2
10 RCL R"
11 24 x
11 STO "ULIW 25 STO "ULIM"
12 0.01 26 INTEG "H"
18 STO "ACC" 27 STO "VOLUME"
14 INTEG "P" 28 VIEW "VOLUME 11
First, you input the radius of the sphere and the aperture angle
of the cone (and line 06 puts into RADian mode). Then you call
11 RHO 11 and store the limits of the first integration and the AC Cu-
Now press [XEO] mm(!) li!mII!I ti@E l'lifill] [RIS), to calculate the
triple integral:
Now, before actually trying to find the solutions, you should see
what information you can glean from the equation to help you
narrow your search somewhat:
• Values for x lower than the lowest solution yield will positive
y-values. And values for x higher than the highest solution
will also yield positive y-values. This is a property of polyno-
mials of even degree (in this case, the degree is 6), whose
highest-degree coefficient is positive in sign (the .x6term has a
positive coefficient).
Guesses Interpretation
That's about it- the end of the Easy Course, the tools put away - for
now. But you have only just begun. You've just finished your
apprenticeship and become a fully-trained HP-428 tinkerer.
But of course, it doesn't mean you've seen it all. As we said at the start,
this book doesn't cover all of the many uses of your machine. For
example, here are a couple of topics you can now explore on your own:
• Display graphics;
• Printer operations;
Of course, most of the topics you did cover in this Easy Course have
plenty more exciting functions and variations to try. Explore them -
enjoy them - and get the most out of your HP-428!
Do you find yourself wishing we had covered other things? More of the
same things? Did any mistakes, typos, or other little mysteries leap
out and grab you by the lapels? Please let us hear from you. Your
comments are our only way ofknowingwhether these books help or not
- and we always read our mail!
and
Name _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ~
(J
Address _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ~
u
City _ _ _ _ _ _ _ _ _ _ _ _ _ __ State Zip
J
)
)
..
0 . ~. __ .
('
('
('
c
c
('
c
(
c
(
c
c
c
c
(
c
(
c
.
Coffin (
Coffin
Bloch
An Easy Course In Using The HP-428
(
This cover flap is handy for several If you have an HP-42S, you can do a lot, right? "Right!" c
different things: (
-Tuck it just inside the front Calculate a hairy triple integral? "[can do that!" (
cover when you store this book ~ Solve a system of 6 linear complex equations? "I can do that!"
on a shelf. That way, you can (
see the title on the spine. Customize your HP-42S menus, just for you? "[can do that!"
l
- Fold it inside the back cover -
out of you way- when you're .. .How am I going to do that? (
using the book. (
- Use it as a bookmark when you Take this Easy Course on the HP-42S. It'll show you how!
take a break from your reading!
First, you'll read about math and functions, the Stack, the
CUSTOM menu and each of the variable types (real/ALPHA,
Complex and Matrix). Then you'll learn to program the HP-
42S and use its built-in application tools to solve tough
problems with ease and understanding.
~lifE~~ (
.... (~lltViwE 1'.$ucJ\noMS, INC,
P.O. Box 118 • Corvallis, Oregon 97339-0118 • U.SA • (503) 764-0683
HP Part# 92206M
GRAPEVINE