How to Design Your Own π to e Converter
How to Design Your Own π to e Converter
Harlan J. Brothers
The base of the natural logarithm, e, has been studied since the early seven-
teenth century (Maor, 1994, pp. 26–27). Its limit definition formula
n
e = lim 1 + n1 (1)
n→∞
Given: f (x) and g(x) are monotone over x, |f (x)| > |g(x)|, and f (x), g(x) are
divergent, then
f (x)
f (x) + g(x) g(x)
GCM (x) = f (x), g(x) 6= 0 (3)
f (x)
30 How to Design Your Own π to e Converter
and
f (x)
f (x) + g(x) g(x)
e = lim (4)
|x|→∞ f (x)
In the same manner, we can set the functions f (x) = cot(θ) and g(x) = tan(θ).
As θ approaches π from below, cot(θ) → −∞ and tan(θ) → 0. As θ approaches π
from above, cot(θ) → ∞ while tan(θ) → 0. Substituting these functions in (4) and
using trigonometric identities we arrive at
cot2 (θ)
e = lim sec2 (θ) for π
2 <θ< 3π
2 . (7)
θ→π
It should be noted that it is not necessary to begin with GCM. The same
method of derivation can be applied to other closed-form approximations (Brothers
& Knox, 1998; Knox & Brothers, 1999; Richardson & Gaunt, 1927).
To assess the relative rates of convergence for these expressions it is possible to
generate their respective power series (see Brothers & Knox; Knox & Brothers) by
replacing θ with π ± 1/x and then evaluating the expression as x → ∞. For (6) and
(7) the associated power series when approaching π from below are, respectively,
cot(π−(1/x)) 1 11 29
(1 + tan (π − (1/x))) = e 1+ + 2
+
2x 24x 48x3
(8)
4207 1 4
+ 4
+O , x>
5760x x5 π
The π to e converter
Because the above functions provide a direct link between the numerical values
of these two constants, using a computer algebra program or arbitrary precision
library one can write a procedure that takes a given number of the digits of π and,
from them, derives digits of e. Here is sample Mathematica ® code based on the
first-order approximation in (6):
$MaxExtraPrecision 10000; power 1;
power Cot power
func _ : 1 Tan
numDigits 12; extraPlaces 0; acc power numDigits extraPlaces;
piDigits Flatten Drop RealDigits , 10, numDigits , 1 ;
piNum FromDigits piDigits ;
eValue N func piNum 10numDigits 1 , acc ;
Print "Input digits ", numDigits, " digit accuracy ", piDigits
If extraPlaces 0, Print " ", numDigits extraPlaces, " digit accuracy
", N , numDigits extraPlaces
Print " ", acc, " digit accuracy ", actualE N E, acc
Print "Output ", acc, " digit accuracy ", eValue
Print "Error ", N FromDigits RealDigits actualE , acc
N FromDigits RealDigits eValue , acc
Using the variable numDigits, this program takes the first n digits of π as its
input, rounded to n digit accuracy (d.a.). It outputs the actual value of e (at n d.a.)
along with the computed value and the error, expressed as e minus the computed
value. For the first-order approximation (6), inputting the first twelve digits of π
yields the first 12 digits of e (at 12 d.a.).
Higher-order approximations can also be tested with the program. For exam-
ple, using trigonometric identities, the second-order approximation in (7) can be
rewritten as
cot2 (θ)
e = lim 1 + tan2 (θ) . (11)
θ→π
Setting the variable power = 2 and using the same 12 digit input yields 24 digits
of e. In general, the number of accurate digits obtained is proportional to order of
accuracy of the approximation’s associated power series; a kth order approximation
returns approximately k times the number of digits that are input.
The decimal place accuracy of the output (the number of accurate digits to the
right of the decimal point) can be directly approximated using the log of the error
term in the approximation’s associated power series (see equations (8) and (9)):
j a k
d.p.a. ≈ −Log10 (12)
bxn
where a, b, and n are constants and “b c” denotes the floor function. Let Pa equal
the actual value of π and let Pr equal the input value rounded to n d.a.. The value
of x is then calculated according to
x = 1/(Pa − Pr ). (13)
It is interesting to note that certain inputs are inherently more accurate at any
order. Because the function f is defined by the limit e = limθ→π f (θ), it converges as
|Pa − Pr | → 0. Rounding error therefore changes according to the value of the digits
immediately following the specific number of digits chosen for input. Remembering
that the first digit of π occurs to the left of the decimal point, if we denote the
maximum possible rounding error by ε, then at any given value of accuracy n,
ε = 5 × 10−n + C × 10−(n+1) , for C < 1 as C → 0. The maximum error in the
converted value therefore occurs when |Pa − Pr | = ε. Conversely, minimum error
occurs when |Pa − Pr | < 1 × 10−n .
For any arbitrary number of input digits, the potential range in accuracy is
equal to (|Pa − Pr |max − |Pa − Pr |min ). This is simply ε, which to one d.p.a. in the
nth decimal place is equal to 0.5. For the function in (8), the error term in its power
series is (1/2x). Evaluating this term with x = 1/(0.5) (see Eq. 13), we find that the
maximum potential error η in the estimation of the overall d.p.a. of the function is
equal to
η = − Log10 14 ≈ 0.6 (14)
Referring back to the above code, the maximum decimal place error (m.d.p.e.)
for this function (and its higher-order cousins) can therefore be closely estimated by
m.d.p.e. ≈ 35 · power where “d e” denotes the ceiling function. At maximum error,
Using a non-zero value for the variable extraPlaces allows one to compare the
values of Pa and Pr .
Conclusion
It should be noted that using π to generate the digits e is not very “practical.”
The simple fact that one needs to first calculate trigonometric values to be used
as part of the overall calculation severely limits efficiency in a computational sense.
Clearly, if armed only with pencil and paper, there are easier ways to calculate e
using infinite series (Brothers, 2004). Nonetheless, these unexpected expressions
appear interesting in their own right and provide fertile territory for exploration and
research by first- and second-year calculus students. Indeed, students can use the
methods presented here to produce their own original results, reinforcing the intimate
link between two numbers that have fascinated mathematicians for centuries.
References
Anton, H. (1980). Calculus. New York: John Wiley & Sons.
Bradley, G. L. & Smith, K. J.. (1999). Single variable calculus. (2nd ed.). Baskin-Ridge,
NJ: Prentice-Hall.
Brothers, H. J. (2004). Improving the convergence of Newton’s series approximation for e.
The College Mathematics Journal, 35 (1), 34–39.
Brothers, H. J. http://www.brotherstechnology.com/math/converter.html.
Brothers, H. J. & Knox, J. A. (1998). New closed-form approximations to the logarithmic
constant e. The Mathematical Intelligencer, 20 (4), 25–29.
Knox, J. A. & Brothers, H. J. (1999) Novel series-based approximations to e. The College
Mathematics Journal, 30 (4), 269-275.
Maor, E. (1994), e: The story of a number. Princeton, NJ: Princeton University Press.
Richardson, L. F. & Gaunt, J. A. (1927). The deferred approach to the limit. Philosophical
Transactions of the Royal Society of London, series A, 226.
Acknowledgments
This paper would not have been possible without the support and encouragement of
Professor John Knox, University of Georgia. His initial interest and subsequent devotion
to the development of series-based approximations for e provided the foundation for this
work. The author is grateful to Professor Miguel Garcia of Gateway Community College in
Connecticut for his unflagging interest and encouragement. Thanks also to Robert Speiser at
Brigham Young University for his editorial expertise. Mathematica is a registered trademark
of Wolfram Research, Inc.
(x − 1) (3x + 2) = 4x
x − 1 = 4x or 3x + 2 = 4x
−1 = 3x or 2=x
−1
= x or 2 = x
3
−1
n o
Solution set = ,2
3
Michael W. Lanstrum
Cuyahoga Community College
Parma, OH
Neglect of mathematics works injury to all knowledge, since one who is ignorant of it
cannot know the other sciences of the things of this world. And what is worst, those
who are thus ignorant are unable to perceive their own ignorance and so do not seek
a remedy.
Roger Bacon
I must study politics and war that my sons may have liberty to study mathematics and
philosophy. My sons ought to study mathematics and philosophy, geography, natural
history, naval architecture, navigation, commerce and agriculture in order to give their
children a right to study painting, poetry, music, architecture, statuary, tapestry, and
porcelain.
John Adams (1735–1826)
Letter to Abigail Adams, May 12, 1780