Computing e to Any Power (Part 2)

In this series, I’m looking at a wonderful anecdote from Nobel Prize-winning physicist Richard P. Feynman from his book Surely You’re Joking, Mr. Feynman!. This story concerns a time that he computed e^x mentally for a few values of x, much to the astonishment of his companions.

Part of this story directly ties to calculus.

One day at Princeton I was sitting in the lounge and overheard some mathematicians talking about the series for e^x, which is 1 + x + x^2/2! + x^3/3! Each term you get by multiplying the preceding term by x and dividing by the next number. For example, to get the next term after x^4/4! you multiply that term by x and divide by 5. It’s very simple.

When I was a kid I was excited by series, and had played with this thing. I had computed e using that series, and had seen how quickly the new terms became very small.

As noted, this refers to the Taylor series expansion of e^x, which is can be used to compute e to any power. The terms get very small very quickly because of the factorials in the denominator, thus lending itself to the computation of e^x. Indeed, this series is used by modern calculators (with a few tricks to accelerate convergence). In other words, the series from calculus explains how the mysterious “black box” of a graphing calculator actually works.

Continuing the story…

“Oh yeah?” they said. “Well, then what’s e to the 3.3?” said some joker—I think it was Tukey.

I say, “That’s easy. It’s 27.11.”

Tukey knows it isn’t so easy to compute all that in your head. “Hey! How’d you do that?”

Another guy says, “You know Feynman, he’s just faking it. It’s not really right.”

They go to get a table, and while they’re doing that, I put on a few more figures.: “27.1126,” I say.

They find it in the table. “It’s right! But how’d you do it!”

For now, I’m going to ignore how Feynman did this computation in his head and instead discuss “the table.” The setting for this story was approximately 1940, long before the advent of handheld calculators. I’ll often ask my students, “The Brooklyn Bridge got built. So how did people compute e^x before calculators were invented?” The answer is by Taylor series, which were used to produce tables of values of e^x. So, if someone wanted to find e^{3.3}, they just had a book on the shelf.

For example, the following page comes from the book Marks’ Mechanical Engineers’ Handbook, 6th edition, which was published in 1958 and which I happen to keep on my bookshelf at home.

ExponentTable

Look down the fifth and sixth columns of this table, we see that e^{3.3} \approx 27.11. Somebody had computed all of these things (and plenty more) using the Taylor series, and they were compiled into a book and sold to mathematicians, scientists, and engineers.

But what if we needed an approximation better more accurate than four significant digits? Back in those days, there were only two options: do the Taylor series yourself, or buy a bigger book with more accurate tables.

Lessons from teaching gifted elementary students (Part 6b)

Every so often, I’ll informally teach a class of gifted elementary-school students. I greatly enjoy interacting with them, and I especially enjoy the questions they pose. Often these children pose questions that no one else will think about, and answering these questions requires a surprising depth of mathematical knowledge.

Here’s a question I once received:

255/256 to what power is equal to 1/2? And please don’t use a calculator.

Here’s how I answered this question without using a calculator… in fact, I answered it without writing anything down at all. I thought of the question as

\displaystyle \left( 1 - \epsilon \right)^x = \displaystyle \frac{1}{2}.

\displaystyle x \ln (1 - \epsilon) = \ln \displaystyle \frac{1}{2}

\displaystyle x \ln (1 - \epsilon) = -\ln 2

I was fortunate that my class chose 1/2, as I had memorized (from reading and re-reading Surely You’re Joking, Mr. Feynman! when I was young) that \ln 2 \approx 0.693. Therefore, we have

x \ln (1 - \epsilon) \approx -0.693.

Next, I used the Taylor series expansion

\ln(1+t) = t - \displaystyle \frac{t^2}{2} + \frac{t^3}{3} \dots

to reduce this to

-x \epsilon \approx -0.693,

or

x \approx \displaystyle \frac{0.693}{\epsilon}.

For my students’ problem, I had \epsilon = \frac{1}{256}, and so

x \approx 256(0.693).

So all I had left was the small matter of multiplying these two numbers. I thought of this as

x \approx 256(0.7 - 0.007).

Multiplying 256 and 7 in my head took a minute or two:

256 \times 7 = 250 \times 7 + 6 \times 7

= 250 \times (8-1) + 42

