A92: RE: Trig


[Prev][Next][Index][Thread]

A92: RE: Trig




You should be aware that the power series converges for |x|<1, as you
can easily verify.  Consequently, I would not recommend that you use
|x|<2*pi for your interval. The power series for tan(x) is derived in a
straightforward fashion by means of long division of the series of
sin(x) and cos(x).  Series for inverse trig functions are easily
derivable from Integration/Differentiation Theorem for Power Series.
Check with a book on the Calculus for more info.
However, I surmise that emulated floating point routines on a 10MHZ
processor would be too slow to be practical in this application
(especially if you have a rendering loop requiring a multitude of such
computations).  It is therefore more practical to sacrifice a little
memory and build a table of values to required precision (which should
not be too excessive).  Furthermore, keep in mind that, with a little
manipulation, the interval [0, pi] of either sin or cos is entirely
sufficient, something which you could not exploit if you merely computed
the value every time.

                    -AI
                    ivanova@ucs.orst.edu
                    ant_i@hotmail.com
>Well, if you impliment all that stuff division and multiplication and
>stuff...you should know that trig is pretty easy with a power series.
For
>instance, for sin(x), you need x in radians, and it would probably be
best to
>reduce it to + or - 2pi or so.  Then you can approximate sin(x) with: x

>- -x^3/3! + x^5/5! - x^7/7! ... it gives a very close approximation
after adding
>only a few terms (seven terms or so would probably be good) try it out
on a
>calculator, see how close it gets you.  If you like it, and you write
those
>routines, there's also a power series for cos(x).  I don't think it
would work
>well for tan(x) though.  Anyhow, sin(x) and cos(x) would be good for
start on
>trig, once you have the basic addition, subtraction, multiplication and

>division implimented.
>



Follow-Ups: