SATO Motif

HP-48 Algebra Library Documentation

Table of Contents

General Issues
History and Overview
Installing and Uninstalling
Individual Program Descriptions
Frequently Asked Questions
Miscellaneous Information

General Issues

The Algebra Library is freeware. It is not to be bought or sold. The programs, library, and documentation may be copied freely provided that the programs, library, and/or documentation are not altered in any way and that they are distributed as you received them (that is to say, in a single compressed file containing the programs, library, and documentation, and any other accompanying files). A service fee may be charged only for the distribution process. You may alter the programs for your personal use but you may not distribute any altered version without prior written permission from the copyright owners.

The above privileges do not involve transfer of intellectual property rights such as copyright ownership. Algebra Library and documentation copyright © 1992, 1995, 2000 by Junichi Steven Sato. Programs copyright © 1990, 1991, 1992, 1995 by Akira Ijuin, Junichi Steven Sato, William Wickes, et alii. All rights reserved.



Return to the Table of Contents

History and Overview

It all began on a November day in 1990. The first version of SupraFactor, originally known as SuperFactor, was completed. SuperFactor used 30 subprograms, 121 variables, and all the time in the world. The amount of memory space it took was about 40 kilobytes.

Three months later in February 1991, version 4.2 was completed. Although it only factored up to eighth order polynomials (SuperFactor factored up to twelfth order polynomials), it was the first bug-free SupraFactor program. SupraFactor 4.2 used only one subprogram and four independent programs, allowing it to run much faster than any of its predecessors. A special feature was also added, called the "root found" beep. Setting a particular flag made the program beep every time a root was found.

SupraFactor 5.0 further expanded the capabilities of version 4.2. Not only were subprograms eliminated, but the program itself as a whole had been completely rewritten resulting in a more compact program (some 4,313 bytes less than SupraFactor 4.2) and no limitations on the size of polynomials (dependent on available memory, of course).

Small improvements were made in versions 5.1 and 5.2, each revision being smaller and faster than the one before. Version 5.2 was then rewritten in system RPL, yielding the fastest and most compact version (version 5.2-ML) to date.

Akira Ijuin took the liberty of creating a library which included SupraFactor and other programs which SupraFactor depended on. Eventually, all of the included programs were rewritten in system RPL and collectively released as the Algebra Library, version 3.5.

Return to the Table of Contents


The author would like to thank the following people for making this library possible: Mr. Joe Horn, whose Goodies Disks have helped in better understanding and gaining access to the internals of the HP-48; Mr. Rick Grevelle, whose Hackit Library was used to create most of the included programs; Dr. William Wickes, whose PCOEF program was included in this library; Mr. Akira Ijuin for his support, suggestions, et cetera during the process of creating this library; and a few others whose names are not known to the author but whose simple but incredibly useful programs were included in this library.

Return to the Table of Contents

Installing and Uninstalling

To install the Algebra Library, download the ALGEBRA.LIB file to the calculator in binary form and store it in a variable. Recall the contents of the variable to the stack and execute DUP. Check to see if the library object is valid by executing BYTES. The library object should be 3461 bytes with a checksum of # 209Ah or # 8346d. Do not use the library if the figures do not match. Store the library object in a port by placing a port number on the stack and executing STO. Turn the calculator off and then on. The calculator will perform a system reset, and the library will automatically attach itself to the home directory. Purge the variable in which the library was stored.

To remove the Algebra Library, place a tagged object on the stack in the form x: 1060 where 'x' is the port number in which the Algebra Library was stored. Execute DUP, then DETACH, then PURGE. Check your HP-48 manual for details.

Return to the Table of Contents

Individual Program Descriptions

All of the programs included in this library, originally written in user RPL, have been converted to system RPL by Junichi Steven Sato.

The results for the examples given below were obtained using the default flag settings.


Program: SFACT
Function: Factors polynomials
Author: Junichi Steven Sato

SFACT factors polynomials of first order or higher. There is no limitation in the order of polynomials as long as there is enough memory available. It requires in level 1 of the stack a list containing coefficients of a polynomial in decreasing order of power. The list may not begin with a 0.

Two numbers are displayed during the operation: the number at the top is the guess being used to find a rational root and the number at the bottom is the number of rational roots found.

The results may be affected by flag -3. SFACT does not work if the last stack option is disabled. Results are provided in algebraic form.

