14

I needed the PI constant in C++, and I was lead to the answer that:

const PI = atan(1) * 4

Note that despite involving code, I'm asking this from a mathematics perspective.

I have 2 questions about this:

  • Is this an estimation of PI, or should it give me a large degree of accuracy?
  • How does this give PI?

On the second point, if I understand atan correctly, it takes a ratio of two sides, and returns the corresponding angle.

That means that atan(1) is referring a situation with 2 equal length sides.

I think I'm misunderstanding something though, as atan(1) gives me 0.7853981633974483, which seems like a very tiny angle.

If anyone can fill in the holes, it would be greatly appreciated.

asked Mar 29, 2015 at 17:26

Carcigenicate's user avatar

6

16

I'm including this little gif from Wikipedia as a great way to understand radians.

enter image description here

answered Mar 29, 2015 at 17:47

Joffan's user avatar

13

The function arctan:R(π2,π2) is the inverse of tan. (for the right domain of definition). As tanπ4=1, this means that arctan1=π4.

Regarding your question about angles: angles are (in mathematics) measured in radians (in [0,2π) or [π,π)), not in degrees: you should expect a value or order π or so, not ranging between 0 and 360.

answered Mar 29, 2015 at 17:29

Clement C.'s user avatar

4

2

You certainly know that sinπ4=cosπ4=22 so one has tanπ4=1 and therefore π=4tan11

answered Mar 29, 2015 at 17:32

marwalix's user avatar

2

This shows geometric explanation for relationship between tan, atan and Pi.

Because horizontal segment AB = 1 and vertical segment BD = 1, angle alpha = 45°. From there you can use atan( BD ) to determine 45° in radiant and take that times 4 to get Pi.

enter image description here

answered Sep 17, 2020 at 9:30

VisorZ's user avatar

1

1

Math explanation from a non-math person:

In a right angled triangle if the two short sides are equal, the angle is 45 degrees.

45 degrees in radians is π/4. (The full circumference is 2πr, 180 degrees is π and 45 degrees is π/4)

sin π/4 = cos π/4 because the two sides are equal.

tan π/4 = tan 45 = 1.

Arctan(1) is the degree (or radian) which returns a value of 1. So arctan of 1 is either 45 degrees or π/4.

π = 4*arctan(1)

answered Jun 19, 2018 at 19:24

gizmo's user avatar

0

You are correct, in all numeric programing languages like fortran, c, c++, and many others, for a program generalized input line that looks something like:

    print, numeric,  %pi , acos(-1), 4*atan(1)

all return the same numeric value. Here the system stored value %pi may be faster than trig evaluation.

    3.141592653589793, 3.141592653589793, 3.141592653589793

answered Mar 4, 2018 at 20:44

eromana's user avatar

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.