> <\body> <\expand|make-title> om>>>> \; <\address> > \; \; Numerical Algorithms Group Limited, 1992 <\with|paragraph mode|center> With Contributions From |||||||||||||||||||||||||||||||||||||||||||||||||||||>|||>|||>|||>>>> <\expand|table-of-contents|toc> Introduction to AXIOM > > > > > > > > Welcome to the world of AXIOM. We call AXIOM a scientific computation system: a self-contained toolbox designed to meet your scientific programming needs, from symbolics, to numerics, to graphics. \; This introduction is a quick overview of what AXIOM offers. > AXIOM provides a wide range of simple commands for symbolic mathematical problem solving. Do you need to solve an equation, to expand a series, or to obtain an integral? If so, just ask AXIOM to do it. <\verse> <\with|font size|0.84> Integrate (a+bx)>> with respect to . <\input|<\with|color|red> >\ > integrate(1/(x**3 * (a+b*x)**(1/3)),x) <\output> <\with|mode|math> xlog ++a+>>>|>|xlog -a+>>>|>|xarctan +a|3a>+>>>|>|12b*x-9a>>>>>>|18ax>(1)> <\input|<\with|color|red> >\ > \; <\output> \; > Axiom provides state-of-the art algebraic machinery to handle your most advanced symbolic problems. For example, AXIOM's integrator gives you the answer when an answer exists. If one does not, it provides a proof that there is no answer. Integration is just one of a multitude of symbolic operations that AXIOM provides. > AXIOM has a numerical library that includes operations for linear algebra, solutions of equations, and special functions. For many of these operations, you can select any number of floating point digits to be carried out in the computation. Solve -49x+9> to 49 digits of accuracy. > <\input|<\with|color|red> >\ > solve(x**49-49*x**4+9 = 0, 1.e-49) <\output> <\with|mode|math> x=-0.65465367069042711367,x=1.0869213956538595085,>>>|>|x=0.65465367072552717397>>>>>>(1)> <\input|<\with|color|red> >\ > \; > \; The output of a computation can be converted to FORTRAN to be used in a later numerical computation. Besides floating point numbers, AXIOM provides literally dozens of kinds of numbers to compute with. These range from various kinds of integers, to fractions, complex numbers, quaternions, continued fractions, and to numbers represented with an arbitrary base. <\verse> to the > power in base 32?> <\input|<\with|color|red> >\ > radix(10**100,32) <\output> <\with|mode|math> 9####9#####5##164##5#72##827226#####462585#7#0000000000000000000(3)> <\input|<\with|color|red> >\ > \; > > AXIOMS's interactive programming language lets you define your own functions. A simple example of a user-defined function is one that computes the successive Legendre polynomials. AXIOM lets you define these polynomicals in a piece-wise way. <\verse> <\input|<\with|color|red> >\ > p(0) == 1 <\output> <\input|<\with|color|red> >\ > \; > <\verse> <\with|prog language|axiom|this session|default> <\input|<\with|color|red> >\ > p(1) == x <\output> <\input|<\with|color|red> >\ > \; <\verse> > Legendre polynomial for 1)>.> <\with|prog language|axiom|this session|default> <\input|<\with|color|red> >\ > p(n) == ((2*n-1)*x*p(n-1) - (n-1) * p(n-2))/n <\output> <\input|<\with|color|red> >\ > \; > \; In addition to letting you define simple functions like this, the interactive language can be used to create entire application packages. All the graphs in the AXIOM Images section in the center of the book, for example, were created by programs written in the interactive language. The above definitions for p do no computation -- they simply tell AXIOM how to compute for some positive integer . To actually get a value of a Legendre polynomial, you ask for it. <\verse> <\input|<\with|color|red> >\ > p(10) <\output> \ \ \ Compiling function p with type Integer -\ Polynomial Fraction\ \ \ \ \ \ \ Integer\ \ \ \ Compiling function p as a recurrence relation. <\with|mode|math> x-x+x-x+x-(4)> <\input|<\with|color|red> >\ > \; > AXIOM applies the above pieces for to obtain the value . But it does more: it creates an optimized, compiled function . The function is formed by putting the pieces together into a single piece of code. By , we mean that the function is translated into basic machine-code. By , we mean that certain transformations are performed on that code to make it run faster. For , AXIOM actually translates the original definition that is recursive (one that calls itself) to one that is iterative (one that consists of a simple loop). <\verse> <\with|font size|0.84> What is the coefficient of > in <\input|<\with|color|red> >\ > coefficient(p(90),x,90) <\output> <\with|mode|math> (8)> <\input|<\with|color|red> >\ > \; > In general, a user function is type-analyzed and compiled on first use. Later, if you use it with a different kind of object, the function is recompiled if necessary. > A variety of data structures are available for interactive use. These include strings, lists, vectors, sets, multisets, and hash tables. A particularly useful structure for interactive use is the infinite stream: <\verse> <\input|<\with|color|red> >\ > [D(p(i),x) for i in 1..] <\output> <\with|mode|math> 1,3x,x-,x-x,x-x+,>>>|>|x-x+x,x-x+x-,>>>|>|x-x+x-x,>>>|>|x-x+x-x+,>>>|>|x-x+x-x+x,\>>>>>>(9)> <\input|<\with|color|red> >\ > \; > \; > Streams display only for a few of their initial elements. Otherwise, they are "lazy": they only compute elements when you ask for them. Data structures are an important component for building application software. Advanced users can represent data for applications in optimal fashion. In all, AXIOM offers over forty kinds of aggregate data structures, ranging from mutable structures (such as cyclic lists and flexible arrays) to storage efficient structures (such as bit vectors). As an example, streams are used as the internal data structure structure for power series. <\verse> about /2>?> <\input|<\with|color|red> >\ > series(log(cot(x)),x = %pi/2) <\output> <\with|mode|math> |2>+x-|2>+x-|2>+x-|2>+>>>|>|x-|2>+x-|2>+Ox-|2>>>>>>>(10)> <\input|<\with|color|red> >\ > \; > Series and streams make no attempt to compute their elements! Rather, they stand ready to deliver elements on demand. <\verse> > term of the series?> <\input|<\with|color|red> >\ > coefficient(%,50) <\output> <\with|mode|math> (11)> <\input|<\with|color|red> >\ > \; > > AXIOM also has many kinds of mathematical structures. These range from simple ones (like polynomials and matrices) to more esoteric ones (like ideals and Clifford algebras). Most structures allow the construction of arbitrarily complicated "types". <\verse> <\input|<\with|color|red> >\ > matrix [[x+%i,0], [1,-2]] <\output> <\with|mode|math> |||>||>>>>(12)> <\input|<\with|color|red> >\ > \; > <\input| > \; The AXIOM interpreter builds types in response to user input. Often, the type of the result is changed in order to be applicable to an operation. <\verse> <\input|<\with|color|red> >\ > inverse(%) <\output> <\with|mode|math> ||>|>|>|>>>>>(13)> <\input|<\with|color|red> >\ > \; > > A convenient facility for symbolic computation is "pattern matching". Suppose you have a trigonometric expression and you want to transform it to some equivalent form. Use a command to describe the transformation rules you need. Then give the rules a name and apply that name as a function to your trigonometric expressioin. <\verse> <\input|<\with|color|red> >\ > sinCosExpandRules := rule ( \ \ sin(x+y) == sin(x)*cos(y)+sin(y)*cos(x); \ \ cos(x+y) == cos(x)*cos(y) - sin(x)*sin(y); \ \ sin(2*x) == 2*sin(x)*cos(x); \ \ cos(2*x) == cos(x)**2 - sin(x)**2 ); <\output> <\input|<\with|color|red> >\ > \; > <\verse> <\input|<\with|color|red> >\ > sinCosExpandRules(sin(a+2*b+c)) <\output> <\with|mode|math> -cos asin b-2cos bsin asin b+cos acos bsin c->>>|>|csin asin b+2cos acos bcos csin b+>>>|>|bcos csin a>>>>>>(15)> <\input|<\with|color|red> >\ > \; > Using input files, you can create your own library of transformation rules relevant to your applications, then selectively apply the rules you need. > All componetns of the AXIOM algebra library are written in the AXIOM library language. This language is similar to the interactive language except for protocols that authors are obliged to follow. The library language permits you to write "polymorphic algorithms", algorithms defined to work in their most natural settings and over a variety of types. <\verse> .> <\input|<\with|color|red> >\ > S := [3*x**3 + y +1 = 0, y**2 = 4] \; > <\verse> using rational number arithmetic and 30 digits of accuracy.> <\input|<\with|color|red> >\ > solve (S,1/10**30) <\output> <\with|mode|math> y=-2,x=,>>>|>|y=2,x=-1>>>>>>(17)> <\input|<\with|color|red> >\ > \; > <\verse> with the solution expressed in radicals.> <\input|<\with|color|red> >\ > radicalSolve(S) <\output> <\with|mode|math> y=2,x=-1,y=2,x=+1|2>,>>>|>|y=2,x=+1|2>,y=-2,x=>,>>>|>|y=-2,x=-1|2>,y=-2,x=-1|2>>>>>>>(18)> <\input|<\with|color|red> >\ > \; > While these solutions look very different, the results were produced by the same internal algorithm! The internal algorithm actually works with equations over any "field". Examples of fields are the rational numbers, floating point numbers, rational fractions, power series, and general expressions involving radicals. > Users and system developers alike can augment the AXIOM library, all using one common language. Library code, like interpreter code, is compiled into machine binary code for run-time efficiency. Using this language, you can create new compuational types and new algorithmic packages. All library code is polymorphic, described in terms of a database of algebraic properties. By following the language protocols, there is an automatic, guaranteed interaction between your code and that of colleagues and system implementers. <\initial> <\collection> <\references> <\collection> |?>> |3>> > |3>> |3>> |4>> |5>> |6>> |7>> |7>> |8>> <\auxiliary> <\collection> <\associate|toc> Introduction to AXIOM |Symbolic Computation> |Numeric Computation> |Interactive Programming> |Data Structures> |Mathematical Structures> |Pattern Matching> |Polymorphic Algorthms> |Extensibility>