80787 native trig functi

 BBS: Inland Empire Archive
Date: 08-13-92 (14:37)             Number: 166
From: RICK PEDLEY                  Refer#: NONE
  To: JIM VAN NULAND                Recvd: NO  
Subj: 80787 native trig functi       Conf: (2) Quik_Bas
 On 08-12-92 Jim Van Nuland wrote to All...

 JV>   Math co-processors from the 387 onward have built-in trig
 JV> functions, which would probably be a hundred times faster
 JV> than doing the calculations the long way (that is, in
 JV> 8087 mode).
 JV>   But the Quickbasic library doesn't take advantage of this
 JV> potential speedup -- optical and astronomical programs
 JV> are full of SIN and COS calls.
 JV>   Does anyone know of a replacement trig function library
 JV> that utilizes the native cabability of the newer math
 JV> chips? Is Microsoft listening?

I don't know of such a library but there are a couple of things
you can do to speed up calculations significantly.  The first
is to pre-calculate and store in an array all the trig values
you'll need in the rest of the program. Something like:

DIM Sine!(360), Cosine!(360)

Radians! = 0

FOR x = 1 TO 360
   Radians! = Radians! + .01744  '(6.28 / 360)
   Sine!(x) = SIN(x)
   Cosine!(x) = COS(x)

x = 45
PRINT "The sine of"x"degrees is"Sine!(x)  'etc.

As well, if any portion of a formula remains constant in value
(in Circ! = 2 * Pi! * r! for example), its value should be substituted
directly, so it'd be Circ! = 6.28 * r!

The second speed-up technique is to do calculations using long
integers wherever possible, though with astronomical distances
you'll easily exceed the +/- ~2 billion range of long integers.
With money for example, you'd convert all amounts to cents and
store/calculate them as long integers.

... OFFLINE 1.40

--- Maximus 2.01wb
 * Origin: The BULLpen BBS * Intel 14.4EX (613)549-5168 (1:249/140)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET