Jump to content
  • Advertisement

Archived

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

cplusasterisk

cosine without pi

This topic is 5733 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

Is there a way to use the cosine function in C, or any other language, with degrees, and without pi? That includes the definition of the cosine function: I don''t want pi anywhere. c+*

Share this post


Link to post
Share on other sites
Advertisement
PI is like, the most important constant... EVER! Why do you want to get rid of it? While you are correct that there is a way involving cosine to evaluate PI, I remember there being lots of nasty exponents and coefficients... very slow!

PI is your friend. Don''t hate him for what he is.

Share this post


Link to post
Share on other sites
Yeah, pi is great. The reason why I want to get rid of it is because it would be quite silly to use pi to calculate pi.

Anyway, c is better than pi.



c+*

Share this post


Link to post
Share on other sites
Using this formula for arctan:

∞ x2n-1(-1)n-1
Σ -----------
n=1 2n-1


We can plug in 1 for x, and get one-fourth the value of PI (arctan(1) = π/4). You might have to evaluate to a bunch of terms though. I know it doesn't use cosine, but that's the best a quick google search could do for finding PI...

EDIT: Grrr, growing hostility towards formatting...

[edited by - Zipster on October 1, 2002 1:25:57 AM]

Share this post


Link to post
Share on other sites
I''ve already got my own formula to find pi,

lim (n*cos(90-180/n))
x->infinity

I just wanted a way to evaluate the cos part without having to convert 90 to 1/2pi and 180 to pi. I tried looking for the definition of cosine, but I got scared away. Coding a definition for cosine is a whole different project.

c+*

Share this post


Link to post
Share on other sites
Hmmm...

lim(n->inf) n cos(pi/2 - pi/n)
= lim(n->inf) [cos(pi/2 - pi/n)] / [1/n]
= lim(n->inf) [-pi/n² sin(pi/2 - pi/n)] / [-1/n²]
= lim(n->inf) pi sin(pi/2 - pi/n)
= lim(n->inf) pi sin(pi/2 - 0)
= lim(n->inf) pi
= pi

...yeah, it works. I''m not too sure whether it''ll be useful, though.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!