Examples Using SFACT
Polynomial List Result
x ^ 2 - 3 * x + 2 { 1 -3 2 } '(-1 + X) * (-2 + X)'
x ^ 2 - 4 { 1 0 -4 } '(2 + X) * (-2 + X)'
3 * x ^ 3 - 10 * x ^ 2 + 8 * x { 3 -10 8 0 } '(-4 + 3 * X) * (-2 + X) * X'
-2 * x ^ 2 - 9 * x - 7 { -2 -9 -7 } '-((7 + 2 * X) * (1 + X))'
x ^ 2 + 5 * x - 3 { 1 5 -3 } '-3 + X ^ 2 + 5 * X'
3 * x ^ 3 - 6 * x + 9 { 3 0 -6 9 } '3 * (3 + X ^ 3 - 2 * X)'
x ^ 4 - 3 * x ^ 3 + 2 * x - 6 { 1 -3 0 2 -6 } '(2 + X ^ 3) * (-3 + X)'
27 * x + 72 { 27 72 } '9 * (8 + 3 * X)'
315 * x ^ 2 + 1711 * x - 1376 { 315 1711 -1376 } '(-32 + 45 * X) * (43 + 7 * X)'
18 * x ^ 9 - 129 * x ^ 8 + 206 * x ^ 7 + 404 * x ^ 6 - 1193 * x ^ 5 + 200 * x ^ 4 + 448 * x ^ 3 + 1232 * x ^ 2 - 496 * x - 960 { 18 -129 206 404 -1193 200 448 1232 -496 -960 } '(1 + X ^ 2 + X) * (2 + 3 * X) * (-4 + 3 * X) * (-5 + 2 * X) * (2 + X) * (-2 + X) ^ 2 * (-3 + X)'
-6 * x ^ 10 + 44 * x ^ 9 - 102 * x ^ 8 - 12 * x ^ 7 + 454 * x ^ 6 - 780 * x ^ 5 + 366 * x ^ 4 + 412 * x ^ 3 - 648 * x ^ 2 + 336 * x - 64 { -6 44 -102 -12 454 -780 366 412 -648 336 -64 } '-(2 * (-4 + 3 * X) * (1 + X) * (-1 + X) ^ 5 * (2 + X) * (-2 + X) ^ 2)'

Return to the Table of Contents


Program: FACTS
Function: Finds factors of a number
Author: Anonymous; edited by Junichi Steven Sato

FACTS factors a non-negative integer given in level 1 of the stack. It leaves other real numbers alone. Factors are returned in a list.

The larger the number, the longer it takes for FACTS to return a result. The ATTN key interrupts the program and returns two lists, one each in levels 1 and 2, and the original number in level 3.

Examples Using FACTS
Number Result
56 { 1 2 4 7 8 14 28 56 }
128 { 1 2 4 8 16 32 64 128 }
263 { 1 263 }

Return to the Table of Contents


Program: PRIM
Function: Finds prime factors of a number
Author: Anonymous

PRIM finds prime factors of a positive real number and returns the results in a list. PRIM returns an empty list for the number 1 and leaves non-positive numbers alone.

Examples Using PRIM
Number Result
360 { 2 2 2 3 3 5 }
3844037 { 29 41 53 61 }
373 { 373 }
5.132E13 { 2 2 2 2 2 2 2 2 2 2 2 2 5 5 5 5 5 5 5 5 5 5 1283 }

Return to the Table of Contents


Program: SQRT
Function: Finds the square root of a number
Author: Junichi Steven Sato

SQRT requires a real number from the stack and it returns the square root of the number in its simplest radical form. The solution will contain the variable 'i' if the number is negative.

Examples Using SQRT
Number Result
20 '2 * \v/5'
-163296 '108 * \v/14 * i'
576 24
269 '\v/269'

Return to the Table of Contents


Program: D\->F
Function: Converts a decimal to a fraction
Author: Akira Ijuin

D\->F converts a decimal number (any real number) to a fraction in the form 'a/b*\v/(c/d)'. Integers, however, are returned as integers. If '\v/(c/d)' is equal to 1, only 'a/b' is returned. If 'a/b' is equal to 1, only '\v/(c/d)' is returned.

The results may be affected by flag -3.

Examples Using D\->F
Number Result
1.02062072616 '5 / 2 * \v/(1 / 6)'
4.89897948557 '2 * \v/6'
1.29099444874 '\v/(5 / 3)'
.714285714286 '5 / 7'
.267261241912 '\v/(1 / 14)'

Return to the Table of Contents


Program: D\->RT
Function: Converts a decimal to a root
Author: Anonymous

D\->RT converts a real number to a root in the form 'a+\v/b', where 'a' is either a whole number or a number with one decimal place and 'b' is a positive whole number. Integers and numbers with only one decimal place are ignored. The program may run infinitely if random numbers are used. The program searches for 'b' in the above equation by starting with 1. It then increments the counter by 1 until 'b' is found. Therefore, the decimal 8.0891438104 ('-20+\v/789') would take much longer than the decimal 12.2360679775 ('10+\v/5').

