                    ALGB 2.3.

Bernard Parisse Institut Fourier (CNRS UMR 5582) Université de Grenoble I F-38402 St Martin d’Hères Cédex Tél. (33 | 0) 4 76 51 43 14

                    Bernard.Parisse@ujf-grenoble.fr

November 7, 1996

Contents

1 License 3

2 Installation from a computer. 3

3 Introduction. 3 3.1 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3.2 Implementation notes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3.3 Next upgrades. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

4 Files 4 4.1 Installation from another HP48. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

5 Data and main functions of the library 5 5.1 Data types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 5.2 User flags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 5.3 Main functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

6 Simplifications. 7

7 Integration. 7

8 Inverse laplace transform. 8 8.1 Linear differential equations systems with constant coefficients. . . . . . . . . . . . . . . . . . 8

9 Taylor series and other functions utilities. 9

10 Linear algebra. 10 10.1 Diagonalisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 10.2 Reduction of matrices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

10.2.1 Solving a linear system. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 10.2.2 Inversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 10.2.3 Determinant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

10.3 The MMULT instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 10.4 Other examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

10.4.1 Stack input/output for RED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

11 QUADR: Quadratic forms. 15 12 Arithmetic. 16

13 Library utilities. 17 13.1 Data representation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 13.2 Factorization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 13.3 Polynomial and fractions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 13.4 Arithmetic (integers, reals and complexes or polynomials) . . . . . . . . . . . . . . . . . . . . 21 13.5 Matrices and vectors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

13.5.1 Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

A All functions (49) of Library 788 listed in alphabetic order 23

B User Keys assignment and user flags. 26

C Thanks to ... 27

1 License

ALGB v2.3 \begin{matrix}c \\ ◯ \end{matrix} 11/1996 by Bernard Parisse, HORN%%ext and BAIRSText: \begin{matrix}c \\ ◯ \end{matrix} 06/1995 by Ram Naresh Gudavalli

This program can be redistributed and modified under the terms of the GNU General Public

License as published by the Free Software Foundation either version 2.0 or (at your option) any later version

This program is distributed in the hope that it will be useful, but WITHOUT ANY WAR-

RANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if

not, write to the Free Software Foundation, Inc, 675 Mass Ave, Cambridge, MA 02139, USA.

2 Installation from a computer.

If your have a HP48S or a HP48SX with few memory, you should probably install the G/GX version of the library to save 2.6K. The G/GX version works on S/SX models as far as the numeric solver is not called. In most situations at school, the roots of a polynomial are found before by the symbolic routines of ALGB. Of course, sometimes you will get an Undefined XLIB name error when rooting polynomials (at school, this is the case for example if roots of unit or bisquared polynomial are involved, like 'X^4+1').

Now connect your HP to your computer. Run kermit in server mode on your computer, and

type:

'ALGBG' KGET

on your HP48 G/GX model or:

'ALGB' KGET

on your HP48 S/SX model. Keep kermit in server mode. Type the A menu key on your HP to go in the ALGB directory. Type again the A menu key to launch the INIT program. This will install the library and powercycle your HP to attach the library. Type the A menu key twice again to relaunch the INIT program in order to assign the users keys and create the CST menu.

If you have enough memory, type the F menu key to get all modules of ALGB. Otherwise, it’s time

to purge the ALGB directory! Hit the C menu key to launch the PURG program. Now install by hand the module(s) you need, e.g. type:

'MATR' KGET

to get the MATR directory.

3 Introduction.

3.1 Overview.

ALGB is made of:

• a library (24.5K for the G/GX version or 27K for the SX version):

– integer, complex, quadratic irrational, polynomial and fraction arithmetic (operations, integration, derivation, simplifications, GCD algorithm, factorization over IR or I C ,...)

– polynomial symbolic/numeric rootfinder (symbolic roots of a numerical polynomial, roots of some symbolic polynomials)

– symbolic/numeric matrices utilities (operations, trace, transpose, inverse, characteristic polynomial, determinant, row reduction to echelon form with the possibility to follow the reduction step by step).

– conversions (symbolic fractions to lists, symbolic to numeric matrices, symbolic to numeric polynomials, ...)

• modules (0 to 20K): other functions. They are independant, you can install 0, 1, 2, ... or all modules.

– TSIMP program for simplification of transcendental functions – risch program for symbolic integration

– MATR directory for symbolic or numeric matrices:

∗ DIAG: eigenvalues and eigenvectors (including Jordan cycles of characteristic vectors),

∗ RED: rank of a matrix, formal inverse and determinant by row reduction, solution of linear systems (including underdetermined systems).

– FUNC directory with the enhanced TAYLR to get Taylor expansion,

– INTG directory, the complement of risch:

∗ INT: symbolic integration of rational fraction of x or of sin(x) cos(x) or of sinh(x) cosh(x) and of \sqrt{ax^{2} + bx + c}, partial fraction decomposition over IR or I C, inverse Laplace transform of rational fractions,

∗ LDEC: solutions of systems of first order linear differential equations with constant coefficient.

∗ LIN: linearization of trigonometric polynomials

– QUADR directory with the GAUSS program to get Gauss orthogonalization of quadratic forms

– ARIT has some arithmetic utilities.

3.2 Implementation notes.

This software is written in Sysrpl with HP48 supported entries and standard instructions (with one exception: the POP2%SPLITAC static entry), hence it should work on all versions of the HP48. Of course, you should backup your calc before trying it: no software is bug free!

You can store the library in any port. It will run faster (1.3 to 1.5*) in a non covered port (0 or

1) on a GX. The installation procedure (INIT) installs the library in port 0.

Since some internal and visible routines have been moved or removed from earlier versions of

ALGB, you must reinstall both the library and the directories you need.

This package was written on a 90Mhz Pentium PC running under Linux version 2, with XFree86

(X-Windows system), the GNU emacs editor, the x48 emulator with JAZZ installed, the gtools package (HP48 GNU compiler) and kermit.

3.3 Next upgrades.

The latest versions are available by anonymous ftp in the directory:

ftp://puccini.ujf-grenoble.fr/pub/hp48/

If you don’t have DNS access the IP address of puccini is currently 193.54.241.2. If you have a WEB client, try the following URL:

http://www-fourier.ujf-grenoble.fr/~parisse

4 Files

The ALGB package contains the following files:

        algb.zip (Executables)
ALGBG.LIB    ALGB Library (G/GX)
ALGB.LIB     ALGB Library (S/SX/G/GX)
algb.inf     Short info
copying.gnu  GNU General Public License
ALGBG        ALGB Directory for installation on a G/GX
ALGB         ALGB Directory for installation
MATR         MATR Directory
INTG         INTG Directory
ARIT         ARIT Directory
QUADR        QUADR Directory

FUNC         FUNC Program
fr           Short online reference (French)
us           Short online reference (English)
     algbdoc.zip (Documentation)
algbus.ps    English printable documentation
algbfr.ps    French printable documentation
algbus       Directory: English HTML version of the documentation
algbfr       Directory: French HTML version of the documentation
     algbunix.zip (Source codes)

4.1 Installation from another HP48.

The HP48 where you want to install ALGB must be set in server mode (don’t forget to select the IR port before). On the HP48 where you have ALGB installed, type the following program:

« :0:788 RCL RCLKEYS -> ALGB.LIB UKEYS
   « { ALGB.LIB UKEYS } SEND »
»

Of course you must replace :0:788 by say :1:788 if ALGB is installed in port 1 instead of port 0.

After the transfert, press ON on the other HP to stop the server mode. Hit the A menu key to

recall the users key and type:

STOKEYS

Purge the 'UKEYS' variable. Now install the library:

'ALGB.LIB' DUP RCL SWAP PURGE 0 STO

5 Data and main functions of the library

5.1 Data types.

