Content uploaded by Harlan J. Brothers

Author content

All content in this area was uploaded by Harlan J. Brothers

Content may be subject to copyright.

The AMAT

YC Review

published by the

American Mathematical Association of Two-Year Colleges

published by the

American Mathematical Association of Two-Year Colleges

volume 30

•

number 1

•

fall 2008

How to Design Your Own πto eConverter

Harlan J. Brothers

Harlan Brothers is Director of Technology at The Country School in

Madison, CT where he teaches programming, fractal geometry, and gui-

tar. Having worked for six years with Michael Frame and Benoit Man-

delbrot at the Yale Fractal Geometry Workshops, he now lectures on the

subject of fractal music. Harlan is also an inventor with ﬁve US patents.

E-mail: harlan@thecountryschool.org

The base of the natural logarithm, e, has been studied since the early seven-

teenth century (Maor, 1994, pp. 26–27). Its limit deﬁnition formula

e= lim

n→∞ 1 + 1

nn(1)

is a variant of the compound-interest formula used in ﬁnance (Anton, 1980, p. 558;

2; Bradley & Smith, 1999, pp. 63–64). This article demonstrates how a simple

restatement of (1) can lead to the derivation of a fascinating family of functions that

can be used to convert the digits of πto those of e.

Generalizing the Limit Deﬁnition of e

Starting with the right hand side (RHS) of (1), we can treat it as a real function

of two variables, rand s. Replacing the integer nwith a rational number in the form

r/s we have

e= lim

|r

s|→∞ r+s

rr

s|r|>|s|, r, s 6= 0 (2)

Thus, the greater the ratio between rand s, the better (2) approximates e.

The value of (2) is that it can be redeﬁned more broadly as a compound function

of one variable by replacing rwith subfunction f(x)and swith subfunction g(x).

The result is a formula we refer to as the Generalized Classical Method (GCM).

Given: f(x)and g(x)are monotone over x,|f(x)|>|g(x)|, and f(x),g(x)are

divergent, then

GCM(x) = f(x) + g(x)

f(x)f(x)

g(x)f(x), g(x)6= 0 (3)

30 How to Design Your Own πto eConverter

and

e= lim

|x|→∞ f(x) + g(x)

f(x)f(x)

g(x)(4)

New connections between πand e

When we assign f(x)and g(x)using the appropriate trigonometric subfunc-

tions, the functions that result, in their limits, deﬁne new relationships between π

and e.

For example, we can set f(x) = cos(θ)and g(x) = sin(θ). As θapproaches π,

cos(θ)→ −1,sin(θ)→0. Although the function is not deﬁned at θ=π, we ﬁnd

that

e= lim

θ→πcos(θ) + sin(θ)

cos(θ)cos(θ)

sin(θ)for 3π

4< θ < 3π

2(5)

or equivalently,

e= lim

θ→π(1 + tan(θ))cot(θ)for 3π

4< θ < 3π

2.(6)

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

e= lim

θ→πsec2(θ)cot2(θ)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,

(1 + tan (π−(1/x)))cot(π−(1/x)) =e1 + 1

2x+11

24x2+29

48x3

+4207

5760x4+O1

x5, x > 4

π

(8)

The AMATYC Review Volume 30, Number 1

Harlan J. Brothers 31

a ﬁrst-order approximation, and in alternative form,

sec2(π−(1/x))(sec2(π−(1/x))−1)−1

=e1−1

2x2+1

8x4−11

728x6

+19

13440x8−O1

x10 , x > 2

π

(9)

which, as conﬁrmed by the RHS, is a second-order approximation.

Dozens of trigonometric approximations to ecan be derived in the manner

described. Many of these functions map to Cover at least some portion of the

interval [0,2π]. For example, the following form has the interesting property that in

addition to converging to eas θ→π, it also converges to √2at 5π/4and to 1 at

3π/2(see Figure 1 below and Figure 2 on page 32):

e= lim

θ→π(−sin(θ)−cos(θ))cot(θ)for 3π

4< θ < 7π

4(10)

Figure 1: Graph of the Real output of the function f(θ) =

(−sin (θ)−cos (θ))cot(θ)for 3π/4< θ < 11π/4with removable sin-

gularities at πand 2π. This function maps to Rfor 3π/4< θ < 7π/4

and to Cfor 7π/4< θ < 11π/4. It is undeﬁned at θ= 3π/4and

θ= 7π/4and Real at (9π/4,−√2) and (5π/2,1).

Similar approximations can also be derived so as to converge for π/2. Higher-

order approximations can also be achieved in the same fashion. A more extensive

list of trigonometric expressions for ecan be found at (Brothers).

Fall 2008 The AMATYC Review

32 How to Design Your Own πto eConverter

Figure 2: 3D scatter plot of the function in Figure 1 revealing the

Imaginary component for 7π/4< θ < 11π/4. The modulus of the

complex region approaches eas θ→2π.

The πto econverter

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

ﬁrst-order approximation in (6):

$MaxExtraPrecision 10000; power 1;

func _ : 1 Tan power Cot power

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

The AMATYC Review Volume 30, Number 1

Harlan J. Brothers 33

Using the variable numDigits, this program takes the ﬁrst ndigits of πas its

input, rounded to ndigit accuracy (d.a.). It outputs the actual value of e(at nd.a.)

along with the computed value and the error, expressed as eminus the computed

value. For the ﬁrst-order approximation (6), inputting the ﬁrst twelve digits of π

yields the ﬁrst 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

e= lim

θ→π1 + tan2(θ)cot2(θ).(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 ktimes 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)):

d.p.a. ≈j−Log10

a

bxnk (12)

where a,b, and nare constants and “b c” denotes the ﬂoor function. Let Paequal

the actual value of πand let Prequal the input value rounded to nd.a.. The value

of xis 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 fis deﬁned 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 speciﬁc number of digits chosen for input. Remembering

that the ﬁrst 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 < 1as 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 ﬁnd that the

Fall 2008 The AMATYC Review

34 How to Design Your Own πto eConverter

maximum potential error ηin the estimation of the overall d.p.a. of the function is

equal to

η=−Log10 1

4≈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. ≈3

5·powerwhere “ d e” denotes the ceiling function. At maximum error,

the minimum accuracy is then given by d.p.a ≈numDigits*power −3

5·power.

Using a non-zero value for the variable extraPlaces allows one to compare the

values of Paand Pr.

Conclusion

It should be noted that using πto generate the digits eis not very “practical.”

The simple fact that one needs to ﬁrst calculate trigonometric values to be used

as part of the overall calculation severely limits eﬃciency in a computational sense.

Clearly, if armed only with pencil and paper, there are easier ways to calculate e

using inﬁnite series (Brothers, 2004). Nonetheless, these unexpected expressions

appear interesting in their own right and provide fertile territory for exploration and

research by ﬁrst- 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.

The AMATYC Review Volume 30, Number 1

Harlan J. Brothers 35

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 eprovided the foundation for this

work. The author is grateful to Professor Miguel Garcia of Gateway Community College in

Connecticut for his unﬂagging 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.

Lucky Larry #91

Solve the equation (x−1) (3x+ 2) = 4x.

Larry’s solution:

(x−1) (3x+ 2) = 4x

x−1 = 4xor 3x+ 2 = 4x

−1 = 3xor 2 = x

−1

3=xor 2 = x

Solution set =n−1

3,2oMichael 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

Fall 2008 The AMATYC Review