Sin(x) Taylor Series, finally

In my last post I mentioned that I would turn on debugging to see where the program failed before resorting to writing a double precision version.

As it turns out, the program wasn’t really failing, it was the precision I set on the output format that caused the error (CONVERSION). The OVERFLOW error was simply a division that produced a number so small it was beyond single precision. The first was fixed with a simple format change, f(11.7) from f(7.3) and the second… well that needed double precision.

It is very easy to convert the program to double precision. A global replace on ‘float binary’ to ‘float binary(53)’ and it’s done. Since PL/I requires ALL variables to be declared, the above will get them all. Recompile & link, and it’s done.

Except… Digital Research (DR) PL/I for Z80 up to V1.3 explicitly does NOT support double precision; it’s stated quite clearly in the manual. I needed V1.4 for double precision support.

After searching the ‘net and coming up blank, I posed on ‘retrocomputingforum.com’, and immediately EdS came to the rescue with a link to DR PL/I 1.4. I downloaded it, installed it and the program compiled and linked.

Running the program with 11 terms is now not a problem. Using my higher precision formats I could run the program from 0 to 4Pi with 11 terms. Below I show the special cases (exact values of Pi) and you can see how the result differs from actual at 4Pi:

Special cases - sin( Pi):
sin x( 3.14) = 0.0000002 (calculated) 0.0000002 (actual) -0.0000000 (diff)
Special cases - sin( 2Pi):
sin x( 6.28) = -0.0000058 (calculated) -0.0000003 (actual) -0.0000055 (diff)
Special cases - sin( 3Pi):
sin x( 9.42) = -0.1299004 (calculated) -0.0000000 (actual) -0.1299003 (diff)
Special cases - sin( 4Pi):
sin x( 12.57) = -158.2498658 (calculated) -0.0000006 (actual) -158.2498652 (diff)

I now know that if I run 13 terms, it should be accurate to 4Pi, but I think I’ve effectively run the course on this program.

Next up: More conversions from FORTRAN to PL/I. Last time it was an Analytical Well Model program, which gave me a scare in PL/I V1.4 (compared to V1.3) and a couple of programs that “solve the continuity equation for composition variation with time and distance for a one dimensional, two phase, three component system”. Lots of fun. 🙂

Comments are closed.