Data handled by ALGB have two representation: the user representation which you use most all the time and the internal representation. If the user flag 17 is cleared, ALGB is in user representation mode, otherwise, ALGB is in internal representation mode. Sometimes you will be astonished by the results of ALGB functions because you believe that you are in user representation mode but you are in fact in internal mode. You can use the VER instruction to reset all flags in the usual state.

List of data types:

True data  Example  User  Example  Internal Example
Integer  5  real  5  real  5
Float  5.02  real  5.02  real  5
Complex  1 + 2i  symbolic '1+2*i'  complex (1,2)
Complex  (1.1,2.3)  complex (1.1,2.3)  complex (1.1,2.3)
Fractions  \frac{2}{3}  symbolic '2/3'  symbolic '2/3'
Irr. quadr. 1 + 2\sqrt{5}  symbolic '1+2*V3'  program « 1 2 5 »
Unknowns  a, x ...  variables A X  list  variable
Symbolics  a + x^{2}  symbolic 'A+X^2'  list  variable

 Lists  { 1 i }  list  { 1 'i' }  list  { 1 (0,1) }
 Array  [ [ 1 2 ] [ 3 4 ] ] array  [ [ 1 2 ] [ 3 4 ] ] array  [ [ 1 2 ] [ 3 4 ] ]
 Symb. array { { 1 2 } { 3 4 }  list  { { 1 2 } { 3 4 }  list  { { 1 2 } { 3 4 }

Notes:

• You can use binary integer (Sysrpl hexstrings) with ALGB but no simplification routines are provided for this data type.

• Numeric and symbolic vectors are of course allowed (1-d arrays).

• List of lists are used for symbolic matrices (a symbolic matrice is like a numeric matrice, just replace [ by and ] by ).

• For Sysrpl programmers: you can use the arithmetic operations on long real and system binary integers.

Remarque 1 • If flag 13 is cleared (real mode), all global names and all non rational functions are considered as real w.r.t. the instructions RE, IM, CONJ. This could lead to false simplifications if a global name stays for a complex, or if a non-rational inverse function is called with a usually forbidden real argument, like LN(-1) or ASIN(2) Solution: in the first case, replace your global name, say ’Z’, by ’X+iY’. In the second case, set flag 13.

• In internal mode, symbolics returned by ALGB may contain lists. This is not allowed by the HP compiler/decompiler, hence the stack display may show something like: 'UNKNOWN/2' or 'UNKNOWN/UNKNOWN' or 'UNKNOWN+X' (e.g. by typing { 1 2 } { 3 4 } NDXF) Caution, you can not edit such objects. Solution: use FXND to know the numerator and denominator of the above fractions, or use another stack display like EQSTK (by Mika Heiskanen) or JAVA (by Richard Steventon and Andre Schoorl).

5.2 User flags.

You may change the behaviour of ALGB by clearing or setting some user flags (and the system flag -27). Here are the most important flags of ALGB:

• flag 1: display flag (if set then verbose mode selected)

• flag 12: simplification flag (if set then ALGB calls the gcd algorithm if needed)

• flag 13: complex flag (if cleared, all expressions are assumed to be real and ALGB tries to return only real expressions)

• flag 15: real are integer flag (if set, real are assumed to be integer)

• flag 17: internal flag (if set, all data are assumed to be internal)

• flag 21: recurse flag (if set, the simplification algorithms EXPA and TSIMP will simplify in subexpressions)

• system flag -27: if set, then the user representation of complex numbers is symbolic.

To set a flag (say flag 12), type 12 SF. To clear a flag, type 12 CF. To reset ALGB flag to their defaut values

5.3 Main functions.

The main functions of the ALGB library are assigned to keys in user mode. If you don’t see the word USER in the status area (or with JAVA if you see NORM in the status area), you should go in USER mode: press once or twice the left shift key followed by the α key.

The redefined keys are most of the time preceded by the α and right-shift keys. For example,

the add addition function of ALGB is obtained in USER mode by hiting threes keys: α , Right Shift , + .

The same method applies for other operations. The +, −, ∗, /, y^{x}, \sqrt{x}, ∂, ∫, 1/x, ± keys are

redefined (after α and Right Shift ) as add, SUBT, MULT, DIV1, POWER, SQRT, CHS, FDER, FINTG, MAD. The seven first commands extend the usual HP commands to all ALGB data types. The FDER command does differentiation with respect to the main variable (contained in 'VX': usually 'X'), you don’t have to put 'X' on the stack. The FINTG tries to integrate with respect to the main variable between α and the main variable. It extends the built-in symbolic integration to rational fractions (you must however set the flag 13 to be able to integrate all rational fractions). The MAD command is not an inverse function, it is used mainly for matrices to compute eigenvalues. However the inverse is returned at level 3, that’s why I assigned this key to MAD.

The other α-right shift-redefined keys are:

• the 9 key calls EXPA which extends the EXPAN function of the HP. It fully expands expressions in one pass.

• the 6 keys is redefined as COLC which tries to factorize an expression (this has a similar effect to the COLCT instruction).

• the 3 keys lets you switch from numeric to symbolic array representaion of an array. The space key switches on or off the user flag 13.

• the 7 key finds the roots and poles of a rational fraction (function FROOTS),

• the 4 key evaluates an object at stack level 1 and returns an approximation of the time needed (tEVAL function).

• the 1 key calls rref to reduce to echelon form a symbolic or numeric array.

• The 5 key calls the EXEC function which is used to execute something (e.g replace a variable by a value, or execute a program) on an object

Let’s finish this section by two redefined keys which are not α-right shifted:

• On SX models, the →Q and →NUM keys (not alpha shifted) are redefined to handle matrices. They toggle user flags 12, 14 and 15 (XNUM to clear and XQ to set).

• On a G/GX models, use α - Right Shift -Q or →NUM (not shifted).

6 Simplifications.

Two kinds of simplifications are provided: rational simplification (EXPA) and transcental simplification (TSIMP). Transcental simplification is used to detect relations between exponentials and logarithms. Since trigonometric functions are complex exponentials, they are simplified by TSIMP too. In addition ALGB operations perform automatic rational simplifications (in user mode).

The TSIMP output is affected by the state of the flag 13: if cleared, then complex logarithms and

exponentials are converted in arctan and sin/cos functions.

7 Integration.

The commands of ALGB related to integration are:

• FINT (library-command) to integrate rational fractions of x (more precisely of the variable contained in VX, I will assume that it is X). FINT accepts a function as input and returns the primitive evaluated between α and x,

• risch to integrate rational expressions with exponentials and logarithms

• INT (INTG directory) to integrate rational expressions with (sin(x) and/or cos(x)) or (sinh(x) and/or cosh(x)) or (x and/or \sqrt{ax^{2} + bx + c})

• LIN (INTG directory) to linearize trigonometric expressions.

The risch and INT programs accept functions or integrals as input and return the primitive or the evaluated primitive.

Some examples:

• '1/(X^2-4)' FINT EVAL XQ → \frac{1}{4} ln(x − 2) − \frac{1}{4} ln(x + 2) − (\frac{1}{4} ln(α − 2) − \frac{1}{4} ln(α + 2))

• '1/(X^2-4)' risch → \frac{1}{4} ln(x − 2) − \frac{1}{4} ln(x + 2)

• '1/(X^2-4)' INT (hit the ∫ menu key after) → \frac{1}{4} ln(x − 2) − \frac{1}{4} ln(x + 2)

• x ln(x): here you must choose risch

• \sqrt{x^{2} − 1}: choose INT

• 1/(e^{x} − 1): choose risch

• 1/(sin(x) + 2): choose INT or type TSIMP and risch.

The risch program should be used in conjonction with the TSIMP function to enable trigonometric

functions integration. It is a partial implementation of the Risch algorithm: it works with pure transcendental extensions (i.e. no square root allowed), and exponential polynomial part must not contain logarithm ore other exponential. Examples:

ln ln(x), \frac{1}{e^{ln(x)^{2}+1} − 1}, x^{3}e^{(^{\frac{x+1}{x+2}})}

are allowed, but:

\sqrt{x^{2} − 1}, e^{ln(x)^{2}+1}

are not allowed. Note that − sin(x)/x^{2} + cos(x)/x is not allowed directly, but after TSIMP with flag 13 set, risch will find the primitive. A new call to TSIMP with flag 13 cleared converts back complex exponential and logarithms to trigonometric functions.

In conjonction with TSIMP and EXPA, you should obtain some non trivial results: e.g.

∫_{1}^{2} \frac{1}{x^{3} + 1} = \frac{ln(3) − 2 ln(2)}{6} + \frac{π}{18}\sqrt{3}

(you can try INT or risch followed by TSIMP and EXPA).

8 Inverse laplace transform.

Important remark: If you like p for the Laplace variable, don’t forget to set VX to p. The program INT performs inverse Laplace transform of proper rational fraction. Type the fraction, INT and choose ILAP.

8.1 Linear differential equations systems with constant coefficients.

Example: suppose we want to solve the following system:

\{ \begin{matrix}y′_{1}(x) & = & y_{1}(x) & − & y_{2}(x) & + & 1 \\ y′_{2}(x) & = & 2y_{1}(x) & + & 4y_{2}(x) & + & e^{x} \end{matrix}

with initial data y_{1}(0) = y_{2}(0) = 0.

For scalar linear differential equations with constant coefficients, it is a well-known procedure to

use Laplace transform, e.g. to solve

ay′′ + by′ + cy = f(x)

one would perform the L-transform and get:

(ap^{2} + bp + c)L(y) = L(f)(p) + a(pf(0) + f′(0)) + bf(0)

where f(0) and f′(0) are the initial consitions at x = 0. If L(f) is a rational fraction, INT ILAP allows you to recover y by inverse Laplace transform of

(L(f)(p) + a(pf(0) + f′(0)) + bf(0)/(ap^{2} + bp + c)

But this method may be applied to systems of linear differential equations, the aim of LDEC is to help you solving 1st order systems (note that higher order systems may always be rewritten as 1st order systems). Let y = (y_{1}, ..., y_{n}) be a vector of functions of x and suppose that we want to solve:

y′ = Ay + b

where A is a n × n constant matrix and b a vector of n functions of x Denote by L(b) the vector of the n Laplace transform of the n functions of b , and by y(0) the vector of n initial data at x = 0 . Then

(pId − A)L(y) = L(b) + y(0)

and:

L(y) = (pId − A)^{−}1(L(b) + y(0))

The purpose of LDEC is to compute

(pId − A)^{−}1(L(b) + y(0))

given A and L(b) + y(0).

stk2: A,

stk1: L(b) + y(0) LDEC -> (pId − A)^{−}1(L(b) + y(0))

Back to the example above: The matrix A is then: [ [ 1 -1 ] [ 2 4 ] ] and since Laplace(1)=1/p

and Laplace(e^{x})=1/(p − 1), we put L(b) + y(0) on the stack: { '1/X' '1/(X-1)' } (here VX is set as usual to 'X') After calling LDEC, we get:

{ '(X^2-6*X+4)/(X^2-X)/((X-3)*(X-2))' '(X+2)/X/((X-3)*(X-2))' } which is the { Laplace(y_{1} ) Laplace(y_{2})

}. Now to recover y_{1} or/and y_{2} just hit EVAL and INT ILAP for each coordinate. You get:

\{ \begin{matrix}y_{1} & = & −1/2 ∗ e^{x} − 2/3 + 2 ∗ e^{2x} − 5/6 ∗ e^{3x} \\ y_{2} & = & 1/3 − 2 ∗ e^{2x} + 5/3 ∗ e^{3x} \end{matrix}

To compute the solution of the LDEC with initial data y_{1}(0) = 1, y_{2}(0) = 2 just replace { '1/X' '1/(X-1)' }

by { '1/X+1' '1/(X-1)+2' }..

9 Taylor series and other functions utilities.

This section describes the FUNC directory. The main utility is TAYLR which performs Taylor expansion. This program is very similar to the built-in instruction. In addition, Taylor expansion at any point is made easier by the ability to type at level 2 an equation, e.g. 'X=1' instead of 'X' if you want to know a Taylor expansion at x = 1 instead of at x = 0. Moreover, TAYLR of ALGB can solve some undetermined forms (like the third example)

Examples:

:

* 'EXP(SIN(X))' 'X' 3 TAYLR
  -> 3: 0
     2: { 1 1 1/2 0 }
     1: '1+X+1/2*X^2'
* '\v/X' 'X=1' 4 TAYLR
  -> 3: 0
     2: { 1 1/2 -1/8 1/16 -5/128 }
     1: '1+1/2*(X-1)-1/8*(X-1)^2+1/16*(X-1)^3-5/128*(X-1)^4'
* 'EXP(1/X*LN(1+X)) 'X' 4 TAYLR
  -> 3: 0
     2: { 'e' '-e/2' '11*e/24' }
     1: 'e+-e/2*X+11*e/24*X^2'

Note that the last example can not be computed using the inbuild TAYLR instruction.

At level 1, you see the Taylor expansion (algebraic form) and at levels 2 and 3 the list form of

the Taylor expansion (level 3 is a real: the valuation).

The other programs are:

• DER: computes the derivative of a (list of) function(s) like the built-in instruction but does not evaluate numeric expressions (like \sqrt{2} or \frac{1}{2}). If level 1 is a list, DER returns the gradient of level 2:

     2: 'X^2+2*X*LN(Y)-1/Y', 1: { X Y }

-> { '2*X+2*LN(Y)' '2*X*(1/Y)+1/Y^2' } Unlike the built-in instruction, DER returns evaluated derivative for user-defined functions. Example: Suppose that z → z(x) is the primitive of \sqrt{x^{3} − 1}. Type 'Z(X)' X DER, you get ∂_{1}z(x) on the stack. Now, enter \sqrt{x^{3} − 1} and hit = then enter DEFINE. Now, you can type 'Z(X^2)' X DER EVAL and get 2x\sqrt{(x^{2})3 − 1}.

Now try 'Z(X,X^2)' X DER.

• COSN: compute cos(nx) and sin(nx) as polynomial of cos(x) and sin(x).

Input: n (a real integer) Output: 2: sin(nx) , 1: cos(nx) as polynomials of c (cos(x)) and s (sin(x)) Remarque 2 cosh(nx) and sinh(nx) as polynomials of cosh(x) and sinh(x) have the same expression. Example:

3 → (−1 + 4c^{2})s − 3c + 4c^{3}

This means that sin(3x) = (−1 + 4 cos(x)^{2}) sin(x) and cos(3x) = −3 ∗ cos(x) + 4 ∗ cos(x)^{3}.

10 Linear algebra.

In addition to the arithmetic usual operations on matrices and vectors (add, SUBT and MULT), ALGB provides: • STUDMULT: (MATR directory) student multiplication of matrices (term by term)

• TR: trace of a matrix

• TRAN: transposed of a matrix (true transposed, no conjugation)

• XY: scalar produc of two vectors

• cross (MATR directory): cross product of two 3-d vectors.

• rref: row reduction to echelon form. At level 2, the list of pivoting coefficients is given, this is usefull to treat particular cases.

• MAD: given a square matrix, returns determinant, formal inverse, a list polynomial (see section 10.1) and the characteristic polynomial.

• idn: to build a symbolic identity matrix

• LU2: given a square matrix, returns L^{−1} and U s.t. A = LU (i.e. A =stk2^{−1}×stk1) where L and U are lower and upper triangular (maybe w.r.t. to a premutation matrix, this means that computing the inverse of L or U is trivial). For comparison, the built-in LU returns three matrices L, U and P s.t. A = P LU.

• DIAG (MATR directory): diagonalisation of a square matrix (see 10.1)

• RED (MATR directory)

• DET (MATR directory): determinant (using the stupid algorithm)

• PCAR(MATR directory): characteristic polynomial using DET

10.1 Diagonalisation

Given a square matrix A, DIAG returns 7 levels:

• 7: det(A)^{−1}

• 6: A^{−1}

• 5: a list polynomial P (A) with matrix coefficient defined by the relation

(xI_{n} − A)P (A) = M(x)I_{n} = M(x)I_{n} − M(A)

where M denotes the minimal polynomial of A

• 4: characteristic polynomial

• 3: minimal polynomial M (it divides the characteristic polynomial)

• 2: list of characteristic spaces tagged by the corresponding eigenvalue (either a vector or a list of Jordan chains, each of them ending by a "Eigen:"-tagged eigenvector)

• 1: list of eigenvalues (with multiplicities)

Examples:

1.

A = ( \begin{matrix}1 & −1 & 0 \\ 0 & 1 & −1 \\ −1 & 0 & 1 \end{matrix} )

returns:

7: 0
6: { { '1/0' '1/0' '1/0' }
     { '1/0' '1/0' '1/0' }
     { '1/0' '1/0' '1/0' } }
5: { [[1 0 0]  [[-2 -1 0]  [[1 1 1]
      [0 1 0]   [0 -2 -1]   [1 1 1]
      [0 0 1]   [-1 0 -2]]  [1 1 1]] }
4: {1 -3 3 0}
3: {1 -3 3 0}
2: { :0: {1 1 1}
     :«(3,0)/2 (0,1)/2 3»: {1 '(-1,0)/2+(0,-1)/2*V3' '(-1,0)/2+(0,1)/2*V3'}
     :« (3,0)/2 (0,-1)/2 3»: {1 '(-1,0)/2+(0,1)/2*V3' '(-1,0)/2+(0,-1)/2*V3'}
1: {0 1 '(3,0)/2+(0,1)/2*V3' 1 '(3,0)/2+(0,1)/2*V3' 1 }

This means that A has 3 eigenvalues \frac{3±\sqrt{3}i}{2}, and a basis of eigenvectors is:

\{(1, 1, 1), (1, \frac{−1 ∓ i\sqrt{3}}{2}, \frac{−1 ± i\sqrt{3}}{2})\}

corresponding to 0, (3 + \sqrt{3}i)/2, (3 − \sqrt{3}i)/2. The characteristic and minimal polynomial are identical (this is generically the case) X^{3} − 3X^{2} + 3X. The matrix is not invertible ('1/0' is infinite) and has a 0 determinant.

2. For the identity matrix I_{2}, we get:

7: 1
6: { { 1 0 } { 0 1 } }
5: { [[1 0]
      [0 1]] }
4: {1 -2 1}
3: {1 -1}
1: { :1, Eigen: { 0 1 } :1, Eigen: { 1 0 } }
2: {1 2}

The minimal polynomial is X −1, different form the characteristic polynomial (X −1)^{2} = X^{2} −2X +1.

3.

( \begin{matrix}1 & 2 & 1 \\ 2 & 0 & 0 \\ 1 & 0 & 3 \end{matrix} )

4. A formal example:

{ { 1 A }
  { A 1 } }

5. In dimension greater than 2, the factorisation routines may fail. For this reason, you may call MAD, factor the characteristic polynomial (e.g. by trying the FCTR instruction of ALG48) before calling DIAG. If you have ALG48 installed, try e.g.

{ { 1 1 X }
  { 1 X 1 }
  { X 1 1 } }
MAD FCTR DIAG

Note that this example is solved by typing DIAG directly but it may fail in other situations.

6. Jordan cycles example:

A = ( \begin{matrix}3 & −1 & 1 \\ 2 & 0 & 1 \\ 1 & −1 & 2 \end{matrix} ) ,

returns:

7: -4
6: : { { '1/4' '1/4' '-1/4' }
       { '-3/4' '5/4' '-1/4' }
       { '-1/2' '1/2' '1/2'  } }
5: { [[ 1 0 0]  [[ -2 -1  1]  [[ 1 1 -1]
      [ 0 1 0]   [  2 -5  1]   [-3 5 -1]
      [ 0 0 1]]  [  1 -1 -3]]  [-2 2  2]] }
4: {1 -5 8 -4}
3: {1 -5 8 -4}
2: { :2, Char: { 2 2 1 }  :2, Eigen:{ 1 1 0 }  :1: { 0 1 1 } }
1: { 2 2 1 1}

This means that 2 has multiplicity 2, but the corresponding eigenspace is only 1-dimensional (spanned by (1, 1, 0) the last vector of the Jordan chain). The first vector (2, 2, 1) is only a characteristic vector, his image by (A − 2I) is the eigenvector (1, 1, 0) .

Remarque 3 If flag 12 is set (normal state), then eigenvectors and characteristic vectors are divided by their common greatest divisor. In case of Jordan chains, this means that the image of the i-th vector of the chain by A − λI_{n} is not necesseraly equal (but always colinear) to the i + 1-th vector of the chain.

10.2 Reduction of matrices.

In conjonction with the rref library comand, the MATR directory contains the RED program. Let’s take some examples!

10.2.1 Solving a linear system.

Suppose you want to find (x, y) s.t.:

\{ \begin{matrix}mx & + & y & = & −2 \\ mx & + & (m − 1)y & = & 2 \end{matrix}

where m is a parameter. Enter the following matrix { {M 1 -2} { M 'M-1' 2 } } and type the ENTER key to have a copy, then type rref, you get at level 1:

{ { '-M^2+2*M' 0 '2*M' } { 0 '2-M' -4 } }.

This means that:

(2m − m^{2})x = 2m, (2 − m)y = −4.

This is the case iff all the coefficients in the list at level 2 are non 0. You should have at level 2:

{ -1 'M+-2'

The second coefficient vanishes if m = 2. You have to solve for this particular case again. Recall the original matrix from the stack and type:

'M=2' EXEC

This replace all occurences of M by 2 in the original matrix. Now type rref again, you get:

{ { 2 1 -2 } { 0 0 4 }

The last line means that:

0x + 0y = 4

which is clearly impossible, the system has no solution.

If you have MATR installed, you can solve the system using the RED instruction. Put the MATRIX

on the stack, type the list of unknown followed by −1 (+1 means that the constant row is before the = sign, −1 means after the = sign):

{ X Y -1}

then hit the RED menu key and SYST, you get the solutions (value tagged by the corresponding unknown). At level 2, you get the list of cases for which you need a specific study:

{ 'M^2-2*M' '-M+2' -1 'M+-2'

This means that we have to solve again for m = 0 and m = 2.

For systems, the SOLG menu key provide another way of writing the solution as an affine space of

solutions. Recall the matrix on the stack (simply hit MATRIX), type:

'M=0' EXEC EVAL

and RED SOLG, you get at level 1:

If { }, { X Y }=:{ X -2 }

This means that (x, −2) is solution for every x. The If statement shows necessary conditions for the system to have solutions (here no condition, but if we try m = 2 instead of m = 0 the system has no solution: the If statement is If { '0=-1'} never fulfilled).

Remarque 4 SYST and SOLG order the unknown so that principal unknown are followed by auxiliary unknown. For the m = 0 case, the list of unknown returned is { Y -1 X }, this means that Y is a principal unknown and X an auxiliary one.

10.2.2 Inversion

The RED INVL implements the Gauß method to invert matrices.

{ { '1/2' -1 }
  { 1    '2/3' } }
RED INVL
-> { { '1/2' '3/4'  }
     { '-3/4' '3/8' } }

10.2.3 Determinant

The RED DET implements Gauss row reduction to compute determinant.

{ { 1 T T T }
{ 1 K T T }
{ 1 T K T }
{ 1 T T K } }
RED DET -> '(-T+K)*(-T+K)*(-T+K)'

10.3 The MMULT instruction.

This multiplication takes 3 arguments: 2 objects at levels 3 and 2, and a real at level 1: the product type:

• 0: matrix, matrix

• 1: matrix, vector

• 2: matrix, scalar,

• 3: vector, scalar

• 6: scalar, matrix

• 7: scalar, vector

10.4 Other examples.

• LU decomposition example:

A = ( \begin{matrix}1 & 2 \\ 3 & 4 \end{matrix} )

LU2 returns:

l = ( \begin{matrix}1 & 0 \\ −3 & 1 \end{matrix} ) U = ( \begin{matrix}1 & 2 \\ 0 & −2 \end{matrix} )

We have A = l^{−1}U.

• Rank of a matrix:

( \begin{matrix}1 & 2 & 4 & 6 \\ −1 & 3 & 5 & 7 \\ 2 & 1 & 0 & 1 \\ 2 & 6 & 9 & 14 \end{matrix} ) ,

hit RED RANG, and look at the matrix, the rank is the number of non zero lines (BTW you get a half reduced matrix)

• Linear relations between vectors Suppose we want to know the rank and linear relations existing between v_{1}(1, 2, 0), v_{2}(−2, −1, 1), v_{3}(0, 3, 1) ∈ IR^{3}:

{ { 1 2 0 V1 }
  { -2 -1 1 V2 }
  { 0 3 1 V3 } }

then RED, RANG, we get:

{ { 1 2 0 V1 }
  { 0 3 1 '2*V1+V2' }
  { 0 0 0 '-(2*V1)-V2+V3' } }

The family is of rank 2 (the 3rd line is 0) and −2v_{1} − v_{2} + v_{3} = 0.

10.4.1 Stack input/output for RED

Program Option  Input  Output
RED  RANG  1: matrix  2: pivots, 1: redcued matrix
RED  RED  1: matrix  2: pivots, 1: rref-ed matrix
RED  DET  1: matrix  3: pivots, 2: reduced matrix , 1:determinant
RED  INVL  1: matrix  2: pivots, 1: inverse
RED  SYST  2: matrix, 1: list of unknowns 4: list unknowns,

3: list of principals and auxiliary unknowns 2: list of pivots 1: list of tagged algebraics

RED  SOLGEN 2: matrix, 1: list of unknowns 5: pivots, 4: list of unknowns,

3: list of principal and auxiliary unknowns 2: list of tagged algebraics, 1: result

11 QUADR: Quadratic forms.

The main program is GAUSS to perform reduction of a quadratic form q. There are two ways to use GAUSS:

• symbolic input: Input: a quadratic form q (symbolic) at level 1 or the quadratic form q at level 2 and the list of variables at level 1. Output:

– stk5: D the list of diagonal coefficients (only the number of positive and negative coefficients is characteristic of q )

– stk4: P (the columns vectors of P^{−}1 form a q-orthogonal basis of A at level 3)

– stk3: A (A is the matrix of q in the dual base of the coordinates-forms at level 2, we have A = P^{t}DP where P^{t} denotes the transposed of P)

– stk2: list of variables

– stk1: symbolic as a sum of independent squares

Examples:

Example 1:
'X^2+4*X*Y-2*X*Z+4*Y^2+6*Y*Z+7*Z^2' GAUSS
5: { 1 '-25/6' '1/6' }
4: { { 1 2 -1 } { 0 1 0 } { 0 5 6 } }
3: { { 1 2 -1 } { 2 4 3 } { -1 3 7 } }
2: { X Y Z }
1: '1/6*(6*Z+5*Y)^2+ -25/6*Y^2+(-Z+2*Y+X)^2'
Example 2: same example but with variable in the reverse order
'X^2+4*X*Y-2*X*Z+4*Y^2+6*Y*Z+7*Z^2' { Z Y X } GAUSS
5: { '1/7' '7/19' '-25/19' }
4: { { 7 3 -1 } { 0 '19/7' '17/7' } { 0 0 1 } }
3: { { 7 3 -1 } { 3 4 2 } { -1 2 1 } }
2: { Z Y X }
1: '-25/19*X^2+7/19*(17/7*X+19/7*Y)^2+1/7*(-X+3*Y+7*Z)^2
Example 3: if you want to orthogonalize with parameter, you need to
enter the list of variables of the quadratic form

'X^2+2*A*X*Y' { Y X } GAUSS
5: { '-A^2' 1 }
4: { { 1 0 } { A 1 } }
3: { { 0 A } { A 1 } }
2: { Y X }
1: '(X+A*Y)^2-A^2*Y^2'

• matrix input:

Input (stack level 1): the formal matrix A of the quadratic form q Output: at stack level 2 D the diagonal coefficients list and at stack level 1 the transition matrix P . (the following holds A = P^{t}DP where P^{t} denotes the transposed of P. Note that to obtain a q -orthogonal basis, one can take the columns of the inverse P^{−1} of P).

Example: The matrix of q defined by q(x, y) = 4x^{2} + 2xy − 3y^{2} is:

A = ( \begin{matrix}4 & 1 \\ 1 & −3 \end{matrix} ) ,

(to get the matrix of q, enter '4*X^2+2*X*Y-3*Y^2', then the list of variables { X Y} and hit QXA). Call GAUSS which returns:

2: { '1/4' '-13/4' }
1: { { 4 1 } { 0 1 } }

this means that:

A = ( \begin{matrix}4 & 0 \\ 1 & 1 \end{matrix} ) × ( \begin{matrix}′1/4′ & 0 \\ 0 & ′ − 13/4′ \end{matrix} ) × ( \begin{matrix}4 & 1 \\ 0 & 1 \end{matrix} ) .

This means that:

q(x, y) = 4x^{2} + 2xy − 3y^{2} = \frac{1}{4}(4x + y)^{2} − \frac{13}{4}y^{2}.

The other utilities are QXA and AXQ to switch from algebraic to matricial representation of a

quadratic form (quadratic as symbolic to array). QXA accepts an optional list of variables at level 1.

Remarque 5 • If you want to use AXQ with large array (more than 4x4), add global identifiers to the VXYZ list.

• If you want to save time, use numeric mode (hit <->NUM> in user mode)!

12 Arithmetic.

• XFRC:

Same as →Q but handles quadratic irrationals (recognize a quadratic irrational if its expansion in contined fraction is ultimately periodic of period less or equal to 3) Examples:

1.20710678118 → \frac{1}{2} + \frac{1}{2}\sqrt{2} 1.5 → \frac{3}{2}

• CAB: (Bezout identity)

solve in the polynomials ring the equation c=ax+by Examples:

* 1 'X^2+2*X+1' 'X^2+2*X+3' -> -1 1 1
* 1 'X^2+2*X+1' 'X^2+2*X+3' -> 0

This means for the first case that:

(X + 1) = −(X^{2} + 2X + 1) ∗ (−1) + (X^{2} + 3X + 2) ∗ 1

as in the second case there is no solution because the gcd of x^{2} + 1 ∗ x + 1 and x^{2} + 3 ∗ x + 2 does not divide 1.

• EULER: Euler indicatrix Given an integer n, returns an integer e: the number of integers lower than and prime with n. Example for n = 25, e = 20 because 1,2,3,4,6,7,8,9,11,12,13,14,16,17,18,19,21,22,23,24 are prime together with 25.

• FCLI:

converts a real into a rational, an integer, or a list (his development in continued fraction). Example:

.5 → \frac{1}{2}, π → NUM → \{37151292\}

• LIFC:

continued fraction to fraction (or symbolic) For example { 3 7 15 1 292 } → 103993 and 33102. You may type / to find approximatively π).

• ORND:

round object at stack level 2, stack level 1 is the expected denominator of all rationals of the object. For example, .49999999999 + .2000000001 ∗ x 10 ORND returns .5 + .2 ∗ x.

13 Library utilities.

13.1 Data representation.

• EXPA: simplifies an object. Sets flags 12, 14 and 15. Ex:

{ '6/4*\v/2-\v/2' 'A+A' } -> { '1/2*\v/2' '2*A' }

• COLC: factorize an object. Ex:

X^2-1 -> '(X-1)*(X+1)'

For a list does a square-free factorization.

• SIMP2: simplifies two objects by dividing them by their GCD. Sets flags 12, 14 and 15. Ex:

stk2: 9, stk1: 6 SIMP2 -> stk2: 3, stk1: 2

• AXL: array ↔ list conversion.

• SXL:

– VX variable-fraction representation conversion. Switches from algebraic to list-polynomials or fractions. Ex:

     '(X+1)/(3*X-2)' <–>  '{1 1}/{3 -2}' (displayed as 'UNKNOWN/UNKNOWN')
    'X+3' <–> {1 3}

– General stack object conversion. Ex:

    'X+3*SIN(X)'
    { { 1 '5*X' } { 'SIN(X)' 1 } }
    { 'X^2+7*X' '3*SIN(X)' }
    #3h  SXL ->
    { 'SIN(X)' X }

    { 3 { 1 0 } }
    { { 1 { { 5 0 } } } { { 1 0 } 0 } }
    { { { 1 7 0 } } { 3 0 } }

To go back, type { #0 #1 #2 } SXL

• S2L: convert an algebraic polynomial in a list polynomial. Ex:

'1+2*A' A S2L -> { 2 1 } Accepts lists. Ex:
{ '1+A' '2*A-3' } A S2L -> { { 1 1 } { 2 -3} }

• L2S: converts back a list polynomial to an algebraic.

• EPSX0: strip leadings zeros in list-polynomials, replace objects by 0 if their absolute value is less than

EPS.

• FXND: splits a fraction in numerator (stack 2) and denominator (stack 1). Ex:

'(X+1)/A' FXND -> 2:X+1, 1:A

Works as well for fractions of lists polynomials.

• NDXF: reverse of FXND. Ex:

1 2 NDXF -> '1/2'

Works for all data types (you can get strange symbolics with NDXF).

• XNUM: like the in-build →NUM, but accepts lists (this was not the case on S/SX models). Clears flags 12, 14 and 15.

• XQ: like the in-build →Q. Sets flags 12, 14 and 15.

• idn: like the built-in IDN but returns a symbolic identity matrix.

13.2 Factorization.

The factorization routines work only for 1-variable polynomials (with eventual parameters).

• COLC: factorize a symbolic fraction (returns a symbolic)

• FROOTS: input is a fraction, outputs: the list of var (stack level 3), the list polynomial (2), and the list of root/multiplicity (1) (each root is followed by its multiplicity). Examples:

  * 'X^3-6*X^2+11*X-6'
    -> 3: { X }, 2:'X^3-6*X^2+11*X-6' , 1: { 2 1 3 1 1 1 }
  * '1/X^2' -> 3: { X }, 2: '1/X^2', 1: { 0 -2 }
  * 'X^2-Y^2' ->
  3: { X Y }, 2: 'X^2+2*X*Y+Y^2', 1: { '-Y' 2 }

For a symbolic, FROOTS factorizes with respect to the variable contained in VX, or if the symbolic is independant of VX with respect to the first variable of LVAR applied to the symbolic.

If stack 1 is a real integer, FROOTS computes the roots of a list polynomial with numeric coefficient using Bairstow method (real coefficients) or Laguerre method (complex coefficients). During iterations, you can modify some parameters:

– E*10: (ε × 10) multiplies the test value by 10, use this when there are multiple roots.

– E/10: divides the test value/10, for accurate precision (use this after you have found all multiple roots)

– RAND: reset current iteration (restart with random initial value)

– STOP abort iteration (for the next one or two roots)

Displayed are the last found roots and the current test value (to compare with the ε value). Before starting the program, you must specify the ε value and the number of test-successfully iterations using the following stack input:

– 3: list polynomial,

– 2: test value (positive real),

– 1: iteration number (real integer)

Example:

{ 1 -21 183 -847 2196 -3024 1728 }
1E-4
3
FROOTS
-> approximatively { 3 3 3 4 4 4 }

The result is bad since 3 and 4 are multiple roots.

• FACTO: same stack as FROOT but returns a list of "prime" factors instead of roots. Example:

  * 'X^3-6*X^2+11*X-6'
    -> 3: { X }, 2: 'X^3-6*X^2+11*X-6', 1: { '(X-2)' 1 '(X-3)' 1 '(X-1)' 1 }
  * 21 -> 3: { }, 2: 21,  1: { 3 1 7 1 }

• FCOEF: input is a list of roots/multiplicity, output is a fraction or polynomial with leading coefficient 1 having this roots (and poles). Example:

{ 1 1 2 1 3 1 } -> 'X^3-6*X^2+11*X-6'
{ A -1 2 1 } -> '(X-2)/(X-A)'

Remarque 6 Factorization of polynomial is very important in several mathematical functions, like symbolic integration or matrix diagonalization. It is important to understand the mecahnism used by ALGB to perform this tasks.

Let’s begin by recalling some mathematicals facts:

• Theorem (d’Alembert):

A polynomial of degre n has exactly n complex roots (counted with multiplicity).

• Theorem (Galois):

There is no formula for solving a generic polynomial of degre ≤ 5 (by algebraic operations and extraction of n-th roots)

This means that you can not root a multivariate polynomial of order greater than 5 (for such polynomials, systems like Maple, Reduce, Axiom Mathematica or Mupad use algebraic extension), and that you can only root numerically a univariate polynomial of order ≥ 5. Note that the generic solution of a polynomial of order 3 is still complicated and of order 4 very complicated. I think that it is not possible to handle the generic solution of polynomials of order 3 or 4 on the HP48 in a raisonable amount of time. Summary: only polynomial of order 2 are generically solved by ALGB.

However, in some situations, you can root exactly polynomials of order ≤ 3, by searching multiple

roots and by finding obvious roots (or obvious factor). The rooting algorithm of ALGB search first multiple roots by computing the GCD of the polynomial and his first derivative (this is the SQFFext algorithm in the source of ALGB). Of course flag 12 must be set for this step to be done. If a univariate polynomial has only integer (or rational) coefficients, you can find all rational solutions of this polynomial by testing a finite set of rationals (of the form numerator/denominator where numerator is a divisor of the constant coefficient and denominator a divisor of the leading coefficient). This is implemented in ALGB by the nullnamed XLIB EVIDENText which is called if flag 14 is set.

If exact solving fails, ALGB calls the numeric solver (which is the PROOT function in ALGBG.LIB

or the Bairstow or Laguerre algorithm in ALGB.LIB) and tries to find second order polynomial with integer coefficients by coupling 2 approximate solutions (this was an idea of Mika Heiskanen implemented in

POLYLIB).

Summary: ALGB should find all rationals and quadratic irrationals roots of a univariate polynomial

(unless the polynomial is bad conditionned).

For multivariate polynomials, the two first steps are achieved (EVIDENText and SQFFext). ALGB

should find all rational multivariate roots of a polynomial (1st order factors). Unfortunately, ALGB does not implement the exhaustiv search of all 2nd order (or greater) multivariate rationals factors. This can be performed using the FCTR function of the ALG48 library.

Summary: ALGB should find 1st order factors of multivariate polynomials.

Abstract of the Sysrpl XLIBs (include alextdec.h and alhash.h in your source code to use them)

to factorize:

• EVIDENText: finds rational roots SQFFext: finds square-free factorization of a polynomial SOLVext: roots a univariate polynomial numerically and tries to rebuild quadratic irrationals roots

Abstract of the users commands to factorize:

• COLC:

for symbolic input calls SQFFext, then EVIDENText, does not call SOLVext, for list input calls only SQFFext

• FROOT: calls SQFFext then EVIDENText then SOLVext,
• FACTO: calls SQFFext then EVIDENText, does not call SOLVext

Flags 12 and 14 may be cleared to skip respectively SQFFext and EVIDENText.

13.3 Polynomial and fractions.

• add, SUBT, MULT: operations on polynomials

• CHS: opposite of a polynomial

• POWER: polynomial to a power. Ex:

  'X+2'   5 POWER -> 'X^5+10*X^4+40*X^3+80*X^2+80*X+32'

• DIV2: euclidean division, returns at stack level 2 the quotient, and at stack level 1 the remainder

• DIV1: usual division

• FDER: derivative (with respect to VX)

• FINTG: antiderivative (with respect to VX). Works for polynomial and rational fractions.

• SQRT: square root of a polynomial. Ex:

  'X^2+2*X+1' -> 'X+1'

• DEGRE (list polynomial only): order. Ex:

  { 0 1 2 } -> 1

• L2S: multiple variable polynomial evaluation. Ex:

  { { 1 2 3} {4 5 6} } { X Y } L2S  ->  '(Y^2+2*Y+3)*X+(4*Y^2+5*Y+6)'

• HORN executes an Horner scheme. The syntax is:

   \begin{verbatim}   stk2: P   stk1: r   -> 3: P div (X-r), 2: r, 1: P(r)   Ex: 'X^2+2*X+3', 5 -> 'X+7', 5, 38

\end{verbatim} This means that X^{2} + 2 ∗ X + 3 = (X + 7)(X − 5) + 38.

• PTAYL: Taylor development (for polynomials only):

2: P(X), 1: r -> P(X-r)

Example:

'X^3+2*X' 2 PTAYL -> 'X^3+6*X^2+14*X+12'

means that X^{3} + 2X = (X − 2)^{3} + 6(X − 2)^{2} + 14(X − 2) + 12

13.4 Arithmetic (integers, reals and complexes or polynomials)

• FACTO (integer): gives the list of prime factors. Example:

3150 -> { 2 3 3 5 5 7 }

You can forget levels 2 and 3

• DIVIS: gives a list of divisors. Example:

21 -> { 1 7 3 21 }

• SQRT: formal square root of an integer or complex integer or polynomial. Examples:

40 → 2\sqrt{10}, a^{2} + 2a + 1 → a + 1

• GCD1: greatest common divisor (integers or polynomials). 'X^2+2*X+1' 'X^2+3*X+2' GCD1 -> 'X+1'

25 15 GCD1 -> 5

If flag 12 is clear returns 1.

• LCM: lowest common multiple (GCD(a, b)×LCM(a, b) = a × b). Examples:

'X^2+2*X+1' 'X^2+3*X+2' LCM -> '(X^2+2*X+1)*(X+2)'
25 15 LCM -> 75

• GCD3: extended gcd algorithm, given x and y returns d , u and v s.t.:

ux + vy = d

(d is a multiple of the GCD of x and y by an invertible, i.e. an integer in the univariate case)

• re: real part of a fraction, global names are always considered as reals

• im: imaginary part of a fraction,

• conj: conjugate of a fraction,

13.5 Matrices and vectors.

See section 10

13.5.1 Utilities

• LVAR: returns the list of global names of an algebraic. The list is sorted by reverse alphabetic order. Square roots are at the beginning. Example:

'SIN(A)+B*X+1' -> { X B 'SIN(A)' }
• EXEC:

– doall function:

if stack 1 is a program executes program at stack level 1 recursively on the components of a list object at stack level 2. Example: { 1 2 3 } « NEG » EXEC is the same as { 1 2 3 } CHS

– one algebraic substitution: If stack 1 is an equation ('objA=objB'), replace objA by objB in stack2.

– many subsitutions: If stack 1 and 2 are lists, replace each object of list2 in stack level 3 by the corresponding object of list1. Example:

'COS(X)+i*SIN(X)'
{ SIN COS }
{ « i * EXP DUP INV - i 2 * / »
  « i * EXP DUP INV + 2 / »
}

replace sin and cos by complex exponentials. If you call EXPA after you get e^{ix}.

A All functions (49) of Library 788 listed in alphabetic order

The following symbols will be used:

• %: real

• C%: complex

• n: integer (real integer)

• [ ]: numeric array

• { l }: list

• { m }: symbolic array

• p: polynomial ({ p } for a list-polynomial),

• { v }: list of variables

• s: symbolic object

• v: variable (global name or irrational symbolic)

• f: a fraction

• N, D: numerator and denominator of a fraction

• o: object

Name  Function  Arguments  Returns

{ALGB}  ({VAR})

ARIT  Directory  nothing  nothing
CST  Cst Menu  nothing  { l }
fr  English doc  nothing  string
FUNC  Directory  nothing  nothing
GETALL  Get All Modules  nothing  nothing
INIT  Initialization  nothing  nothing
INTG  Directory  nothing  nothing
MATR  Directory  nothing  nothing
PURG  Purge ALGB  nothing  nothing
QUAD  Directory  nothing  nothing
risch  Symbolic integration  s  s
SCST  CST-Menu string  nothing  string
SETFR  Set French Flags  nothing  nothing
TSIMP  Transcendental simplification  s  s
UKEYS  User keys string  nothing  string
us  English doc  nothing  string

{ALGB ARIT}  ({VAR})

CAB  Bezout ax + by = c  3,2,1: c, a, b  1:1 [3,2: x, y] ou 1: 0
EULER  Euler indicatrix  n  n
FCLI  → continued fraction  %  f or % or { l }
LIFC  continued fraction →  { l }  2: N, 1: D
ORND  Round an object  2: o, 1: D  o
XFRC  To quadratic irrational  o  o

{ALGB FUNC}  ({VAR})

COSN  cos, sin(nx) → P (cos x, sin x)  n > 0  2: s, 1: s
n < 0  2: { p }, 1: { p }
DER  derivative  2: s, 1: v  1: s
TAYLR  Taylor  3: s, 2: v, 1: n  3: n, 2: { p }, 1: s

{ALGB INTG}  ({VAR})

INTG  Symbolci integration  s  s
LIN  Linearization  C%, s ou { p }  s
PEVAL  Evaluation  3: primitive, 2,1:bornes  s
PRIMIT  Last primitive  Rien  s
VX  integration variable  Rien  v

{ALGB MATR}  ({VAR})

cross  Wedge product  2: x, 1: y  x ∧ y
DET  Determinant  endomorphism  determinant
DIAG  Diagonalisation (Faddeev)  endomorphism  7 à 1: cf. section 10
MATRIX  Last matrix  nothing  matrix
PCAR  Characteristic polynomial  endomorphism  s
RED  Gaußreduction  matrix or system  cf. section 10

{ALGB QUAD}  ({VAR})

AXQ  array to s quadratic form  { m }  s
2: { m }, 1: { v }  s
GAUSS Gauß quadratic form reduction 1: A 2: D, 1: P
s  5: D, 4: P, 3: A, 2: { v },1: s
2: s, 1: { v }  5: D, 4: P, 3: A, 2: { v },1: s
QXA s quadratic form to array 2: s, 1: { v } { m }
s  { m }

Name  Function  Arguments  Returns

{ALGB.LIB}  (0:788)

AXL  array ↔ list  [ ] ou { m }  { m } ou [ ]
add  Addition  2: o_{2}, 1: o_{1}  o_{2} + o_{1}
CHS  Change signe  o  −o
COLC  Factorization  s  s
conj  Conjugate  o  \overline{o}
DEGRE  Order  { p }  n
DIV1  Usual division  2: o_{2}, 1: o_{1}  o_{2}/o_{1}
DIV2  Euclidean division  2: o_{2}, 1: o_{1}  2: o_{2} div o_{1}, 1: o_{2} mod o_{1}
DIVIS  List of divisors  o  { l }
EXEC  Substitution or doall  2: { l }, 1: program  1: { l }
2: s, 1: o_{1} = o_{2}  s
3: s, 2: { l1 } 1: { l2 }  s
EPSX0  Strip expression  o  o
EXPA  Simplification  o  o′
FACTO  Factorization  o  3: { v } 2: f , 1: { f_{1}n_{1}f_{2}n_{2} ... }
FCOEF  roots/poles → Fraction  { r_{1}n_{1}r_{2}n_{2} ... }  { f }
FDER  Derivation  f  f
FINTG  Integration  f  s
FROOTS  Factorisation  o  3: { v } 2: f , 1: { s_{1}n_{1}s_{2}n_{2} ... }
FXND  Split a fraction  f = N/D  2: N, 1: D
GCD1  Greatest common divisor  2: o_{2}, 1: o_{1}  GCD(o_{2},o_{1})
GCD3  GCD (solves au + bv = d)  2,1: a , b  GCD(a, b) = d, u, v
HORN  Horner scheme  2:p , 1: r  3: p/(X − r) , 2: r, 1: P (r)
idn  identity  real integer or matrix  identity matrix
im  imaginary part  o  ℑ(o)
L2S  Evaluation  2: { p }, 1:v  p(v)
2: { p },1: { v }  p(v)
LCM  Least common multiple  2: o_{2}, 1: o_{1}  LCM(o_{2},o_{1})
LGCD  GCD of a list  { l }  o=GCD
LU2  LU decomposition  M  L^{−}1, U
LVAR  list of variables  o  { v }
MAD  inverse, char. polyn., etc.  o  4: det, 3: 1/o, 2: { p }, 1: { p }
MMULT  special product  3: o_{2}, o_{1}, n  “o_{2} × o_{1}”
MULT  product  2: o_{2}, o_{1}  o_{2} × o_{1}
NDXF  create a fraction  2: N, 1: D  f = N/D
PF  Partial fraction  f  ∑_{i} f_{i}
POWER  integral power  2: o, 1: n  o^{n}
PTAYL  Taylor for polynomials  2: P (X), 1: o  P (X − o)
re  real part  o  ℜ(o)
rref  Row reduction  M  { s }, reduced matrix
S2L  Symbolic to list  2: o, 1: { v }  2: { v }, 1:{ p }
2: o, 1: v  { p }
SIMP2  Simplification  2: o_{2}, 1: o_{1}  2: o′_{2}, 1: o′_{1}
SQRT  Square root  n or C% or s  n or C% or s
SUBT  Substraction  2: o_{2}, 1: o_{1}  o_{2} − o_{1}
SXL  Conversion  Internal [user]  User [internal]
tEVAL  Execution time  ..., 1: o  EVAL(o), 1: time
TR  trace  [ ] or { m }= (a_{ij})_{1≤i,j≤n}  ∑_{i=1}^{n} a_{ii}
TRAN  transposed  [ ] or { m }  [ ] ou { m }
VER  Version  rien  % 2.28
XY  produit scalaire de 2 vecteurs  2: x 1: y  x.y
XNUM  → Numeric  o  o
XQ  → Rational  o  o

B User Keys assignment and user flags.

α - Right Shift -ed keys:

Princ. Key Second. Key Function
EVAL  L2S
SIN Derivative FDER
COS  Integration FINTG
√  √  SQRT
y^{x}  y^{x}  POWER
1/x  1/x  MAD
±  pm  CHS
7  SOLVE  FROOTS
8  PLOT  TSIMP
9  ALGEBRA EXPA
Division  Division  DIV1
4  TIME  tEVAL
5  EXEC
6  COLC

MULT

1  clears flag 13
2  sets flag 13
3  UNITS  AXL
-  -  SUBT
SPC  rref
+ + add

The other redefined keys on S/SX models are: 33.2 (XQ) and 33.3 (XNUM) On G/GX models: 33.2 (XNUM) and 35.6 (XQ). Users flags (* if cleared by VER, # if set by VER):

• 01: if set then verbose mode else quiet mode.

• 10: internal use, if set then ALGB performs integer arithmetic otherwise ALGB performs polynomial arithmetic

• # 11: internal use, cleared if a non-rational algebraic is found

• # 12: if clear then GCD returns always 1 (→ no simplification in algebraics and no search of multiple roots of polynomials)

• # 13: if set then complex mode, else real mode (modifies the way of simplifying expressions with re, im and conj and the way of rooting polynomials)

• # 14: if set then searchs formal first order factors

• # 15: if set enables construction of integer fractions and square roots of integers

• * 16: internal use, if set then inverse Laplace transform

• * 17: cleared to use user data representation, set to use internal data representation.

• * 18: internally used by INT, if set then INT integrates a fraction of sin / cos

• * 19: internally used by INT, if set then integration else partial fraction decomposition.

• * 20: internally used by DIAG, if set then force multiplication of lists to be matrice times polynomials in Horner scheme

• * 21: if set then recursive simplification for EXPA and TSIMP You should only modify flags 12,13,14,15,17 and 21.

C Thanks to ...

Many people helped me during the creation and diffusion of ALGB:

• all anonymous ftp sites administrators, particularly those of puccini.ujf-grenoble.fr (André Voutier), ftp.funet.fi, cbs.cis.com, hplyot.obspm.fr, hpcvbbs.cv.hp.com and wuarchive.wustl.edu,

• I used the following softwares to create ALGB: the EQSTK and JAVA stack displays ([9], [13]), the JAZZ debugger ([10]), various compilers (JAZZ, the HP tools ([1]), the RPL based tools ([12]) and eventually the GNU tools ([11]).

• I looked at the following book and softwares: [6], [2], [5], [3], [4], [7], [8]. One of the best reference is certainly [3] and references therein. M. Heiskanen WWW-homespage has a lot of interesting math links.

• Some of my students and netsurfers tested various versions of ALGB and encouraged me to improve it: particularly Christophe Burdin, Craig Clifford, Jerome Coss, David Czinczenheim, Ludovic Dumaine, Frederic Hermann, Stephane Monboisset, Lionel Pilot, Eric Saya, Quan Tong Duc, Samy Venin ... Special thanks to Gilles Virone who showed me first what an HP28/48 is able to do.

•

References

[1] H. P. Corvallis. TOOLS.EXE. hpcvbbs.cv.hp.com ftp.funet.fi wuarchive.wustl.edu, 1991.

[2] P. Courbis and S. Lalande. Voyage au centre de la HP 48 S/SX. Angkor, 1993.

[3] Davenport, Siret, and Tournier. Calcul formel: Systèmes et algorithmes de manipulations algébriques. Masson, 1989.

[4] J. Ferrard. “Mathez” la HP 48 G/GX. D31 Diffusion, 1993.

[5] C. Ferraro. POLY46SX, POLY46GX, SMATH, SMATHGX. ftp.funet.fi ftp.cis.com hplyot.obspm.fr,

1993.

[6] C. N. Fiechter and M. Heiskanen. ALG48V30.ZIP. http://www.hut.fi/ mheiskan, 1996.

[7] F. Gantmacher. Théorie des matrices, volume 1. Dunod, 1966.

[8] M. Heiskanen. POLYLIB.ZIP. http://www.hut.fi/ mheiskan, 1992,1995.
[9] M. Heiskanen. EQSTK60.ZIP. http://www.hut.fi/ mhesikan, 1996.
[10] M. Heiskanen. JAZZV6x.ZIP. http://www.hut.fi/ mheiskan, 1996.
[11] M. Mikocevic. GNUTOOLS. ftp://srcm1.zems.fer.hr:/pub/hp48/tools2.0.4.zip, 1995.
[12] D. Müeller and R. Hellstern. RPL48V20.ZIP. ftp.funet.fi cbs.cis.com hplyot.obspm.fr, 1993.
[13] R. Steventon and A. Schoorl. JAVA28.ZIP. //ftp:ftp.cis.com/pub/hp48g/uploads/java28.zip,

1996.