#### Archived

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

# 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.

## 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 on other sites
I don''t know of any such way. Why would you want to?

##### Share on other sites
Because I''ve found a way to calculate pi. Sadly, it uses cos. I don''t even know if it''s possible to not use radians for cos, but I was hoping.

c+*

##### Share on other sites
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 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 on other sites
quote:
Original post by KalvinB
Precalculate the values to an array size 360.

Ben

Precalculate them based on what, pi? I don''t want to use pi.

c+*

##### 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 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 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.

• 11
• 20
• 12
• 9
• 34
• ### Forum Statistics

• Total Topics
631399
• Total Posts
2999847
×