= 250 \times 8 - 250 + 42

= 2000 - 250 + 42

= 1750 + 42

= 1792.

Therefore, 256 \times 0.7 = 179.2 and 256 \times 0.007 = 1.792 \approx 1.8. Therefore, I had the answer of

x \approx 179.2 - 1.8 = 177.4 \approx 177.

So, after a couple minutes’ thought, I gave the answer of 177. I knew this would be close, but I had no idea it would be so close to the right answer, as

x = \displaystyle \frac{\displaystyle \ln \frac{1}{2} }{\displaystyle \ln \frac{255}{256}} \approx 177.0988786\dots

Thoughts on Infinity (Part 3g)

We have seen in recent posts that

$latex  \displaystyle 1 – \frac{1}{2} + \frac{1}{3} – \frac{1}{4} + \frac{1}{5} – … = \ln 2$

One way of remembering this fact is by using the Taylor series expansion for \ln(1+x):

\ln(1+x) = x - \displaystyle \frac{x^2}{2} + \frac{x^3}{3} - \frac{x^4}{4} + \frac{x^5}{5} \dots

“Therefore,” the first series can be obtained from the second series by substituting x=1.

I placed “therefore” in quotation marks because this reasoning is completely invalid, even though it happens to stumble across the correct answer in this instance. The radius of convergence for the above Taylor series is 1, which can be verified by using the Ratio Test. So the series converges absolutely for |x| < 1 and diverges for |x| > 1. The boundary of |x| = 1, on the other hand, has to be checked separately for convergence.

In other words, plugging in x=1 might be a useful way to remember the formula, but it’s not a proof of the formula and certainly not a technique that I want to encourage students to use!

It’s easy to find examples where just plugging in the boundary point happens to give the correct answer (see above). It’s also easy to find examples where plugging in the boundary point gives an incorrect answer because the series actually diverges: for example, substituting x = -1 into the geometric series

\displaystyle \frac{1}{1-x} = 1 + x + x^2 + x^3 + x^4 + \dots

However, I’ve been scratching my head to think of an example where plugging in the boundary point gives an incorrect answer because the series converges but converges to a different number. I could’ve sworn that I saw an example like this when I was a calculus student, but I can’t see to find an example in reading Apostol’s calculus text.

 

How I Impressed My Wife: Part 4h

So far in this series, I have used three different techniques to show that

Q = \displaystyle \int_0^{2\pi} \frac{dx}{\cos^2 x + 2 a \sin x \cos x + (a^2 + b^2) \sin^2 x} = \displaystyle \frac{2\pi}{|b|}.

For the third technique, a key step in the calculation was showing that the residue of the function

f(z) = \displaystyle \frac{1}{z^2 + 2\frac{S}{R}z + 1} = \displaystyle \frac{1}{(z-r_1)(z-r_2)}

at the point

r_1 = \displaystyle \frac{-S + \sqrt{S^2 -R^2}}{R}

was equal to

\displaystyle \frac{R}{ 2 \sqrt{S^2-R^2} }.

Initially, I did this by explicitly computing the Laurent series expansion about z = r_1 and identifying the coefficient for the term (z-r_1)^{-1}.

In this post, I’d like to discuss another way that this residue could have been obtained.
green line

Notice that the function f(z) has the form \displaystyle \frac{g(z)}{(z-r) h(z)}, where g and h are differentiable functions so that g(r) \ne 0 and h(r) \ne 0. Therefore, we may rewrite this function using the Taylor series expansion of \displaystyle \frac{g(z)}{h(z)} about z = r:

f(z) = \displaystyle \frac{1}{z-r} \left[ \frac{g(z)}{h(z)} \right]

f(z) = \displaystyle \frac{1}{z-r} \left[ a_0 + a_1 (z-r) + a_2 (z-r)^2 + a_3 (z-r)^3 + \dots \right]

f(z) = \displaystyle \frac{a_0}{z-r} + a_1 + a_2 (z-r) + a_3 (z-r)^2 + \dots

Clearly,

\displaystyle \lim_{z \to r} (z-r) f(z) = \displaystyle \lim_{z \to r} \left[ a_0 + a_1 (z-r) + a_2 (z-r)^2 + a_3 (z-r)^3 + \dots \right] = a_0

