|
Re: Approximate!
Posted by Patrick Dingle at 04/13/2001 4:28 PM EST
College Student on team #639, Red B^2, from Ithaca High School and Cornell University.
In Reply to: Approximate!
Posted by Joe Johnson on 04/12/2001 10:40 PM EST:
Yay this is one of the rare occasions where you can use calculus... For virtually all functions you can find a power series that does a really good job at approximating the actual function (for example, sine, cosine, arctangent, etc...). The higher the order, the more accuracy you get. For sine and cosine, you can use only the first four terms of the series below and get a function remarkably similar to the real functions... at least for the applicable domain of angles between -180 and 180.
For example,
sin x = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - ...
cos x = 1 - x^2/2! + x^4/4! - x^6/5! + x^8/8! - ...
arctan x = x - x^3/3 + x^5/5 - x^7/7 + x^9/9 - ...
(! means factorial; n! = n * n-1 * n-2 * ... * 1; e.g. 5! = 5*4*3*2*1 = 120)
This area of calculus is known as Maclaurin series... check it out if you really are inspired to do so. ;p
Patrick
: Every time I think I can't live without an inverse trig
: function, I end up finding an approximation that gets
: me near enough to it without the fuss of actually
: having to use them.
: Most of the time, I am able to approximate them close
: enough with a simple linear function, but if that is
: not good enough, the lookup/lookdown functions can give
: about as complex of a function as you could want or
: need.
: Finally, if you HAVE to have it, simply devote the EEPROM
: space to defining ARCSIN, ARCCOS and ARCTAN.
: It would use up 3/8's of your code space in each
: programming slot you need the funtions, but this would
: not be too hard to manage if you break your code up
: into several slots. I think you could do it if you really
: needed it.
: Just my opinion. I have been wrong before (once ;-)
: Joe J.
__________________
This message was archived from an earlier forum system. Some information may have been left out. Start new discussion in the current forums, and refer back to these threads when necessary.
|