Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!pasteur!ames!lll-winken!uunet!seismo!esosun!ucsdhub!sdsu!frost From: frost@sdsu.UUCP (Richard Frost) Newsgroups: comp.lang.c Subject: trig approximations Keywords: trig approximations Message-ID: <3571@sdsu.UUCP> Date: 21 Mar 89 06:40:28 GMT Organization: San Diego State University, Math/Sciences Dept. Lines: 32 Fast trig functions for C? I'm probably in on the tail end of this discusion! However, when I need trig functions in a programming enviroment that doesn't support them, I use an infinite series or product representation and truncate the terms I don't need. Perhaps this way is slower, I don't know. For example: infinity ---- (-1)^k * x^(2k + 1) sin(x) = \ _______________________ / (2k + 1)! ---- k = 0 infinity ------ x^2 = x * | | (1 - ----------) | | k^2 * pi^2 k = 1 where x IS IN RADIANS and usually forced to -2*pi <= x < 2*pi. For a given application with a known range (domain) of x-values, K = max{k} can be determined to suit your desired accuracy. Richard Frost E-mail: sdsu!frost@ucsd.edu - a scientist is someone who learns more and more about less and less until they know everything about nothing! (Ziman)