Therefore, the residue at z = r can be found by evaluating the limit \displaystyle \lim_{z \to r} (z-r) f(z). Notice that

\displaystyle \lim_{z \to r} (z-r) f(z) = \displaystyle \lim_{z \to r} \frac{(z-r) g(z)}{(z-r) h(z)}

= \displaystyle \lim_{z \to r} \frac{(z-r) g(z)}{H(z)},

where H(z) = (z-r) h(z) is the original denominator of f(z). By L’Hopital’s rule,

a_0 = \displaystyle \lim_{z \to r} \frac{(z-r) g(z)}{H(z)} = \displaystyle \lim_{z \to r} \frac{g(z) + (z-r) g'(z)}{H'(z)} = \displaystyle \frac{g(r)}{H'(r)}.

For the function at hand, g(z) \equiv 1 and H(z) = z^2 + 2\frac{S}{R}z + 1, so that H'(z) = 2z + 2\frac{S}{R}. Therefore, the residue at z = r_1 is equal to

\displaystyle \frac{1}{2r_1+2 \frac{S}{R}} = \displaystyle \frac{1}{2 \displaystyle \frac{-S + \sqrt{S^2 -R^2}}{R} + 2 \frac{S}{R}}

= \displaystyle \frac{1}{ ~ 2 \displaystyle \frac{\sqrt{S^2 -R^2}}{R} ~ }

= \displaystyle \frac{R}{2 \sqrt{S^2-R^2}},

matching the result found earlier.

 

How I Impressed My Wife: Part 4g

So far in this series, I have used three different techniques to show that

Q = \displaystyle \int_0^{2\pi} \frac{dx}{\cos^2 x + 2 a \sin x \cos x + (a^2 + b^2) \sin^2 x} = \displaystyle \frac{2\pi}{|b|}.

For the third technique, a key step in the calculation was showing that the residue of the function

f(z) = \displaystyle \frac{1}{z^2 + 2\frac{S}{R}z + 1} = \displaystyle \frac{1}{(z-r_1)(z-r_2)}

at the point

r_1 = \displaystyle \frac{-S + \sqrt{S^2 -R^2}}{R}

was equal to

\displaystyle \frac{R}{ 2 \sqrt{S^2-R^2} }.

Initially, I did this by explicitly computing the Laurent series expansion about z = r_1 and identifying the coefficient for the term (z-r_1)^{-1}.

In this post and the next post, I’d like to discuss alternate ways that this residue could have been obtained.
green line

Notice that the function f(z) has the form \displaystyle \frac{g(z)}{(z-r) h(z)}, where g and h are differentiable functions so that g(r) \ne 0 and h(r) \ne 0. Therefore, we may rewrite this function using the Taylor series expansion of \displaystyle \frac{g(z)}{h(z)} about z = r:

f(z) = \displaystyle \frac{1}{z-r} \left[ \frac{g(z)}{h(z)} \right]

f(z) = \displaystyle \frac{1}{z-r} \left[ a_0 + a_1 (z-r) + a_2 (z-r)^2 + a_3 (z-r)^3 + \dots \right]

f(z) = \displaystyle \frac{a_0}{z-r} + a_1 + a_2 (z-r) + a_3 (z-r)^2 + \dots

Therefore, the residue at z = r is equal to a_0, or the constant term in the Taylor expansion of \displaystyle \frac{g(z)}{h(z)} about z = r. Therefore,

a_0 = \displaystyle \frac{g(r)}{h(r)}

For the function at hand g(z) \equiv 1 and h(z) = z-r_2. Therefore, the residue at z = r_1 is equal to \displaystyle \frac{1}{r_1 - r_2}, matching the result found earlier.

 

Why Does 0.999… = 1? (Index)

I’m using the Twelve Days of Christmas (and perhaps a few extra days besides) to do something that I should have done a long time ago: collect past series of posts into a single, easy-to-reference post. The following posts formed my series on different techniques that I’ll use to try to convince students that 0.999\dots = 1.

Part 1: Converting the decimal expansion to a fraction, with algebra.

Part 2: Rewriting both sides of the equation 1 = 3 \times \displaystyle \frac{1}{3}.

Part 3: Converting the decimal expansion to a fraction, using infinite series.

Part 4: A proof by contradiction: what number can possibly be between 0.999\dots and 1?

Part 5: Same as Part 4, except by direct reasoning.

 

 

 

Reminding students about Taylor series: Index

I’m doing something that I should have done a long time ago: collect past series of posts into a single, easy-to-reference post. The following posts formed my series on how I remind students about Taylor series. I often use this series in a class like Differential Equations, when Taylor series are needed but my class has simply forgotten about what a Taylor series is and why it’s important.

Part 1: Introduction – Why a Taylor series is important, and different applications of Taylor series.

Part 2: How I get students to understand the finite Taylor polynomial by solving a simple initial-value problem.

Part 3: Making the jump to an infinite series, and issues about tests of convergence.

Part 4: Application to f(x) = e^x, and a numerical investigation of speed of convergence.

Part 5: Application to f(x) = \displaystyle \frac{1}{1-x} and other related functions, including f(x) = \ln(1+x) and f(x) = \tan^{-1} x.

Part 6: Application to f(x) = \sin x and f(x) = \cos x, and Euler’s formula.

 

 

 

Different definitions of e (Part 12): Numerical computation

In this series of posts, we have seen that the number e can be thought about in three different ways.

1. e defines a region of area 1 under the hyperbola y = 1/x.logarea2. We have the limits

e = \displaystyle \lim_{h \to 0} (1+h)^{1/h} = \displaystyle \lim_{n \to \infty} \left(1 + \frac{1}{n} \right)^n.

These limits form the logical basis for the continuous compound interest formula.

3. We have also shown that \frac{d}{dx} \left(e^x \right) = e^x. From this derivative, the Taylor series expansion for e^x about x = 0 can be computed:

e^x = \displaystyle \sum_{n=0}^\infty \frac{x^n}{n!}

Therefore, we can let x = 1 to find e:

e = \displaystyle \sum_{n=0}^\infty \frac{1}{n!} = \displaystyle 1 + 1 + \frac{1}{2} + \frac{1}{6} + \frac{1}{24} + \dots

green line

In yesterday’s post, I showed that using the original definition (in terms of an area under a hyperbola) does not lend itself well to numerically approximating e. Let’s now look at the other two methods.

2. The limit e = \displaystyle \lim_{n \to \infty} \left(1 + \frac{1}{n} \right)^n gives a somewhat more tractable way of approximating e, at least with a modern calculator. However, you can probably imagine the fun of trying to use this formula without a calculator.

ecalculator3. The best way to compute e (or, in general, e^x) is with Taylor series. The fractions \frac{1}{n!} get very small very quickly, leading to rapid convergence. Indeed, with only terms up to 1/6!, this approximation beats the above approximation with n = 1000. Adding just two extra terms comes close to matching the accuracy of the above limit when n = 1,000,000.

ecalculator2

More about approximating e^x via Taylor series can be found in my previous post.

 

Calculators and complex numbers (Part 15)

In this series of posts, I explore properties of complex numbers that explain some surprising answers to exponential and logarithmic problems using a calculator (see video at the bottom of this post). These posts form the basis for a sequence of lectures given to my future secondary teachers.

To begin, we recall that the trigonometric form of a complex number z = a+bi is

z = r(\cos \theta + i \sin \theta)

where r = |z| = \sqrt{a^2 + b^2} and \tan \theta = b/a, with \theta in the appropriate quadrant. As noted before, this is analogous to converting from rectangular coordinates to polar coordinates.

There’s a shorthand notation for the right-hand side (r e^{i \theta}) that, at long last, I will explain in today’s post.

Definition. If z is a complex number, then we define

e^z = \displaystyle \sum_{n=0}^{\infty} \frac{z^n}{n!}

This of course matches the Taylor expansion of e^x for real numbers x.

Theorem. If \theta is a real number, then e^{i \theta} = \cos \theta + i \sin \theta.

e^{i \theta} = \displaystyle \sum_{n=0}^{\infty} \frac{(i \theta)^n}{n!}

= \displaystyle 1 + i\theta + \frac{(i\theta)^2}{2!} + \frac{(i\theta)^3}{3!} + \frac{(i\theta)^4}{4!} + \frac{(i\theta)^5}{5!} + \frac{(i\theta)^6}{6!} + \frac{(i\theta)^7}{7!} + \dots

= \displaystyle \left(1 - \frac{\theta^2}{2!} + \frac{\theta^4}{4!} - \frac{\theta^6}{6!} \dots \right) + i \left( \theta - \frac{\theta^3}{3!} + \frac{\theta^5}{5!} - \frac{\theta^7}{7!} \right)

= \cos \theta + i \sin \theta,

using the Taylor expansions for cosine and sine.

This theorem explains one of the calculator’s results:

e^{i \pi} = \cos \pi + i \sin \pi = -1 + 0i = -1.

That said, you can imagine that finding something like e^{4-2i} would be next to impossible by directly plugging into the series and trying to simply the answer. The good news is that there’s an easy way to compute e^z for complex numbers z, which we develop in the next few posts.

green line

For completeness, here’s the movie that I use to engage my students when I begin this sequence of lectures.

 

 

Calculators and complex numbers (Part 14)

In this series of posts, I explore properties of complex numbers that explain some surprising answers to exponential and logarithmic problems using a calculator (see video at the bottom of this post). These posts form the basis for a sequence of lectures given to my future secondary teachers.

Definition. If z is a complex number, then we define

e^z = \displaystyle \sum_{n=0}^{\infty} \frac{z^n}{n!}

Even though this isn’t the usual way of defining the exponential function for real numbers, the good news is that one Law of Exponents remains true. (At we saw in an earlier post in this series, we can’t always assume that the usual Laws of Exponents will remain true when we permit the use of complex numbers.)

Theorem. If z and w are complex numbers, then e^z e^w = e^{z+w}.

I will formally prove this in the next post. Today, I want to talk about the idea behind the proof. Notice that

e^z e^w = \displaystyle \left( 1 + z + \frac{z^2}{2!} +\frac{z^3}{3!} + \frac{z^4}{4!} + \dots \right) \left( 1 + w + \frac{w^2}{2!} + \frac{w^3}{3!} + \frac{w^4}{4!} + \dots \right)

Let’s multiply this out (ugh!), but we’ll only worry about terms where the sum of the exponents of z and w is 4 or less. Here we go…

e^z e^w = \displaystyle 1 + z + \frac{z^2}{2!} + \frac{z^3}{3!} + \frac{z^4}{4!} + \dots

+ \displaystyle w + wz + \frac{wz^2}{2!} + \frac{wz^3}{3!} + \dots

+ \displaystyle \frac{w^2}{2!} + \frac{w^2 z}{2!} + \frac{w^2 z^2}{2! \times 2!} + \dots

+ \displaystyle \frac{w^3}{3!} + \frac{w^3 z}{3!} + \dots

+ \displaystyle \frac{w^4}{4!} + \dots

Next, we rearrange the terms according to the sum of the exponents. For example, the terms with z^3, w z^2, w^2 z, and w^3 are placed together because the sum of the exponents for each of these terms is 3.

e^z e^w = 1

+ z + w

\displaystyle + \frac{z^2}{2} + wz + \frac{w^2}{2}

\displaystyle + \frac{z^3}{6} + \frac{wz^2}{2} + \frac{w^2 z}{2} + \frac{w^3}{6}

\displaystyle + \frac{z^4}{24} + \frac{w z^3}{6} + \frac{w^2 z^2}{4} + \frac{w^3 z}{6} + \frac{w^4}{24} + \dots

For each line, we obtain a common denominator:

e^z e^w = 1

+ z + w

\displaystyle + \frac{z^2 + 2 z w + w^2}{2}

\displaystyle + \frac{z^3 + 3 z^2 w + 3 z w^2 + w^3}{6}

\displaystyle + \frac{z^4+ 4 z^3 w + 6 z^2 w^2 + 4 z w^3 + w^4}{24} + \dots

We recognize the familiar entries of Pascal’s triangle in the coefficients of the numerators, and so it appears that

e^z e^w = 1 + (z+w) + \displaystyle \frac{(z+w)^2}{2!} + \frac{(z+w)^3}{3!} + \frac{(z+w)^4}{4!} + \dots

If the pattern on the right-hand side holds up for exponents greater than 4, this proves that e^z e^w = e^{z+w}.

So that’s the idea of the proof. The formal proof will be presented in the next post.

green line

For completeness, here’s the movie that I use to engage my students when I begin this sequence of lectures.