w w w . m a t h o m a t i c . o r g 

Notes on the Limitations of Computer Algebra Systems

by George Gesslein II

Introduction

Having written a general purpose CAS (Computer Algebra System) from scratch, I feel qualified to write a little about them.

The first powerful computer algebra systems ever written were called Macsyma and Reduce. Macsyma is a general-purpose CAS, written in LISP starting in the year 1967, developed at MIT during the 1970s, that is still being developed and used to this day as a free software version: see Maxima and its free GUI wxMaxima. Reduce is a general-purpose CAS geared towards applications in physics, started in LISP in the 1960s. It is now free software, too.

LISP is well-suited to do symbolic mathematical processing with its symbolic lists, while the C programming language is good and fast at numeric math and logic. I think the LISP system and syntax is archaic and a better language is needed, however Maxima is a superior and time-tested system for doing symbolic math.

The C programming language became very popular in the 1980s, and Mathematica, Maple, and Mathomatic were born. Because it is difficult to do symbolic math in a low-level language like C, but easy to write other languages in C, Mathematica and Maple have their own programming language. Mathomatic was a struggle to code, because it is written entirely in C and has no programming capability. This is the reason for its main limitation: No named functions support, therefore no logarithmic nor trigonometric functions. Trigonometry as complex exponentials works, as well as many other standard functions that have algebraic equivalents, using the GNU m4 macro processor as a convenient front-end to automatically substitute entered trig functions with the equivalent complex exponentials. For example:

1−> sin(x)^2+cos(x)^2
1−> ((e**(i*(x))-e**(-i*(x)))/(2i))^2+((e**(i*(x))+e**(-i*(x)))/2)^2

     ((ê^(î·x))(ê^(-î·x)))       ((ê^(î·x)) + (ê^(-î·x)))
#1: (––––––––––––––––––––––––^2) + (––––––––––––––––––––––––^2)
              (2·î)                            2

1−> simplify ; the above expression is equal to 1

#1: 1

1−> 

Rule-based Manipulations and Heuristics

Every computer algebra system uses rule-based transformations and manipulations. Heuristics such as trial and error, also known as the brute force approach, are used too. A totally heuristic CAS would eventually succeed at simplifying any mathematical expression to its smallest possible size. It would do this by trying every combination of algebraic rules on every part of the expression to produce the maximum simplification; sort of like trying every possible move in the game of chess, to find the winning move. This functionality would often make the CAS unresponsive, but it would be nice to have, if you needed perfect simplification.

Mathomatic uses some trial and error in its solve routine, and in its "smart divide" routine. Other than that, it intelligently applies all the rules of algebra to the entire expression to arrive at the best answer in a reasonable amount of time. This means the simplified result might not always be the smallest possible, but it will be easy to read and probably the answer wanted.

Writing Your Own CAS

Writing your own CAS will give you first-hand experience with the perfect beauty of mathematics and may make you smarter and a better thinker. For every algebraic rule you implement, you will need its inverse, too.

Most computer algebra systems use dynamically allocated tree structures for storing mathematical expressions. Mathomatic is different in that it uses simple, fixed-size arrays with alternating elements of operand/operator for internal representation of mathematical expressions. Each level of parentheses is indicated by a level number in each element (origin 1). This method of storage is OK for basic math, but won't work for more advanced math, where functions can have more than two parameters, and matrices are required. I designed it this way because it is easy for me to understand and write code for it. And I didn't want a lot of memory fragmentation, which is what you will get when dynamically allocating and freeing a lot of different sized objects in C.

You will need to decide on how to represent constants. Standard floating point arithmetic (which Mathomatic uses) is very fast because it is usually done in hardware with an FPU (Floating Point Unit). Floating point is severely limiting and is only good for quick calculations and approximations. It has problems representing fractions (rational arithmetic), which are very important in a CAS, and round-off error accumulates quickly. Mathomatic can and often does convert floating point values to fractions, as long as the numerator and denominator are small integers and the fraction is very, very close to the original floating point value. Other computer algebra systems use true rational data types and abitrary-precision arithmetic ("bignum") libraries, which allow for very large and long numbers and fractions with exactness or high precision.

Solving in Mathomatic is almost entirely based on the rule:

y = f(x)
g(y) = g(f(x))
where f() and g() are any function, and:
arcf(y) = arcf(f(x))
arcf(y) = x

where arcf() is the inverse function of f(). An equality will remain an equality when both sides of the equation are operated on by the same mathematical operation. Some simplification is also necessary during solving.

Mathomatic has proved it is practical and efficient to do generalized polynomial operations. By generalized, we mean that the coefficients of polynomials are not specially treated or stored in any way. They are not separated out from the main variable of the polynomial. Maximum simplification of all expressions is not possible unless everything is generalized.


Mathomatic downloads
Mathomatic info and examples Mathomatic user documentation

Privacy statement
Site map Mathomatic logo