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 CAS ever written is called Macsyma. Macsyma is a LISP program, started in the late 1960s, that is still being used to this day (see Maxima and its GUI wxMaxima). LISP is well-suited to do symbolic mathematical processing, while the C programming language is good at numeric math and logic. I think the LISP system and syntax is archaic and a better language is needed.

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 logarithms nor trigonometric functions. Trigonometry as complex exponentials works, 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

     ((e#^(i#·x)) − (e#^(-1·i#·x)))       ((e#^(i#·x)) + (e#^(-1·i#·x)))
#1: (−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−^2) + (−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−^2)
                 (2·i#)                                 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.

Have fun, and remember to value life!


Mathomatic downloads
Valid HTML 4.01 Transitional Mathomatic logo