

Programming in User RPL  First conceptsNow that you've payed 270 bucks for you HP48GX, it should at least be able to do everything you need. Several funcitions are already avaliable, but probably you'll need to do something the HP cannot do automatically. Say for example, you have to calculate the determinant of a symbolic matrix. Since the HP only supports numerical matrices, you'll have to calculate it manually. If you need to do that only once, OK, but what to do if you need several calculations, always doing the same thing, pressing the same keys, but with different inputs? That's why the HP48 is different from other calculators. It is programmable. It means it can learn how to do something. In the example above, you could write a program that calculates the determinat of a symbolic matrix when you give the elements. So, to calculate the determinat, you would just need to enter the elements and run the program. Want to calculate with different elements? Just key in them and run the program again. You'll get the new results automatically. Basically, programmable calculator can save you time. On the HP48, programs are delimited by
Let's see a simple example of a program. Suppose you have a 52 gallon cylindrical water heater and you wish to determine how much energy is being lost because of poor insulation. For that, you can use the formula
where q is the heat loss from the heater (btu per hour); h is the heattransfer coeficient, in our case 0.47; A is the total surface area of the cylinder, in our example 30; and T is the temperature difference. The values of h and A will remain constant in or case, but we
want to calculate the heat loss for various temperature differences. You could
key in the values every time and multiply them, but this task can be simplified
with programming. Let's create a simple program to calcule the heat loss for the
heater when the temperature difference is on the stack. Key in the following
program, and press
Lets examine this program carefully. The first thing is the number 30. Since
it's a number, it will be put into the stack. Now the stack contains the
temperature difference (which you entered) and 30, the surface area, that the
program entered. The next object is a command, Let's see if this works. If you have not already entered the program, enter
it now. You should see the program on level 1 of the stack. To save it as a
variable, type To see how easy it would be if you had to calculate several times, calculate the heat loss for the differences of temperature of 10, 12, 14, 16, 18 and 20. The answers are 141, 169.2, 197.4, 225.6, 253.8 and 282. Stack ManipulationOf the several commands that can be included in programs, some of the most
important ones are the ones that manipulate the stack, ie, change the order of
the elements, removes some elements or make copies of some of them. The HP
provides 13 commands for manipulating the stack. It is not recommend that you
know what them do. It is essential to know what them do. Was I
clear? You must know how to use them and their effect. Anyway, it
isn't so difficult. Here they are:
Now let's see another very simple program. It calculates the hypotenuse of a right triangle, given the tow cates on the stack. << SQ SWAP SQ + >> Let's again examine closely this program. First, it squares the number on level 1. Then, it swaps levels 1 and 2, and squares the new level 1, which was previously level 2. Now we have both catets squared, so the program adds them, and finally takes the square root. Simple, isn't it? Exercises
Answers to exercises Next Page 

This page was created by Eduardo M Kalinowski