Archived

This topic is now archived and is closed to further replies.

calculation of trigonmetric functions

This topic is 5266 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! How are functions like sin, cos, tan calculated? I want to code version of trigonmetric functions for SSE, 3DNow, MMX,... Are there some ready to use functions aviable for the different cups and their features? Thanks, Christian [edited by - Austrian Coder on August 16, 2003 8:12:45 PM]

Share this post


Link to post
Share on other sites
Sin and cos can be calculated as:

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/6! + x^8/8! - ...

Tan is a little harder; try here.

On the IA-32, you''ll only need FPU instructions such as FSIN and FCOS, which is what sin() and cos() use. Are you sure that there''ll be some benefit in writing your own functions?

Share this post


Link to post
Share on other sites
I hope there''ll be some benefit. I think SSE, [SSE2,] MMX and 3DNow are some nice extras.

I will wirte the sse version of sin and then i will see it

Share this post


Link to post
Share on other sites
cos(x)=sin(x+90degrees)
tan(x)=sin(x)/cos(x)
I''m sure you knew that, but my point is that you can just write one of the functions (using Beer Hunter''s code) and then use my little thing to do the rest. The longer you continue the ... the more accurate it will be.

Share this post


Link to post
Share on other sites