Decimal numbers must be accurate to at least five decimal places. ATTN interrupts the program, leaving the original decimal in level 2 and the current guess in level 1.

Examples Using D\->RT
Number Result
4.4142136 '3 + \v/2'
7.6095202129 '-5 + \v/159'
-1.11 '-13.6 + \v/156'

Return to the Table of Contents


Program: GCF
Function: Finds the greatest common factor of two numbers
Author: Anonymous

GCF finds the greatest common factor of two real numbers. To find the greatest common factor of three or more numbers, put the numbers on the stack and execute GCF repeatedly until a single number remains. For example, to find the greatest common factor of four numbers, enter the four numbers on the stack and execute GCF three times; for ten numbers, execute GCF nine times, etc. If one or more of the numbers are negative, GCF returns a negative number.

Examples Using GCF
Numbers Result
300 and 1275 75
258 and -461 -1
-16.8 and 22.4 -5.6
-.089 and -.2136 -.0178

Return to the Table of Contents


Program: LCM
Function: Finds the least common multiple of two numbers
Author: Anonymous

LCM finds the least common multiple of two real numbers. Follow the guideline given in the description for GCF to find the least common multiple of three or more numbers. If one or more of the numbers are negative, LCM returns a negative number.

Examples Using LCM
Numbers Result
5 and 12 60
56 and -45 -2520
-240 and 16 -240
-2.35621 and -45.1523 -10638830.0783

Return to the Table of Contents


Program: PCOEF
Function: Extracts coefficients into a list
Author: William Wickes

PCOEF requires an algebraic expression in level 3, a variable name in level 2, and a number representing the order of the polynomial in level 3 in level 1. It returns a list of coefficients in order of decreasing power.

If the number in level 1 is a decimal, it is rounded to the nearest whole number. If it is non-positive, PCOEF returns only the coefficient of x^0. If the number is larger than the order number of the polynomial, the resulting list will contain leading 0's. Note that lists containing leading 0's cannot be used with SFACT.

The results may be affected by flag -3.

Examples Using PCOEF
Polynomial Variable Order Result
'(X + 1) * (X ^ 2 - 4)' 'X' 3 { 1 1 -4 -4 }
'Y ^ 2 - 3 * Y + 2' 'Y' 4 { 0 0 1 -3 2 }
'4 * S ^ 2 - N' 'S' 2 { 4 0 '-N' }
'J ^ 3 - 3 * J + 6' 'J' 1.5 { 0 -3 6 }

Return to the Table of Contents


Function: Displays the Algebra Library logo and version number
Author: Akira Ijuin; edited by Junichi Steven Sato

ALGVERSION displays the Algebra Library logo and its version number along with the release date. Pressing any key will return you to the stack.

ALGVERSION does not affect PICT or 'PPAR'.

Return to the Table of Contents

Frequently Asked Questions

Q: I already have some of the programs included in the Algebra Library. Is it possible to install just the ones I don't have?
There are programs available on the internet that assist in extracting library programs and putting together custom-made libraries, but these generally deal with the sensitive internals of the HP-48. Because of the complexity, taking the Algebra Library apart is not recommended.

Q: May I get a copy of the source code for the programs in the Algebra Library?
Because the Algebra Library and its programs were programmed directly on the HP-48, no source code is available. If you're desperate and are familiar with the internals of the HP-48, Rick Grevelle's Hackit Library can extract the source code for you.

Q: What method does SupraFactor use?
SupraFactor uses synthetic division.

Q: Why does '315*x^2+1711*x-1376' take longer to factor than '-6*x^10+44*x^9-102*x^8-12*x^7+454*x^6-780*x^5+366*x^4+412*x^3-648*x^2+336*x-64' even though the former is a 2nd order polynomial and the latter is a 10th order polynomial?
The order of the polynomial has very little to do with running time. Take a look at the coefficients of the highest degree and the coefficients of x^0. The larger the value of these coefficients, the longer SupraFactor takes.

Q: How can SupraFactor come up with so many lucky guesses?
SupraFactor does not make random guesses. These guesses are actually calculated.

Q: Why does it take a long time before SupraFactor begins searching for a root?
The reason why SupraFactor takes this time is because it is creating a list of possibilities or "guesses" to be used in the searching process. If the value of the coefficient of the highest degree and the value of the coefficient of x^0 are large, the program takes a long time before starting the search.

Q: After a root is found, SupraFactor pauses for a while. Is that to show the user what the root is?
It wasn't meant to be, but it seems like it. When the program "freezes" the display after a root is found, it is actually creating a new list of possibilities to be used in the searching process for the next root. Quite convenient, isn't it?

