αβγ

An example: solve ax²+bx+c=0

Here is another, somewhat more advanced example of programming XCALC. It is similar to an example in the programming book that came with my HP-33E, that I bought in the late seventies. The book is long gone, but I remember the example used the stack in a way similar to this. To use it, you must have a stack size of exactly 4, and "copy top on stack drop" must be turned on.

The program finds the solutions to the equation ax²+bx+c=0. Just enter the numbers a <enter> b <enter> c and run the program. The two solutions will be found in the stack registers X and Y (unless a is zero, in which case the result is rubbish).

The program (paste into the program editor):

# solve quadratic equation
# enter a b and c, then run
enter +
xy chs enter rdn rdn xy enter +
* lastx rup xy / lastx rup sqr rup -
sqrt xy / + lastx xy rdn -
rdn back rdn back rdn