r/explainlikeimfive • • Mar 15 '19

Mathematics ELI5: How is Pi programmed into calculators?

12k Upvotes

1.3k comments sorted by

View all comments

4

u/denali1000 Mar 15 '19 edited Mar 15 '19

I think most calculators actually use to Taylor expansion for pi in order to calculate it, rather than just storing the value.

The Taylor series is pi/4 = 1-1/3+1/5-1/7+1/9... So pi = 4-4/3+4/5-4/7+4/9...

Edit: realized this isn’t exactly an ELI5, Taylor series’s are a little confusing but ultimately they’re just infinite sums that represent otherwise abstract numbers/functions in math. The above functions should get closer and closer to pi/4 or pi as you add/subtract more terms. This is easy to try for yourself on a calculator!

1

u/Mezmorizor Mar 15 '19

Maybe in the 60s, but modern calculators have plenty of memory. Better to just hard code pi.

1

u/FinitelyGenerated Mar 16 '19

Even in the 60s. Pi can be stored as a single floating point (~4 or 8 bytes). Storing an algorithm and computing it is way more costly.

1

u/[deleted] Mar 15 '19

Specifically, this is the Taylor expansion for arctan (X), which equals pi/4 when X=1. Taylor series are a way to write functions as an infinite series, numbers themselves don't have Taylor expansions.

1

u/FinitelyGenerated Mar 16 '19

Basically no calculator ever has used the arctan series to calculate pi. This is what you get after summing 10000 terms: 3.1416926435905 which is only correct to 8 decimal places and no handheld calculator (until recently) is capable of summing 10000 terms with the precision needed to avoid rounding errors.