Letter To dieHard from

Eugene R. Heath

July 5, 1993

Dear sirs,

I have been programming the VIC-20 and the C-64 for about 8 years. I would estimate that I have spent about 5000 hours programming these two computers. When I first got my VIC-20, I spent more time on it than I did on my job in the Aerospace Industry.

Most of the programs I write today are machine language programs. Most of my BASIC progams contain machine language routines stored below BASIC. I sometimes use SYS or Y=USER(X) to call up these routines, but in later years I have been diverting the ERROR Pointer at $300 to enter my routines.

Now I have been working on a program to solve algebraic polonomials of all degrees up to the sixth degree. I have spent about five years on this program. i have several notebooks filled with dozens of versions of the program as it developed during these years. Now a program a never ever done, but I reached the point where I can't find anything left that needs to be done with it except to share it with others or take it to the grave with me. I am now 68 years old.

The program consists of two pieces. The 3.5K ML part is below BASIC and can be tacked on to any BASIC program simply by LOADing the program, RUNning it, and typing NEW then pressing

So now I have programs that calculate trigonometric and Bessel's functions and solve polonomials of degree up to six. I also calculate the value of PI to 66 decimal places (mostly as a stunt) in one of my programs.

I have a String Arithematic program. A$=B$*C$ and A$=B$/C$ are all legal in the BASIC part of these programs. There is a problem with A$=B${C$ because BASIC accepts it as concatenation. The BASIC editor won't accept a similiar graphics symbol so I ended up using the UP-ARROW for addition. This is the only flaw in what would be a real professional looking program.

But, I did manage to come up with a 1.1 version that I don't know what to do with. This program copies the BASIC ROM to RAM and locks out the concatenation function (under program control). The I use the { sign for string addition. I use the BACK-ARROW for concatenation. But BASIC tinkers with my BACK-ARROW statements unless I put parentheses around the operands. I mean that, we need one set of parentheses around the whole statement to the right of the = sign.

I have mixed feelings about HEXIC 1.1. I had to add 256 bytes to my machine language program. I think that I will probably continue to use the UP-ARROW even if it does normally indicate that we are raising a number to a power. So, I have a HEXIC 1.1 that I don't know what to do with. I will put a copy of it on the disks in case this is the version some people will prefer. This program has a new error message. We have EXPONENT ERROR in the 1.1 version because I had some room left over.

There are also coommands to set the cursor and clear the screen following it (STAB(CO), VTAB(CO)) and Truncating commands to round off the numbers at any degree of precision [A$(9)=T(C$(3),45)). Or simply A=T(A$) if you want to default to the maximum that BASIC itself can handle and convert to standard BASIC math at the same time. I have also mechanized an IF statement for Strings. We will get a NULL STRING ERROR IN nnnn if we run into any null strings. String Arithematic can't handle null strings. nnnn, of course, is the number of the BASIC statement. If we try to divide by 0 (zero), then we use the BASIC DIVISION BY ZERO error message. Since I am using the BASIC ROM for so much of the program, many of the usual BASIC error messages will be seen when encountered.

IF A =< X THEN C$=PQ$(N-1)/XX$ is legal. A$=1.23456E{1:C$=T(A$,3) makes C$={12.3

B$=123:C$=B$/0 or A$=0:B$=123:C$=B$/A$ will generate the BASIC error DIVISION BY ZERO

If B$ does not exist, or is B$=, then C$=A$*B$ will generate a NULL STRING error. BASIC will supply the IN nnnn part if needed.

Sometimes we use R$=STR$(R) to go from BASIC variables to String Arithematic. I use BASIC math sometimes to get a quick calculation which I then refine using string arithematic. Using Newton-Raphson to get the square root or the cube root of a number, is an example of this. In three iterations I can get the square root of a number to 68 decimal places. See the BASIC statements at line 580 in HEXIC 1.0 for this. Note that the whole Newton-Raphson loop could be put on a single line of BASIC. I use two shorter lines (583-4). Some of my earlier versions of HEXIC used cube root which is not much different than square root. It was just about as short and as fast.

C$=-A$*B$ is legal (notice the - sign) C$=A$--B$ is the same as adding A$ to B$

All of the operations of HEXIC 1.0 the Program Run Mode and the Direct Mode (which I usually call the Immediate Mode). All of the commands in the BASIC AID part of HMON 0.4 work in both modes also.

The BASIC part of HEXIC is an achievement also. Many ways to solve polonomials have been tried before I ended up with the methods I use. There were some surprises. For example, I use the general solution ofr the quartic, but had to give up on the general cubic because it was too lengthy and too slow. It turned out that my modified Newton's Method was many times faster and shorter for solving cubics. After hundreds of hours of solving polonomials I found out the hard way which way was best.

y = F(x) y' = dy/dx

There is probably one thing I should say here since I have never explained it elsewhere. When I solve a sixth order polonomial and you see a * on the screen in front of a pentic, then that pentic is the derivative of the hexic polonomial. Most times I take time out to solve this pentic in order to decide how I am going to solve the hexic.

There is a DUMP command to print the screen to the printer if you want a hard copy of the results. If the printer is ON, then it prints. If the printer is OFF, the program keeps running without any hesitation at all. The DUMP routine can tell if the printer is ON or OFF. You can dump anything, any time. Just type DUMP and press

I can find all the roots of a sixth degree polonomial to six decimal places. This includes all the pairs of complex roots (I print out the quadratics too). Of course, the accuracy improves greatly as the degree of the polonomial decreases. I wouldn't need 68 decimal digit arithematic to solve quartics to six decimal places.

The String Arithematic routines handle 70 characters. But since we have a { or a - sign and usually a decimal point, we have 68 digit arithematic. The calculations are all made with 6502 (6510) chip in the decimal mode. There are no round-off errors caused by binary to decimal conversions.

I converted the ARITH and HEXIC 0.9 versions to run on the VIC-20. I had the most trouble on the VIC-20 because of the limited screen size.

I wrote another program which makes up polonomials with known roots. Then I came up with dozens of all conceivable kinds of polonomials to use for my testing. Real roots, no real roots, all combinations of real and complex roots, repeat ed roots, you name it, I tried everythiong I could to stump my polonomial solving program. I spent more time testing than I did programming.

The original motivation for developing the program was to find the poles and zeros in a Laplace Transform. But the string arithematic routines have proven to be useful for many things. I wanted to use the C64 as a computer. When I got caugth in the big Aerospace Industry layoffs we had in California, I lost access to main-frame computers. You just can't solve polonomials using C64 BASIC arithematic.

One day I thought I needed a table of Bessel's Functions. But I saved my money and wrote a Bessel's Function routine in my modified BASIC for the C64. It is more accurate and requires no interpolation. Now there is one less big thick book in my bookcase.

My wife likes to play KENO at Las vegas. So one day I wrote a program to calculate the odds at KENO. This is another thing you can't do with the regular BASIC arithematic. But with my String Arithematic routine installed, it was no problam.

I think I used it to evaluate a sixth order determinant in one program.

I have been all alone these last five years doing something no one else seems to have ever tried to do.

Eugene R. Heath