Erable 2.99. Bernard Parisse Institut Fourier (CNRS UMR 5582) Universit'e de Grenoble I F38402 St Martin d'H`eres C'edex T'el. (33 --- 0) 4 76 51 43 14 Bernard.Parisse@ujfgrenoble.fr October 10, 1997 1 Contents 1 License 4 2 Installation. 4 2.1 Getting the binaries from a computer. . . . . . . . . . . . . . . . 4 2.2 Getting the binaries from another HP48. . . . . . . . . . . . . . . 4 2.3 Installing the binaries . . . . . . . . . . . . . . . . . . . . . . . . 4 3 Introduction. 5 3.1 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.2 Warnings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.3 erable--- and alg48---. . . . . . . . . . . . . . . . . . . . . . . . . 6 3.4 Implementation notes. . . . . . . . . . . . . . . . . . . . . . . . . 7 3.5 Next upgrades. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4 Main functions of the library 8 4.1 Main functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 5 Simplifications. 9 5.1 Main simplifications instructions. . . . . . . . . . . . . . . . . . . 9 5.2 Other simplifications instructions . . . . . . . . . . . . . . . . . . 9 5.3 Recurse flag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 6 Limits, Taylor and asymptotic series. 10 7 Derivation and integration. 11 7.1 Derivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 7.2 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 7.3 Integration by part . . . . . . . . . . . . . . . . . . . . . . . . . . 12 8 Ordinary differential equations. 12 8.1 Linear differential equations (systems) with constant coefficients. 12 8.1.1 Laplace transform. . . . . . . . . . . . . . . . . . . . . . . 13 8.1.2 Inverse laplace transform. . . . . . . . . . . . . . . . . . . 13 8.1.3 Linear differential equations systems with constant coef ficients. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 8.2 First order linear equation. . . . . . . . . . . . . . . . . . . . . . 14 9 Substitution, change of variables. 15 10 Factorization. 16 10.1 Summary of the instructions. . . . . . . . . . . . . . . . . . . . . 16 10.2 A word about factorization. . . . . . . . . . . . . . . . . . . . . . 18 2 11 Linear algebra. 19 11.1 Building a matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 11.2 Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 11.3 Gau Jordan row reduction. . . . . . . . . . . . . . . . . . . . . 20 11.3.1 Solving a linear system. . . . . . . . . . . . . . . . . . . . 20 11.3.2 Inversion . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 11.3.3 Determinant . . . . . . . . . . . . . . . . . . . . . . . . . 21 11.3.4 Other examples. . . . . . . . . . . . . . . . . . . . . . . . 21 11.3.5 Stack input/output for reduction instructions. . . . . . . . 22 11.4 Diagonalisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 11.5 The MMULT--- instruction. . . . . . . . . . . . . . . . . . . . . . 25 12 Quadratic forms. 26 13 Arithmetic. 27 14 Customization and other utilities. 29 14.1 Data types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 14.2 User flags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 14.3 Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 14.4 Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 14.5 Permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 14.6 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 14.7 ALGB(G)--- directory. . . . . . . . . . . . . . . . . . . . . . . . . 32 15 Final remarks. 33 A All functions of erable--- listed in alphabetic order 34 B User Keys. 37 C User flags 38 D Thanks to ... 39 3 1 License Erable v2.99 c fl 06/1997 by Bernard Parisse, with integers routines from ALG48, c fl 1997 by ClaudeNicolas Fiechter and Mika Heiskanen. HORN%%ext and BAIRSText: c fl 06/1995 by Ram Naresh Gudavalli The Erable package is made of a kernel library and the erable library which needs the library. The kernel library is a work based on ALG48 (using long integer routines) hence is submitted to the license of ALG48 (see the file license.txt). People who don't make software or authors of softwares which are free of charge may use the erable library according to the GNU General Public License (see the file copying.gnu). Authors of nonfree software(s) may use erable in the same conditions if they send me free of charge a copy of any software from which they are the author. 2 Installation. 2.1 Getting the binaries from a computer. WARNING: if you have installed ALG48, you must either upgrade to version 4.01 or desinstall it. erable assume that if ALG48 is installed, then version 4.01 is installed Connect your HP to your computer. Run kermit in server mode on your computer, and type: -- kernel.lib erableg.lib ALGBG KGET on your HP48 GX model or: -- kernel.lib erable.lib ALGB KGET on your HP48 SX model. 2.2 Getting the binaries from another HP48. Put your HP48 in server mode. On the other HP, type the following little program: !! :&:787 RCL :&:788 RCL RCLKEYS ? kernel.lib erable.lib touches !! -- kernel.lib erable.lib touches SEND ?? ?? and EVAL it. 2.3 Installing the binaries The kernel library must be installed in port 0 or port 1, for port 0 type: 'kernel.lib' DUP RCL SWAP PURGE 0 STO The erable library may be installed in any port, for example in port 2: 'erable.lib' DUP RCL SWAP PURGE 2 STO Optional but recommended: 4 ffl if you got ALGB or ALGBG from your computer, go in the ALGB or ALGBG folder and hit INIT. This will assign keys in user mode and create a little CST menu. ffl if you got touches from another HP, type: 'touches' DUP RCL SWAP PURGE STOKEYS to assign keys in user mode. If you are short in memory, you can erase parts or the whole ALGB (respec tively ALGBG) directory: e.g. for a HP48GX with 128K, I recommend to install kernel.lib, erable.lib, EQSTK, TED and UFL. 3 Introduction. 3.1 Overview. erable is a computer algebra system for the HP48. The main features are sim plifications (including complexes and square roots), integration, first order dif ferential equations, partial fraction decomposition, Laplace and inverse Laplace transform, limits, Taylor and asymptotic series, row reduction to echelon form of matrices, linear system (including over and underdetermined), eigenvalues and eigenvectors, quadratic forms, permutations, variables substitution, ... With erable you will be able to solve fast all the problems solved by a TI92 and some problems which are not solved by a TI92: some integrals (the Risch algorithm is not implemented in the TI92), some Taylor series, arithmetic, diagonalisation of matrices, change of variables,... Examples (# means not solved natively by the TI92): 1 + p 2 1 + 2 p 2 EXPA 3 7 + 1 7 p 2 e i=6 TSIMP p 3 2 + i 2 ln(1 + i) TSIMP ln(2) 2 + 1 4 i Z 1 e x \Gamma 1 dx RISCH ln(e x \Gamma 1) \Gamma x # Z (1 + 2x 2 )e x 2 dx RISCH xe x 2 # Z b a e x x dx; e x = y EXEC Z e b e a y y ln(y) dy # sin(x)=(e x \Gamma 1); x; 4 SERIES 1 \Gamma 1 2 x \Gamma 1 12 x 2 + 1 12 x 3 +O(x 4 ) # cos(x) 2 1 LAP 1 2x + 1 4(x \Gamma 2i) + 1 4(x + 2i) 5 # 1 (x 2 + 1)(x + 1) ILAP \Gamma1 2 cos(x) + 1 2 sin(x) + 1 2 e \Gammax #y 0 = xy 2 'X*SQ(Y(X))' DSOLVE EXPA y = y 0 e \Gamma1=2x 2 +1=2x 2 0 0 @ 1 1 a 1 a 1 a 1 1 1 A rref 0 @ a \Gamma 1 0 a 2 \Gamma 1 0 a \Gamma 1 \Gammaa + 1 0 0 \Gammaa 2 \Gamma a + 2 1 A # ` 0 1 \Gamma1 2 ' JORDAN Char (1)(1; 0); Eigen (1)(\Gamma1; \Gamma1) 3.2 Warnings. ffl Using a computer algebra system does not mean that you don't have to think. Most of the time, all works perfectly and you get the answer within 30 seconds. But sometimes, after 1 or 2 minutes, you don't get the answer or you get a Insufficient memory error. In this case, you should think ``Is there a different way to get the answer? Is there a way which will be easier for the system?'' And most of the time, there is a better way! Think of double integrals where you can reverse the integration order or define integrals where you may do a variable translation to have less variables, or linearity in inverse Laplace transform, ... You should learn maths and algorithms to get the best of any computer algebra system. And a system is never complete, you will need to program sometimes! ffl Most of the problems in the real life don't have exact answers but can only be solved approximately. Think of integrals, differential equations, great matrices (say e.g. 100\Theta100), ... Before learning how to solve exactly a problem, I strongly recommend to learn how to solve numerically a problem. Then for a real life problem, you will know when you must stop finding an exact solution and begin to use a numerical algorithm. 3.3 erable--- and alg48---. erable is partially derived from the alg48 package. The arithmetic functions of erable are derived from those of alg48. erable and alg48 have some other common features like simplifications, partial fraction expansion or rational in tegration. The main differences are: ffl erable is most of the time slower (about 2 times I would say, this is only a mean, sometimes alg48 is 3 times faster than erable, sometimes erable is 1 to 2 faster than alg48). Why? Because erable handles complexes and square roots natively: e.g. erable simplifies expressions like (1+i)=(1+2i), (1+ p 2)=(1\Gamma2 p 2), e 5i=6 . Hence arithmetic operations in erable must be generic, that's why they are slower. On the other hand, erable treats matrices as global objects for simplifications, as alg48 6 simplifies matrices element by element, hence erable may be faster if matrices are involved. ffl erable accepts strings embedded in symbolics, this means that if you EXPAnd (5x + 12) 16 with erable you'll get the exact answer. ffl erable handles numerical data (non integers real and complexes) ffl erable has a partial implementation of the Risch integration algorithm: it handles most of the common integrals, not only rational fractions. ffl alg48 (version 4) implements the complete factorization algorithm over the rationals, erable finds only first order factors of the squarefree fac torization and then, for 1variable polynomials, calls the numeric solver if necessary and tries to rebuild 2nd order factor. Hence, alg48 factors the expanded form of (x 4 + x 3 + 1)(x 4 + x + 1) but not x 4 + 1 and erable does not factor the first example but factors the second one. ffl The main specific feature of alg48 is the Grobner base computation. The main specifics features of erable are eigenvalues and eigenvectors of ma trices, differential equations (first order: linear, Bernouilli, homogenous; linear with constant coefficients), limits and Taylor series, quadratic forms, permutations, variable substitutions. If you have enough memory, do like me: keep both on your calc and choose the right instruction! 3.4 Implementation notes. This software is written in ML and Sysrpl with HP48 supported entries and standard instructions (and a few unsupported but static entries), 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! This package was written on a 90Mhz Pentium PC running under Linux ver sion 2, with XFree86 (XWindows system), the GNU emacs editor, my patched version of the x48 emulator (with almost instantaneous file transferts) with JAZZ installed, the gtools package (HP48 GNU compiler) and kermit. 3.5 Next upgrades. The latest versions are available by anonymous ftp in the directory: ftp://fourier.ujfgrenoble.fr/pub/hp48/ If you have a WEB client, you may prefer to go to my professional homepage: http://wwwfourier.ujfgrenoble.fr/~parisse/english.html or to my personal homepage: http://perso.wanadoo.fr/bernard.parisse 7 4 Main functions of the library erable has two major modes: complex and real mode. The user flag 13 is set in complex mode and cleared in real mode (default state). This mode affects the way erable output results. For example, partial fraction decomposition is made over I C or over IR depending of the current mode. If you see unwanted i on the stack, this means that erable is probably in complex mode, you can go back to real mode either by clearing flag 13 (13 CF) or by typing VER. Remarque 1 List of lists are used to represent symbolic matrices, in other words a symbolic matrice is entered like a numeric matrice, replacing [ by and ] by . Symbolic vectors are allowed as well (represented as lists). 4.1 Main functions. The main functions of the erable 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 ff key. The redefined keys are most of the time preceded by the ff and rightshift keys. For example, the add addition function of erable is obtained in USER mode by hiting threes keys: ff , Right Shift , + . The same method applies for other operations. The +, \Gamma, \Lambda, =, y x , p x, @, R , 1=x, \Sigma keys are redefined (after ff and Right Shift ) as add, SUBT, MULT, DIV1, POWER, SQRT, CHS, der, RISCH, INVL. These commands extend the usual HP commands to all erable data types, except for the RISCH program, which tries to integrate with respect to the main variable (contained in 'VX': usually 'X'). The other ffright shiftredefined keys are: ffl the 9 key calls EXPA which extends the EXPAN function of the HP. It fully expands rational expressions in one pass. ffl the 6 keys is redefined as COLC which tries to factorize an expression (this has a similar effect to the COLCT instruction). ffl the 3 keys calls TSIMP, the simplification program for transcendental func tions (exponentials and logarithms). ffl The EVAL 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 ffl the 2 keys lets you switch from numeric to symbolic array representation of an array. ffl the 7 key finds the roots and poles of a rational fraction (function FROOTS), ffl the 4 key evaluates an object at stack level 1 and returns an approximation of the time needed (tEVAL function). 8 ffl the 1 key switches on or off the complex mode (i.e. user flag 13), the same key but ffleft shifted switches on or off the internal flag 17. The new state is displayed. The R key has a similar effect for the recurse flag (21) (if ffrightshifted, for the ffleftshiftR this switches the +=\Gamma integration flag on or off) Let's finish this section by two redefined keys which are not ffright shifted: ffl 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). ffl On a G/GX models, use ff Right Shift Q or !NUM (not shifted). 5 Simplifications. 5.1 Main simplifications instructions. Two kinds of simplifications are provided: full rational simplification (EXPA) and transcental presimplification (TSIMP). In many situations, full rational simplifi cation achieve the whole simplification, but sometimes you will need to detect relations between exponentials and logarithms, in this situation you should call TSIMP, followed by EXPA or COLC to finish the simplification. Note that TSIMP consider trigonometric functions as complex exponentials, and simplify them this way and that the output of TSIMP is affected by the state of the flag 13 (complex flag): if cleared, then complex logarithms and exponentials are con verted to arctan and sin/cos functions. For convenience, arithmetic operations of erable perform automatic rational simplifications: e.g. add is equivalent to + EXPA. The COLC instruction may be used as a simplification instruction, it tries to factorize a symbolic. 5.2 Other simplifications instructions ffl EXPLN: replace transcendental functions by exponentials and logarithms and tries to expand the result as a sum of exponentials. Example: in complex mode, sin(x) 2 EXPLN returns 1=2 \Gamma 1=4e 2ix \Gamma 1=4e \Gamma2ix . ffl TRIG: replace complex exponentials and logarithms by trigonometric func tions and tries to simplify sinus and cosinus fonctions together (applying sin 2 + cos 2 = 1). Example: tan( x 2 ) sin(x) returns 1 \Gamma cos(x). ffl PFEXPA: like EXPA but only in subexpressions between + and \Gamma. Usefull before or after integration. The PFCOLC instruction behaves like PFEXPA but calls COLC on subexpressions. 9 5.3 Recurse flag. If flag 21 is set, ``variables'' of an expression are simplified recursively (global name are evaluated, integrals are evaluated by a call to RISCH). Warning: deriva tives of userfunctions are not evaluated (you have to do an explicit substitution with EXEC for this). 6 Limits, Taylor and asymptotic series. The program SERIES compute Taylor series, asymptotic development and limit at finite and infinite points. It should cover a lot of weierd limits, even some that are not handled by the TI92 (not surprising!) nor by maple (more surprising!) like: lim x!0 sin(1=x + x) \Gamma sin(1=x) Syntax: Put on the stack the following arguments in this order ffl the function (mandatory of course) f(x) ffl the variable if the limit point is 0 or an equation x = a if the limit point is a (and the variable is x). This entry is optional if the stack as only 1 argument. ffl the order for series expansion (optional), by default 4 (minimum 2, maxi mum 20). Type SERIES, this computes the bidirectional limit (at level 1), the equivalent e(x) (at level 2), f(x)=e(x) (at level 3), the relative rest (at level 4), the Taylor development (at level 5) and the limit point (at level 6). If you type LIMIT, you get only the limit. For onedirectional limit: put an equation x = a+0 for limit at a (left limit) or x = a \Gamma 0 (right limit). For limits at infinity: you may use the 1 symbol (from keyboard type ff right shiftI). Infinity means non signed infinity, for plus infinity use 'ABS(1) or 0 +1, for minus infinity use \Gamma1 (unary minus) or 0 \Gamma 1. Examples: 1=x x = 1 SERIES 1=x x = 0 +1 SERIES 1=x x = 0 \Gamma 1SERIES sin(x)=x x SERIES sin(x)=x x = 0 +1SERIES p (2 + x) x 5 SERIES sin(1=x + x) \Gamma sin(x) x SERIES (ln(\Gamma ln(x + x 2 )) \Gamma ln(\Gamma ln(x))) \Lambda ln(x)=x x = 0 + 0 SERIES Note that SERIES and LIMIT are still in betatesting. 10 7 Derivation and integration. 7.1 Derivation The erable derivation instruction is der, it computes the derivative of a (list of) function(s) like the builtin instruction but does not evaluate numeric ex pressions (like p 2 or 1 2 ). If level 1 is a list, der returns the gradient of level 2: 2: 'X2+2*X*LN(Y)1/Y', 1: -- X Y ? -- '2*X+2*LN(Y)' '2*X*(1/Y)+1/Y2' der returns djZ(X,Y,...) for the derivative of the userdefined function Z(X,Y,...) with respect to the jth variable of z(x; y; :::). Example: Suppose that x ! z(x) is the primitive of p x 3 \Gamma 1. Type 'Z(X)' X der, you get @ 1 z(x) on the stack. Enter p x 3 \Gamma 1 and hit = then enter DEFINE. Now, you can type 'Z(X2)' X der EVAL and get 2x p (x 2 )3 \Gamma 1. Now try 'Z(X,X2)' X der. 7.2 Integration The main integration command is RISCH. The LIN command may be used to linearize trigonometric expressions, it is called by RISCH if polynomials of sin(x) and cos(x) are integrated. The RISCH program accepts functions or integrals as input and (tries to) return the primitive or the evaluated primitive. Some examples for RISCH: ffl 1 x 2 \Gamma4 ! 1 4 ln(x \Gamma 2) \Gamma 1 4 ln(x + 2) ffl x ln(x) ! 1 2 x 2 ln(x) \Gamma 1 4 x 2 ffl p x 2 \Gamma 1 ! 1 2 ln(\Gammax + p x 2 \Gamma 1) + x 2 p x 2 \Gamma 1: ffl 1=(sin(x) + 2) ! \Gamma2 3 p 3 arctan( \Gamma2 tan(x=2)\Gamma1 3 p 3) The RISCH program should be used in conjonction with the TSIMP function to get ``weak normalization''. It is a partial implementation of the Risch algorithm: it works with pure transcendental extensions (i.e. square root are generically not allowed), and exponential polynomial part must not contain logarithms or other exponentials. Examples: ln ln(x); 1 e x 2 +1 \Gamma 1 ; x 3 e ( x+1 x+2 ) are allowed (and returned since they do not have a antiderivative which may be expressed with elementary functions), but: p ln(x) 2 \Gamma 1; e ln(x) 2 +1 are not allowed as input. Trigonometric expressions are converted in exponen tials or logarithms (if linearisation is not the direct solution). Fractions of the type F (x; p ax 2 + bx + c) are detected. 11 In conjonction with EXPA, you should obtain some non trivial results: e.g. Z 2 1 1 x 3 + 1 = ln(3) \Gamma 2 ln(2) 6 + 18 p 3 (call EXPA in real mode). 7.3 Integration by part Integration by part is implemented via the IPP command. You have to put a defined integral R b a f(t) dt at level 2 and a function u(t) at level 1. Let v = f=u 0 , then IPP returns Z b a f(t) dt = [uv(t)] b a \Gamma Z b a uv 0 (t) dt You may call IPP twice or more. In this case, the transformation applies on the first integral of the second member of the equality. Example: Z x 0 arcsin(t) 2 dt 'T' IPP p 1 \Gamma T 2 IPP EXPA returns the antiderivative of arcsin(x) 2 . Try: Z x 0 exp(t) sin(2t) dt with exp(t) IPP twice. 8 Ordinary differential equations. 8.1 Linear differential equations (systems) with constant coefficients. The most efficient tool for these equations is the Laplace transform defined by: L(y)(s) = Z 1 0 e \Gammast y(t) dt Example: solve y 0 + 2y = cos(x). Apply L, since: L(y 0 )(s) = sL(y)(s) \Gamma y(0) we get: (s + 2)L(y) = L(cos(x))(s) + y(0) hence: y(t) = L \Gamma1 ` s s 2 +1 + y(0) s + 2 ' = L \Gamma1 ` s s 2 +1 s + 2 ' + y(0)L \Gamma1 ( 1 s + 2 ) since L(cos(x))(s) = s=(s 2 + 1). 12 8.1.1 Laplace transform. The program LAP takes 2 arguments: a function f at level 2 and a divisor g at level 1 (usually the characteristic equation of the linear o.d.e.) and returns L(f)=g (Laplace transform is performed with respect to the variable contained in VX). If you need the Laplace transform alone, type 1 for g. For the above example, you would type cos(x) and x + 2 then LAP. You may wonder why I added the g function? The reason is that inverse Laplace transform of rational fractions is obtained by partial fraction decompo sition, and it is easier to decompose expressions with subexpressions separated by + or \Gamma, hence it is faster to divide by the characteristic equation each term of the Laplace transform of f . 8.1.2 Inverse laplace transform. The program ILAP performs inverse Laplace transform of rational fractions. Example: 'X/(X2+1)' 'X+2' / ILAP and you get the answer: y(t) = 1 5 (2 cos(x) + sin(x)) + \Gamma2 5 e \Gamma2x Important remark: The name of the Laplace variable is the same name as the normal variable (and is contained in VX). 8.1.3 Linear differential equations systems with constant coefficients. Example: suppose we want to solve the following system: ae y 0 1 (x) = y 1 (x) \Gamma y 2 (x) + 1 y 0 2 (x) = 2y 1 (x) + 4y 2 (x) + e x 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 00 + by 0 + cy = f(x) one would perform the Ltransform and get: (ap 2 + bp + c)L(y) = L(f)(p) + a(pf(0) + f 0 (0)) + bf(0) where f(0) and f 0 (0) are the initial consitions at x = 0. If L(f) is a rational fraction, ILAP allows you to recover y by inverse Laplace transform of L(f)(p) + a(pf(0) + f 0 (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 13 systems may always be rewritten as 1st order systems). Let y = (y 1 ; :::; yn ) be a vector of functions of x and suppose that we want to solve: y 0 = Ay + b where A is a n \Theta 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 \Gamma A)L(y) = L(b) + y(0) and: L(y) = (pId \Gamma A) \Gamma1 (L(b) + y(0)) The purpose of LDEC is to compute (pId \Gamma A) \Gamma1 (L(b) + y(0)) given A and L(b) + y(0). The stack should be prepared as: stk2: A, stk1: L(b) + y(0) then type LDEC and you will get at stack level 1: (pId \Gamma A) \Gamma1 (L(b) + y(0)) Stack level 3 is the comatrix, stack level 2 is the determinant of A. 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 \Gamma 1), we put L(b) + y(0) on the stack: -- '1/X' '1/(X1)' (here VX is set as usual to 'X'). After calling LDEC, we get: -- '(X26*X+4)/(X2X)/((X3)*(X2))' '(X+2)/X/((X3)*(X2))' which is the f Laplace(y 1 ) Laplace(y 2 ) g. Now to recover y 1 or/and y 2 just hit EVAL and ILAP for each coordinate. You'll get: ae y 1 = \Gamma1=2e x \Gamma 2=3 + 2e 2x \Gamma 5=6e 3x y 2 = 1=3 \Gamma 2e 2x + 5=3e 3x To compute the solution of the LDEC with initial data y 1 (0) = 1; y 2 (0) = 2 just replace -- '1/X' '1/(X1)' by -- '1/X+1' '1/(X1)+2' .. 8.2 First order linear equation. The DSOLVE program recognizes and solves the following equations types: ffl y 0 (x) = f(y(x)), ffl y 0 (x) = f(x; y(x)) with f homogenous, 14 ffl y 0 (x) = g(x)y(x) + h(x)y(x) ff ; ff 2 IR (Bernouilli type) ffl y 0 (x) = f(x)g(y) (separable, if f and g are rationals fractions) ffl y 0 (x) = f(x)y(x) + g(x) (linear) The input is a symbolic f(x; y(x)). Examples: Y(X)2+Y(X) DSOLVE (incomplete) X*Y(X)+1X2 DSOLVE (linear) (Y(X)X)/(Y(X)+X) DSOLVE (homogenous) Y(X)2+X*Y(X) DSOLVE (Bernouilli) The output may be y as a function of x or x as function of y or x and y as a function of t (parametric solution) for an homogenous ode. 9 Substitution, change of variables. The syntax is 'oldname=expression' EXEC. oldname may be a global name, an expression (in this case, the first global name in this expression will be isolated) or a userdefined function. For multiples substitutions, the syntax is -- oldname1 ... oldnamen -- expr1 ... exprn EXEC In this case, EXEC does only substitutions. Examples: ffl 'X2+2*X+5' 'X=1' EXEC: evaluate an expression at x = 1. ffl 'X=Y2' EXEC: change of variables, works in integrals too ffl '2*Z(X)X*d1Z(X)' 'Z(X)=X2 EXEC: in a differential equation, replace the function z(x) by x 2 . ffl 'Z(X)+d1Z(X)' 'Z(X)=EXP(X)*Y(X)' EXEC: change of function in a differential equation. ffl 'X2+X*COS(X)' 'X2=1Y' EXEC: replace x 2 by 1 \Gamma y and replace x by p 1 \Gamma y. ffl 'SIN(X)2+SIN(X)*COS(X)' -- 'SIN(X)2' -- '1COS(X)2' EXEC: replace sin(x) 2 by 1 \Gamma cos(x) 2 but does not replace sin(x) by p 1 \Gamma sin(x) 2 . The EXEC programs checks the object type at stack level 1 and performs the corresponding action: ffl doall function: if stack 1 is a program, EXEC executes program at stack level 1 recur sively 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 15 ffl one algebraic substitution: If stack 1 is an equation ('objA=objB'), replace objA by objB in stack2. ffl mulitple substitutions: 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 . ffl variable isolation: Otherwise, EXEC tries to isolate stack level 1 in stack level 2. Example: 'X25' X EXEC returns 'X' p 5. 10 Factorization. 10.1 Summary of the instructions. ffl COLC: factorize a symbolic fraction (returns a symbolic). Factorization may be incomplete, but is squarefree and all first order factors are detected. ffl FROOTS: given an object as input, 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: * 'X36*X2+11*X6' ? 3: -- X , 2:'X36*X2+11*X6' , 1: -- 2 1 3 1 1 1 * '1/X2' ? 3: -- X , 2: '1/X2', 1: -- 0 2 * 'X2Y2' ? 3: -- X Y , 2: 'X2+2*X*Y+Y2', 1: -- 'Y' 2 16 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 La guerre method (complex coefficients). During iterations, you can modify some parameters: -- E*10: ('' \Theta 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 testsuccessfully 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 1E4 3 FROOTS ? approximatively -- 3 3 3 4 4 4 The result is bad since 3 and 4 are multiple roots. ffl FACTO: same stack as FROOT but returns a list of ''prime'' factors instead of roots. Example: * 'X36*X2+11*X6' ? 3: -- X , 2: 'X36*X2+11*X6', 1: -- '(X2)' 1 '(X3)' 1 '(X1)' 1 * 21 ? 3: -- , 2: 21, 1: -- 3 1 7 1 ffl FCOEF: input is a list of roots/multiplicity, output is a fraction or polyno mial with leading coefficient 1 having this roots (and poles). Example: -- 1 1 2 1 3 1 ? 'X36*X2+11*X6' -- A 1 2 1 ? '(X2)/(XA)' 17 10.2 A word about factorization. You should skip this section for a first reading. Factorization of polynomial is very important in several mathematical functions, like symbolic integration or matrix diagonalization. It is important to understand the mechanism used by erable to perform this tasks. Let's begin by recalling some mathematicals facts: ffl Theorem (d'Alembert): A polynomial of degre n has exactly n complex roots (counted with mul tiplicity). ffl Formula exists to get the solution of polynomials up to order 4 but Galois proved the following theorem last century: There is no formula for solving a generic polynomial of degre 5 (by algebraic operations and extraction of nth roots) This means that you can not root a multivariate polynomial of order 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. Hence, only polynomial of order 2 are generically solved by erable. 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 erable search first multiple roots by computing the GCD of the polynomial and his first derivative (this is the SQFFext algorithm in the source of erable). 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 erable by the nullnamed XLIB EVIDENText which is called if flag 14 is set. Hence, erable detects all 1st order factors of a symbolic. If exact solving fails, erable calls the numeric solver for univariate polyno mials (which is the HP48GX PROOT function in erableg.lib or the Bairstow or Laguerre algorithm in erable.lib) and tries to find second order polyno mial with integer coefficients by coupling 2 approximate solutions (this was an idea of Mika Heiskanen implemented in POLYLIB). Hence erable 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). erable should find all rational multivariate roots of a polynomial (1st order factors). Unfortunately, erable 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. 18 Abstract of the Sysrpl XLIBs (include erextdec.h and erhash.h in your source code to use them) to factorize: ffl EVIDENText: finds rational roots ffl SQFFext: finds squarefree factorization of a polynomial ffl SOLVext: roots a univariate polynomial numerically and tries to rebuild quadratic irrationals roots Abstract of the users commands to factorize: ffl COLC: for symbolic input calls SQFFext, then EVIDENText, does not call SOLVext, for list input calls only SQFFext ffl FROOT: calls SQFFext then EVIDENText then SOLVext, ffl FACTO: calls SQFFext then EVIDENText, does not call SOLVext Flags 12 and 14 may be cleared to skip respectively SQFFext and EVIDENText. 11 Linear algebra. 11.1 Building a matrix To build a matrix, you may type it as usual with f and g instead of [ and ] or you may use one of the following instructions: ffl idn: to build a symbolic identity matrix ffl LCXM: to build a matrice A = (a ij ) 1il;1jc . The program takes 3 arguments: l, c and a program building a ij from i and j. Example: 2 4 !! SQ + ?? LCXM returns a 2 \Theta 4 matrix with a ij = i + j 2 . ffl VAND and HILB return Vandermonde and Hilbert matrices given respec tively a list of objects or an integer. 11.2 Operations erable provides the arithmetic usual operations on matrices and vectors (add, SUBT, MULT, CHS) and: ffl STUDMULT: (MATR directory) student multiplication of matrices (term by term) ffl TR: trace of a matrix ffl TRAN: transposed of a matrix (true transposed, no conjugation) ffl XY: scalar produc of two vectors ffl cross: cross product of two 3d vectors. 19 11.3 Gau Jordan row reduction. Summary of the instructions: ffl rref: row reduction to echelon form. At level 2, the list of pivoting coefficients is given, this is usefull to treat particular cases. ffl RANG: like rref but creates 0 only under the diagonal. ffl det and RDET: determinant (using the O(n\Lambdan!) algorithm or row reduction) ffl INVL: inverse of a matrix using row reduction ffl LU2: given a square matrix, returns L \Gamma1 and U s.t. A = LU (i.e. A =stk2 \Gamma1 \Thetastk1) where L and U are lower and upper triangular (maybe w.r.t. to a permutation matrix, this means that computing the inverse of L or U is trivial). For comparison, the builtin LU returns three matrices L, U and P s.t. A = PLU . ffl SYST and SOLGEN: solution of a linear system. 11.3.1 Solving a linear system. Suppose you want to find (x; y) s.t.: ae mx + y = \Gamma2 mx + (m \Gamma 1)y = 2 where m is a parameter. Enter the following matrix -- --M 1 2 -- M 'M1' 2 and type the ENTER key to have a copy, then type rref, you get at level 1: -- -- 'M2+2*M' 0 '2*M' -- 0 '2M' 4 . This means that: (2m \Gamma m 2 )x = 2m; (2 \Gamma m)y = \Gamma4: 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. Another way to solve the system is the SYST instruction. Put the MATRIX on the stack, type the list of unknown followed by \Gamma1 (+1 means that the constant 20 row is before the = sign, \Gamma1 means after the = sign): -- X Y 1 then type SYST, you get the solutions (value tagged by the corresponding un known). At level 2, you get the list of cases for which you need a specific study: -- 'M22*M' 'M+2' 1 'M+2' This means that we have to solve again for m = 0 and m = 2. For systems, the SOLGEN program provides another way of writing the solu tion as an affine space of solutions. Recall the matrix on the stack (simply hit SYSTEM), type: 'M=0' EXEC EVAL and SOLGEN, you get at level 1: If -- , -- X Y =:-- X 2 This means that (x; \Gamma2) is solution for every x. The If statement shows nec essary 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 2 SYST and SOLGEN 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. 11.3.2 Inversion The INVL implements the Gau method to invert matrices. -- -- '1/2' 1 -- 1 '2/3' INVL ? -- -- '1/2' '3/4' -- '3/4' '3/8' 11.3.3 Determinant The RDET instruction implements Gauss row reduction to compute determinant. -- -- 1 T T T -- 1 K T T -- 1 T K T -- 1 T T K RDET ? '(T+K)*(T+K)*(T+K)' 11.3.4 Other examples. ffl LU decomposition example: A = ` 1 2 3 4 ' 21 LU2 returns: l = ` 1 0 \Gamma3 1 ' U = ` 1 2 0 \Gamma2 ' We have A = L \Gamma1 U . ffl Rank of a matrix: 0 B B @ 1 2 4 6 \Gamma1 3 5 7 2 1 0 1 2 6 9 14 1 C C A ; hit RANG, and look at the matrix, the rank is the number of non zero lines (BTW you get a half reduced matrix) ffl Linear relations between vectors Suppose we want to know the rank and linear relations existing between v 1 (1; 2; 0), v 2 (\Gamma2; \Gamma1; 1), v 3 (0; 3; 1) 2 IR 3 : -- -- 1 2 0 V1 -- 2 1 1 V2 -- 0 3 1 V3 then 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 \Gamma2v 1 \Gamma v 2 + v 3 = 0. 11.3.5 Stack input/output for reduction instructions. Program Input Output RANG 1: matrix 2: pivots, 1: redcued matrix rref 1: matrix 2: pivots, 1: rrefed matrix RDET 1: matrix 3: pivots, 2: reduced matrix , 1:determinant INVL 1: matrix 1: inverse 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 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 22 11.4 Diagonalisation The diagonalisation instructions are: ffl MAD: given a square matrix, returns determinant, formal inverse, a list polynomial (cf. infra) and the characteristic polynomial. ffl PCAR: characteristic polynomial using det ffl JORDAN: compute eigenvalues and eigenvectors (cf. infra) Given a square matrix A, JORDAN returns 7 levels: ffl 7: det(A) \Gamma1 ffl 6: A \Gamma1 ffl 5: a list polynomial P (A) with matrix coefficient defined by the relation (xI n \Gamma A)P (A) = M(x)In = M(x)In \Gamma M(A) where M denotes the minimal polynomial of A. (this is the list polynomial returned by MAD if characteristic and minimal polynomial coincides) ffl 4: list of eigenvalues (with multiplicities) ffl 3: characteristic polynomial ffl 2: minimal polynomial M (it divides the characteristic polynomial) ffl 1: 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) Examples: 1. A = 0 @ 1 \Gamma1 0 0 1 \Gamma1 \Gamma1 0 1 1 A 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: --0 1 '3/2+i/2*V3' 1 '3/2i/2*V3' 1 23 3: 'X33*X2+3*X' 2: 'X33*X2+3*X' 1: -- :0: --1 1 1 :'3/2+i/2*V3': --1 '1/2i/2*V3' '1/2+i/2*V3' :'3/2i/2*V3': --1 '1/2+i/2*V3' '1/2i/2*V3' This means that A has 3 eigenvalues 3\Sigma p 3i 2 , and a basis of eigenvectors is: f(1; 1; 1); (1; \Gamma1 \Upsilon i p 3 2 ; \Gamma1 \Sigma i p 3 2 )g corresponding to 0; (3 + p 3i)=2; (3 \Gamma p 3i)=2. The characteristic and mini mal polynomial are identical (this is generically the case) X 3 \Gamma 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 3: 'X22*X+1' 2: 'X1' 1: -- :1, Eigen: -- 0 1 :1, Eigen: -- 1 0 The minimal polynomial is X \Gamma 1, different form the characteristic poly nomial (X \Gamma 1) 2 = X 2 \Gamma 2X + 1. 3. 0 @ 1 2 1 2 0 0 1 0 3 1 A 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 JORDAN. If you have ALG48 installed, try this: -- -- 1 1 A -- 1 A 1 -- A 1 1 MAD FCTR JORDAN 24 Note that this example is solved by typing JORDAN directly but it may fail in other situations. 6. Jordan cycles example: A = 0 @ 3 \Gamma1 1 2 0 1 1 \Gamma1 2 1 A ; 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: -- 2 2 1 1 3: 'X35*X2+8*X4' 2: 'X35*X2+8*X4' 1: -- :2, Char: -- 2 2 1 :2, Eigen:-- 1 1 0 :1: -- 0 1 1 This means that 2 has multiplicity 2, but the corresponding eigenspace is only 1dimensional (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 \Gamma 2I) is the eigenvector (1; 1; 0) . Remarque 3 If flag 12 is set (normal state), then eigenvectors and character istic vectors are divided by their common greatest divisor. In case of Jordan chains, this means that the image of the ith vector of the chain by A \Gamma In is not necesseraly equal (but always colinear) to the i + 1th vector of the chain. 11.5 The MMULT--- instruction. This multiplication takes 3 arguments: 2 objects at levels 3 and 2, and a real at level 1: the product type: ffl 0: matrix, matrix ffl 1: matrix, vector ffl 2: matrix, scalar, ffl 3: vector, scalar ffl 6: scalar, matrix ffl 7: scalar, vector It is useless in interactive mode (if you plan to write your own program over erable, you may need MMULT to switch to internal mode data representation for speed). 25 12 Quadratic forms. The main program is GAUSS to perform reduction of a quadratic form q. There are two ways to use GAUSS: ffl 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 \Gamma 1 form a qorthogonal basis of A at level 3) -- stk3: A (A is the matrix of q in the dual base of the coordinatesforms 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: 'X2+4*X*Y2*X*Z+4*Y2+6*Y*Z+7*Z2' 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*Y2+(Z+2*Y+X)2' Example 2: same example but with variable in the reverse order 'X2+4*X*Y2*X*Z+4*Y2+6*Y*Z+7*Z2' -- 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*X2+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 'X2+2*A*X*Y' -- Y X GAUSS 5: -- 'A2' 1 4: -- -- 1 0 -- A 1 3: -- -- 0 A -- A 1 26 2: -- Y X 1: '(X+A*Y)2A2*Y2' ffl 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 . We have A = P t DP where P t denotes the transposed of P . Note that to obtain a qorthogonal basis, one can take the columns of the inverse P \Gamma1 of P ). Example: The matrix of q defined by q(x; y) = 4x 2 + 2xy \Gamma 3y 2 is: A = ` 4 1 1 \Gamma3 ' ; (to get the matrix of q, enter '4*X2+2*X*Y3*Y2', 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 = ` 4 0 1 1 ' \Theta ` 0 1=4 0 0 0 0 \Gamma 13=4 0 ' \Theta ` 4 1 0 1 ' : This means that: q(x; y) = 4x 2 + 2xy \Gamma 3y 2 = 1 4 (4x + y) 2 \Gamma 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 4 If you want to save time, use numeric mode (instruction XNUM)! 13 Arithmetic. You may force integer arithmetic by setting flag 10. Otherwise, polynomial arithmetic is assumed. This is important for instructions like GCD3 or ABCUV. ffl GCD1: returns the greatest common divisor d of two objects a and b (integers, Gau integers, polynomials). Examples: 'X2+2*X+1' 'X2+3*X+2' GCD1 ? 'X+1' 25 15 GCD1 ? 5 If flag 12 is clear returns 1. 27 ffl LCM1: lowest common multiple (GCD1(a; b)\ThetaLCM1(a; b) = a \Theta b). Examples: 'X2+2*X+1' 'X2+3*X+2' LCM1 ? '(X2+2*X+1)*(X+2)' 25 15 LCM1 ? 75 ffl 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) ffl ABCUV: (Bezout identity) solve the equation c=ax+by Examples: 'X2+2*X+1' 'X2+2*X+3' 1 ? 1 1 1 'X2+2*X+1' 'X2+2*X+3' 1 ? 0 This means for the first case that: (X + 1) = \Gamma(X 2 + 2X + 1) \Lambda (\Gamma1) + (X 2 + 3X + 2) \Lambda 1 as in the second case there is no solution because the gcd of x 2 + 1 \Lambda x + 1 and x 2 + 3 \Lambda x + 2 does not divide 1. ffl LGCD: returns the gcd of a list of objects. ffl 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 ffl DIVIS: gives a list of divisors of an object. Example: 21 ? -- 1 7 3 21 ffl fact and comb: like the builtin FACT and COMB instructions but for long integers. ffl 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. ffl PA2B2 (kernel library): Given a prime p which is 1 modulo 4, returns a complex z such that jzj 2 = p. Used for factorization of Gau integers. ffl XFRC: Same as !Q but handles quadratic irrationals (recognize a quadratic irra tional if its expansion in contined fraction is ultimately periodic of period less or equal to 3) Examples: 1:20710678118 ! 1 2 + 1 2 p 2 1:5 ! 3 2 28 ffl ORND: round object at stack level 2, stack level 1 is the expected denominator of all rationals of the object. For example, :49999999999 + :2000000001 \Lambda x 10 ORND returns :5 + :2 \Lambda x. ffl re: real part of a fraction, global names are always considered as reals ffl im: imaginary part of a fraction, ffl conj: conjugate of a fraction, 14 Customization and other utilities. 14.1 Data types. Data handled by erable have two representation: the user representation which you use most all the time and the internal representation. If the user flag 17 is cleared, erable is in user representation mode, otherwise, erable is in internal representation mode. Sometimes you will be astonished by the results of erable 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, hex, string 5 hex #5 Float 5.02 real 5.02 long real %% 5.02 Gauss integer 1 + 2i symbolic '1+2*i' secondarie :: #1 #2 ; Complex (1.1,2.3) complex (1.1,2.3) long complex C%% 1.1 2.3 Fractions 2 3 symbolic '2/3' symbolic '#2/#3' Irr. quadr. 1 + 2 p 5 symbolic '1+2*V3' program !! #1 #2 #5 ?? Unknowns a, x ... variables A X list variable Symbolics a + x 2 symbolic 'A+X2' list variable Lists -- 1 i list -- 1 'i' list -- #1 :: #0 #1 ; Array [ 1 2 ] array [ [ 1 2 ] [ 3 4 ] ] array [ [ 1 2 ] [ 3 4 ] ] Symb. array -- 1 2 list -- -- 1 2 -- 3 4 list -- -- #1 #2 -- #3 #4 Remarque 5 ffl 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 nonrational 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. ffl In internal mode, symbolics returned by erable 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). 29 14.2 User flags. You may change the behaviour of erable by clearing or setting some user flags (and the system flag 27). Here are the most important flags of erable: ffl flag 1: display flag (if set then verbose mode selected) ffl flag 10: integer arithmetic (if set then erable expects integer arguments for instructions like GCD3, ABCUV or DIV2). ffl flag 12: simplification flag (if set then erable calls the gcd algorithm if needed) ffl flag 13: complex flag (if cleared, all expressions are assumed to be real and erable tries to return only real expressions) ffl flag 15: real are integer flag (if set, real are assumed to be integer) ffl flag 17: internal flag (if set, all data are assumed to be internal) ffl flag 21: recurse flag (if set, the simplification algorithms EXPA and TSIMP will simplify in subexpressions) ffl 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 this flag, type 12 CF. 14.3 Conversions ffl AXL: array $ list conversion. ffl SXL: -- VX variablefraction representation conversion. Switches from alge braic to listpolynomials or fractions. Ex: '(X+1)/(3*X2)' !? '--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 -- 'X2+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 30 The SXL may be used in programs for speed since you may spare user internal conversions. Write and test your program in user mode, then add SXL at the beginning and at the end of your program. Warning: some instructions of erable can only handle user data (e.g. RISCH), but most of the basic instruction may be used in internal mode. ffl S2L: convert an algebraic polynomial in a list polynomial. Ex: '1+2*A' A S2L ? -- 2 1 Accepts lists. Ex: -- '1+A' '2*A3' A S2L ? -- -- 1 1 -- 2 3 ffl L2S: converts back a list polynomial to an algebraic. L2S may be used for multiple variable polynomial evaluation. Ex: -- -- 1 2 3 --4 5 6 -- X Y L2S ? '(Y2+2*Y+3)*X+(4*Y2+5*Y+6)' ffl EPSX0: strip leadings zeros in listpolynomials, replace objects by 0 if their absolute value is less than EPS. ffl 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. ffl NDXF: reverse of FXND. Ex: 1 2 NDXF ? '1/2' Works for all data types (you can get strange symbolics with NDXF). ffl XNUM: like the inbuild !NUM, but accepts lists (this was not the case on S/SX models). Clears flags 12, 14 and 15. ffl XQ: like the inbuild !Q. Sets flags 12, 14 and 15. ffl idn: like the builtin IDN but returns a symbolic identity matrix. 14.4 Polynomials ffl HORN executes an Horner scheme. The syntax is: stk2: P stk1: r ? 3: P div (Xr), 2: r, 1: P(r) Ex: 'X2+2*X+3', 5 ? 'X+7', 5, 38 This means that X 2 + 2 \Lambda X + 3 = (X + 7)(X \Gamma 5) + 38. ffl PTAYL: Taylor development (for polynomials only): 2: P(X), 1: r ? P(Xr) Example: 'X3+2*X' 2 PTAYL ? 'X3+6*X2+14*X+12' means that X 3 + 2X = (X \Gamma 2) 3 + 6(X \Gamma 2) 2 + 14(X \Gamma 2) + 12 31 ffl LEGENDRE and TCHEB: given an integer n, returns a list of n+1 polynomials, respectively Legendre and Tchebycheff. ffl 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)) Remark that cosh(nx) and sinh(nx) as polynomials of cosh(x) and sinh(x) have the same expression. Example: 3 ! (\Gamma1 + 4c 2 )s \Gamma 3c + 4c 3 This means that sin(3x) = (\Gamma1 + 4 cos(x) 2 ) sin(x) and cos(3x) = \Gamma3 \Lambda cos(x) + 4 \Lambda cos(x) 3 . 14.5 Permutations A permutation is represented as a list of images of [1::n] e.g. f 5 1 2 4 3 g means oe(1) = 5, oe(2) = 1, oe(3) = 2, oe(4) = 4 and oe(5) = 3. The P2C instruction converts this representation to the cycle decomposition, here f f 1 5 3 2 g f 4 g g (stack level 2) and computes the signature of p (stack level 1). C2P converts back cycle decomposition to usual representation of permutations. CIRC compose 2 permutations in the usual representation. 14.6 Variables ffl LVAR: returns the list of ``variables'' of an algebraic. The list is sorted by reverse alphabetic order. Example: 'SIN(A)+B*X+1' ? -- X B 'SIN(A)' ffl LIDNT: list of global names of an algebraic Example: 'SIN(A)+B*X+1' ? -- X B A 14.7 ALGB(G)--- directory. This directory contains the following programs: ffl tEVAL: evaluate object 1 and returns the time it tooks to evaluate it. Not as accurate as TIM of the hacker library. ffl LATEX: converts a symbolic to a string, the L A T E X traduction of the sym bolic. To tex it on a computer, you must include the string in a math. environment (in $ $ or in ``[ ``] or in an equation environment, and you must include the file hp48.tex). 32 15 Final remarks. Remaining things to do: ffl adapt and integrate the polynomial routines of alg48 for speed, ffl rewrite the Gau reduction to include the Bareiss method, ffl rewrite the extended GCD algorithm with the subresultant method, ffl extend the Risch algorithm to multiples exponentials, and return an un evaluated integrals when there is no closed form, ffl improve the factorization algorithm (Berlekamp method over ZZ[i]. I will probably build a contrib directory (or library) if I have sufficient material to do it, your RPL and SysRPL programs are welcomed. Otherwise, I would say that erable over the Saturn architecture is almost finished since we have probably reached the microprocessor limits. Anyway, it is certainly sufficient to help maths students in their studies, which was my first aim. I will probably switch to another project like working on C(++) on a fast CPU (it would be interesting to have a sysrpl implementation written in C(++), I would only have to rebuild a kernel.lib to have a competitive erable!). 33 A All functions of erable--- listed in alphabetic order The following symbols will be used: ffl %: real ffl C%: complex ffl n: integer (real integer) ffl [ ]: numeric array ffl f l g: list ffl f m g: symbolic array ffl p: polynomial (f p g for a listpolynomial), ffl f v g: list of variables ffl s: symbolic object ffl v: variable (global name or irrational symbolic) ffl f : a fraction ffl N , D: numerator and denominator of a fraction ffl o: object List of all global variables and programs in HOME, ALGB or ALGBG, or in subdirectories: Name Function Arguments Returns CST Cst Menu nothing f l g fr French short doc nothing string GETALL Get All Modules nothing nothing INIT Initialization nothing nothing INVLAP Last inverse Laplace nothing s LATEX LAT E X conversion 1: s 1: string MATRIX Last matrix nothing m PRIMIT Last primitive nothing s PURG Purge erable nothing nothing SCST CSTMenu string nothing string SETFR Set French Flags nothing nothing SYSTEM Last system nothing fmvg TAYLR Taylor 3:s, 2: v, 1: n 3: n, 2: l, 1: s tEVAL Execution time ..., 1: o EVAL(o), 1: time UKEYS User keys string nothing string us English short doc nothing string VX integration variable Rien v 34 The 90 functions of the erable library: Name Function Arguments Returns ABCUV Bezout ax + by = c 3,2,1:a, b, c 1:1 [3,2: x, y] or 1: 0 AXL array $ list [ ] ou f m g f m g or [ ] AXQ array to s quadratic form f m g s 2: f m g, 1: f v g s C2P Cycles ! permutation f cycles g p CHS Change signe o \Gammao COLC Factorization s s COSN cos; sin(nx) ! P (cos x; sin x) n ? 0 2: s, 1: s n ! 0 2: f p g, 1: f p g CIRC Compose 2 permutations 2:p 2 , 1:p 1 p 2 ffi p 1 DEGRE Order f p g 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 f l g DSOLVE Solve y 0 (x) = f(y(x); x) f(y(x); x) y(x) EPSX0 Strip expression o o EULER Euler indicatrix n '(n) EXEC Substitution or doall 2: f l g, 1: program 1: f l g 2: s, 1: o 1 = o 2 s 3: s, 2: f l1 g 1: f l2 g s EXPA Simplification o o 0 EXPLN Conversion en exp; ln s s FACTO Factorization o 3: f v g 2: f , 1: f f 1 n 1 f 2 n 2 ... g FCOEF roots/poles ! Fraction f r 1 n 1 r 2 n 2 ... g f FROOTS Factorisation o 3: f v g 2: f , 1: f s 1 n 1 s 2 n 2 ... g FXND Split a fraction f = N=D 2: N, 1: D GAUSS Gau quadratic form reduction 1: A 2: D, 1: P s 5: D,4: P , 3: A, 2: f v g,1: s 2: s, 1: f v g 5: D,4: P , 3: A, 2: f v g,1: s 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 HILB Hilbert matrix integer r r \Theta r matrix HORN Horner scheme 2:p , 1: r 3: p=(X \Gamma r) , 2: r, 1: P (r) ILAP Inverse laplace transform s L \Gamma1 (s) INVL Inversion o o \Gamma1 IPP Integration by part R b a f(t)dt, u [uv] b a \Gamma R b a uv 0 (t)dt (v = f=u 0 ) JORDAN Diagonalisation endomorphism 7 `a 1: cf. section 11 LAP Laplace transform 2:f, 1:g L(f)=g L2S Evaluation 2: f p g, 1:v p(v) 2: f p g,1: f v g p(v) LCM1 Least common multiple 2: o 2 , 1: o 1 LCM(o 2 ,o 1 ) LCXM Matrix creation 3: r, 2: c, 1: prog 1: r \Theta c matrix LDEC Linear Diff. Equ. Systems 2: f m g, 1: f v g 3,2: (m \Gamma x) \Gamma1 , 1: (m \Gamma x) \Gamma1 v LEGENDRE Polynomials integer r list of r + 1 polynomials LGCD GCD of a list f l g o=GCD LIDNT List of variables s 2: s, 1: f v g LIMIT Limit 3:s, 2:v, 1:n s LIN Linearization C%, s ou f p g s LU2 LU decomposition M L \Gamma 1, U LVAR list of variables o f v g MAD inverse, char. polyn., etc. o 4: det, 3: 1=o, 2: f p g,1: f p g MMULT special product 3: o 2 , o 1 , n ``o 2 \Theta o 1 '' MULT product 2: o 2 , o 1 o 2 \Theta o 1 NDXF create a fraction 2: N, 1: D f = N=D ORND Round an object 2: o, 1: D o 35 P2C Permutation ! cycles p 3: p, 2: cycles, 1: signature PCAR Characteristic polynomial endomorphism s PF Partial fraction f P i f i PFCOLC COLC between + and \Gamma P i f i P i f i PFEXPA EXPA between + and \Gamma P i f i P i f i POWER integral power 2: o, 1: n o n PREVAL Evaluation 3: primitive, 2,1:bornes s PTAYL Taylor for polynomials 2: P (X), 1: o P (X \Gamma o) QXA s quadratic form to array 2: s, 1: f v g f m g s f m g RANG R'eduction sousdiagonale f m g 2: spec. cases, 1:f m g RDET Determinant (rref) endomorphism f m g 2: f m g, 1: determinant RED Gau reduction matrix or system cf. section 11 RISCH Symbolic integration s s S2L Symbolic to list 2: o, 1: f v g 2: f v g,1:f p g 2: o, 1: v f p g SERIES Series 3: s, 2: v, 1: n 6: 61: s SIMP2 Simplification 2: o 2 , 1: o 1 2: o 0 2 , 1: o 0 1 SOLGEN Solves a linear system 2:f m g, 1: f v g cf. section 11 SQRT Square root n or C% or s n or C% or s STUDMULT ``students'' \Theta of matrices M, M 0 ``M M 0 '' SUBT Substraction 2: o 2 , 1: o 1 o 2 \Gamma o 1 SXL Conversion Internal [user] User [internal] SYST Solves a linear system 2:f m g, 1: f v g cf. section 11 TCHEB Polynomials integer r list of r + 1 polynomials TR trace [ ] or f m g= (a ij ) 1i;jn P n i=1 a ii TRAN transposed [ ] or f m g [ ] ou f m g TRIG Trigonometry: ! sin; cos; arctan s s TSIMP Simplification (transcendental) s s VAND Vandermonde matrix list of objects matrix VER Version rien % 2.99 XFRC To quadratic irrational o o XNUM ! Numeric o o XQ ! Rational o o XY Scalar product of 2 vectors 2: x 1: y x:y add Addition 2: o 2 , 1: o 1 o 2 + o 1 comb Combinaisons 2: n, 1: n 0 C n 0 n conj Conjugate o o cross Wedge product 2: x, 1: y x y der derivative 2: s, 1: v 1: s det Determinant (expand) endomorphism determinant fact Factorielle n n! idn identity real integer or matrix identity matrix im imaginary part o =(o) re real part o !(o) rref Row reduction M f s g, reduced matrix 36 Functions of the kernel library (see ALG48 documentation too): Name Function Arguments Returns --kernel.lib (0:788) MOD+ Modular addition 3: n 1 , 2:n 2 , 1: n (n 1 + n 2 ) mod n MOD Modular substraction 3: n 1 , 2:n 2 , 1: n (n 1 \Gamma n 2 ) mod n MOD* Modular multiplicatin 3: n 1 , 2:n 2 , 1: n (n 1 \Lambda n 2 ) mod n MOD/ Modular division 3: n 1 , 2:n 2 , 1: n (n 1 =n 2 ) mod n MODPOW Modular power 3: n 1 , 2:n 2 , 1: n n n 2 1 mod n MODINV Modular inversion 2: n 1 , 1: n n \Gamma1 1 mod n PA2B2 Prime factorization 1: p (p j 1[4]) 1: a + ib/ a 2 + b 2 = p B User Keys. ff Right Shift ed keys: Princ. Key Second. Key Function EVAL EXEC R (recursive) sets/clears flag 21 SIN Derivative der COS Integration RISCH p p SQRT y x y x POWER 1=x 1=x INVL \Sigma pm CHS 7 SOLVE FROOTS 8 PLOT EXPLN 9 ALGEBRA EXPA Division Division DIV1 4 TIME TIM 5 TRIG 6 COLC \Theta MULT 1 (complex flag) clears/sets flag 13 2 AXL 3 UNITS TSIMP SUBT SPC rref + + add Other redefined keys: ffl On S/SX: 33.2 (XQ) and 33.3 (XNUM) ffl On G/GX: 33.2 (XNUM) and 35.6 (XQ). ffl ff Left Shift R (on both models): sets/clears flag 23 (used by RISCH) ffl ff Left Shift 1 (both models): sets/clears internal flag 37 C User flags List of the flags used by erable (* if cleared by VER, # if set by VER): ffl 01: if set then verbose mode else quiet mode. ffl 10: internal use, if set then erable performs integer arithmetic otherwise erable performs polynomial arithmetic ffl # 11: internal use, cleared if a nonrational algebraic is found ffl # 12: if clear then GCD returns always 1 (! no simplification in algebraics and no search of multiple roots of polynomials) ffl # 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 poly nomials) ffl # 14: if set then searchs formal first order factors ffl # 15: if set enables construction of integer fractions and square roots of integers ffl * 16: internal use, if set then inverse Laplace transform ffl * 17: cleared to use user data representation, set to use internal data representation. ffl * 18: internally used by INT, if set then INT integrates a fraction of sin = cos ffl * 19: internally used by INT, if set then integration else partial fraction decomposition. ffl * 20: internally used by DIAG, if set then force multiplication of lists to be matrice times polynomials in Horner scheme ffl # 21: if set then recursive simplification for EXPA and TSIMP ffl * 22: if set then the rule i 2 = \Gamma1 is not applied ffl * 23: if set then RISCH does not try linearity ffl * 24: if set then positivity of expressions are tested at x = 0 instead of x ! +1. ffl * 25: if set then the rule p x 2 = x is not applied You should only modify flags 12,13,14,15,17 and 21 to 25. 38 D Thanks to ... Many people helped me during the creation and diffusion of erable: ffl ClaudeNicolas Fiechter and Mika Heiskanen for letting me use their long integer routines for erable. Special thanks to Mika for explanations about the source code of ALG48. ffl Some of my students and netsurfers tested various versions of erable and encouraged me to improve it: particularly Christophe Burdin, Craig Clifford, Jerome Coss, David Czinczenheim, Ludovic Dumaine, Frederic Hermann, Eric Gorka, Stephane Monboisset, Lionel Pilot, Eric Saya, Quan Tong Duc, Samy Venin, John Wilson ... Special thanks to Gilles Virone who showed me first what an HP28/48 is able to do. ffl all anonymous ftp sites administrators, particularly those of fourier.ujf grenoble.fr (Andr'e Voutier), ftp.funet.fi, cbs.cis.com, hplyot.obspm.fr, hpcvbbs.cv.hp.com and wuarchive.wustl.edu, ffl I used the following softwares to create erable: the EQSTK, JAVA stack displays ([7], [15]), the JAZZ debugger ([12]), the Metakernel ([10]), var ious compilers (JAZZ, the HP tools ([1]), the RPL based tools ([14]) and eventually the GNU tools ([13]). ffl I looked at the following book and softwares: [6], [2], [5], [3], [4], [9], [11], [8] . One of the best reference is certainly [3] and references therein. M. Heiskanen WWWhomespage has a lot of interesting math links. 39 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] J. Davenport, Y. Siret, and E. Tournier. Calcul formel: Syst`emes et algo rithmes de manipulations alg'ebriques. Masson, 1989. [4] J. Ferrard. ``Mathez'' la HP 48 G/GX, Mathemati92. D31 Diffusion (HP48), http://www.ticalc.org (TI92), 1993, 1997. [5] C. Ferraro. POLY46SX, POLY46GX, SMATH, SMATHGX. ftp.funet.fi ftp.cis.com hplyot.obspm.fr, 1993. [6] C. N. Fiechter and M. Heiskanen. ALG48V40.ZIP. http://www.hut.fi/~mheiskan http://www.cs.pitt.edu/ ~ fiechter/hp48, 1997. [7] C. N. Fiechter and M. Heiskanen. EQSTK92.ZIP. http://www.hut.fi/~mheiskan, 1997. [8] B. Fuchssteiner. MuPAD. ftp://ftp.inria.fr/lang/MuPAD http://www.mupad.de, 1997. [9] F. Gantmacher. Th'eorie des matrices, volume 1. Dunod, 1966. [10] M. D. Group. Metakernel, 48+. http://, 1997. [11] M. Heiskanen. POLYLIB.ZIP. http://www.hut.fi/~mheiskan, 1992,1995. [12] M. Heiskanen. JAZZV65.ZIP. http://www.hut.fi/~mheiskan, 1996. [13] M. Mikocevic. GNUTOOLS. ftp://srcm1.zems.fer.hr:/pub/hp48/tools2.1.9.zip, 1995. [14] D. Mueller and R. Hellstern. RPL48V20.ZIP. ftp.funet.fi cbs.cis.com hplyot.obspm.fr, 1993. [15] R. Steventon, A. Schoorl, and W. Laughlin. JAVA30.ZIP. //ftp:ftp.cis.com/pub/hp48g/uploads/java30.zip http://www.engr.uvic.ca/~aschoorl, 1997. 40