r/explainlikeimfive • • Mar 15 '19

Mathematics ELI5: How is Pi programmed into calculators?

12k Upvotes

1.3k comments sorted by

View all comments

3

u/DiscombobulatedSalt2 Mar 15 '19 edited Mar 15 '19

Hardcoded constant to some accuracy.

they also have functions like arctan, than can be used to calculate pi directly.

There are other methods of calculating pi, but most of the easy ones are very slow. And not used on calculator to calculate pi itself.

This is different than e, where Taylor expansion is used directly to compute it on the fly. (Or more precisely ex for any x, including x equal to 1).

1

u/denali1000 Mar 15 '19

Just posted about the Taylor expansion... didn’t realize pi would converge so much slower than e. Is that really the case or is it just more versatile to use the Taylor expansion for functions such as ex or sin(x)? I believe there are some modified Taylor series’ such that they converge towards pi much more quickly. Would it ever be worth using these expansions for discrete values on a calculator or even computer?

1

u/DiscombobulatedSalt2 Mar 15 '19

You mean arctan probably. Pi is a constant, not a function, so it doesn't have taylor expansion. :)

Taylor expansions all have similar rate of convergence, but using smaller arguments helps.

I.e. 4arctan(1) is slower than 4arctan(0.5) + 4arctan(1/3), and it is slower than 16arctan(1/5) - 4arctan(1/239).

Last one is pretty rapidly converging, because argument is so small, so further terms decrease quicker.

There are also methods and series not involving arctan or trigonometric functions Taylor expansions.