Q: Why does it take a long time to return the solution after SupraFactor finds all the roots to a given polynomial?
SupraFactor is creating an algebraic form of the factored polynomial.

Q: Why does SupraFactor go through the trouble of creating an algebraic solution? Wouldn't it be faster if it didn't use this method? Wouldn't SupraFactor take up less memory if it only returned the roots?
SupraFactor would indeed be faster and smaller if it only returned roots. But then the program would not be called "SupraFactor." It would be called something more silly, like "UltraRoots," or something to that effect. Many users complained about previous versions being too large and too slow. Many methods and techniques were experimented with (including Newton's method) to cut down the size and speed as much as possible, but only one technique proved useful in maintaining the real purpose of SupraFactor: not only to find the rational roots of a given polynomial, but also to factor. This one technique is known as synthetic division. Despite being restricted to this one method, a faster and smaller version was made possible with the aid of some of the other programs included in the Algebra Library. Complain if you will, but bear in mind that version 5.2-ML is already 250% faster and 1,121% smaller than version 2.0. Not to mention the fact that it's more reliable as well.

Q: Why do I get a "GCF Error: Insufficient Memory" when running SFACT even though I have plenty of memory available?
The author is not sure what causes this error to occur. Because the Algebra Library was developed for and only tested on the HP-48SX, the issue may be a compatibility problem if you are trying to use the library on anything other than the HP-48S series (the newer HP-48G series, for example). It is also possible that another library with the same ROM ID (1060) or an add-on ROM card may be causing conflicts with the library.

Q: Some numbers such as .333333333333 and .125 do not work with the program D\->F. Is this a bug?
Yes it is. This bug popped up after the program was rewritten in system RPL. Unfortunately, the author has no clue as to why certain numbers do not work with D\->F.

Q: Does the number 1060 (Algebra Library ROM ID) have any meaning?
Yes it does. 1059 was the ROM ID for the Algebra Library, version 3.0, and since the current version (version 3.5) was the next version released, the number has been incremented to 1060. 1059 is the sum of the HP-48 character codes for each of the characters in the string "ALGEBRA LIBRARY".

Return to the Table of Contents


Due to time limitations, not all submissions will be answered, but please feel free to submit correspondence regarding the Algebra Library by sending an e-mail to Junichi Steven Sato at

Return to the Table of Contents

Miscellaneous Information

Title: Algebra Library
Version: 3.5
Release date: August, 1992
Checksum: # 209Ah or # 8346d
Bytes: 3461

Individual Program Information
Program Version Release Date
SFACT 1.0 November, 1990
SFACT 2.0 December 13, 1990
SFCT2 1.0 December 13, 1990
SFCTJ 1.0 December 13, 1990
SFACT 2.2 December 17, 1990
SFCT2 1.1 December 17, 1990
SFCTJ 1.1 December 17, 1990
SFACT 4.0 February, 1991
SFACT 4.2 February, 1991
SFACT 5.0 April, 1991
SFACT 5.1 June, 1991
SFACT 5.2 June, 1992
SFACT 5.2-ML June 21, 1992
FACTS ? October, 1990?
FACTS Sato 1.1 March, 1991
FACTS Sato 2.0 June, 1992
FACTS Sato 2.1 August, 1992
PRIM ? October, 1990?
PRIM Sato 1.1 March, 1991
SQRT 1.0 October, 1990
SQRT 1.1 December 13, 1990
SQRT 2.0 June, 1992
SQRT 3.0 August, 1992
D\->F ? June, 1992
D\->RT ? ?
D\->RT Sato 1.1 March, 1991
GCF ? March, 1991?
GCF Sato 1.1 April, 1991
GCF Sato 1.2 August, 1992
LCM ? June, 1992?
LCM Sato 1.1 August, 1992
PCOEF ? May, 1990
ALGVERSION 1.0 May, 1992
ALGVERSION Sato 2.0 June, 1992
ALGVERSION Sato 2.1 August, 1992
RS (Subprogram) 1.0 (Not released)
RS (Subprogram) Ijuin 2.0 May, 1992
Algebra Library 1.0 (Not released)
Algebra Library 2.0 May, 1992
Algebra Library 2.1 May, 1992
Algebra Library Sato 3.0 June, 1992
Algebra Library Sato 3.5 August, 1992

Return to the Table of Contents

[ Main Page | Official Bio | What is Neecher? ]
[ Work Listing | Audio Clips | Photos ]
[ Beethoven Quiz | HP-48 Programs | Chess Games ]
[ Favorite Links | Terms of Use ]

Main Page

Use of this site indicates you accept the Terms of Use