Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew...

12
Calculus Lectures:Intro to 3D by Kathy Davis Copyright © 2020 Kathy Davis This book was typeset using the T ufte-L A T E X package. These Lectures are copyrighted. You may use and distribute them freely, but they cannot be sold, incorpo- rated in other texts, or modified without written permission of the author. Unless required by applicable law or agreed to in writing, this book is distributed on an “as is basis , without warranties or conditions of any kind, either express or implied. Written October 2020

Transcript of Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew...

Page 1: Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew a blue line of height 3, and you can see it’s accurate by comparing it with the

Calculus Lectures: Intro to 3D

by Kathy Davis

Copyright © 2020 Kathy Davis

This book was typeset using the Tufte-LATEX package.

These Lectures are copyrighted. You may use and distribute them freely, but they cannot be sold, incorpo-rated in other texts, or modified without written permission of the author.

Unless required by applicable law or agreed to in writing, this book is distributed on an “as is” basis,without warranties or conditions of any kind, either express or implied.

Written October 2020

Page 2: Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew a blue line of height 3, and you can see it’s accurate by comparing it with the

2 Kathy Davis

Figure 1: Co-ordinates In 2DThe right-handed system in 2D.

Figure 2: UT Tower

The tree isn’t taller than the tower;choosing where I look distorts lengths.

Figure 3: Standard 3D Perspetive

The x-axis moved left, the z-axis is ’up’.

What

This is going to be a long one. A lot of it is background; skim ifyou’ve seen it. The computations begin on p8.

I’ll be doing calculus in three dimensions; in general this leads tomany kinds of issues: should I look at Cartesian (y = x2), parametric(x = t, y = t2) or implicit (x2 − y = 0) kinds of functions? Or allthree?

The M408D syllabus says: do Cartesian; the other systems are donein M427L. So, I’ll start with Figure 1, the right-handed Cartesian co-ordinate system in 2D. To get a third dimension, perpendicular to thefirst two, I need an axis sticking into or out of the computer screen. IfI want to continue with a right-handed system, I take the third axissticking ’out of’ : that’s the positive z axis. Now a 3D question: howshould I view the axes? Figure 2 shows why it’s an issue.

I’ll almost always choose to stand in the first octant, that is, wherex ≥ 0, y ≥ 0, z ≥ 0; this I call the standard perspective. Then theaxes appear as in Figure 3. Any choice of a place to stand bringsdistortions; here, I’m standing above the xy-plane (that is, the planewhere z = 0), looking down at it. When I look down at anything,it appears shorter. I’ll illustrate this by plotting the particular point(x, y, z) = (1, 3, 3), next page.

Page 3: Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew a blue line of height 3, and you can see it’s accurate by comparing it with the

calculus lectures 3

Start by drawing the axes; next, draw a grid in the xy-plane, so I canlocate points on the grid. I’ve drawn a red dot at (1, 3). Now it’s timeto bring it up to 3D.

In the left side of the figure below, I drew a blue line of height 3, andI can see it’s accurate by comparing it with the height markings onthe z-axis.

In the right-hand side of the picture, I drew the same scene usingthe standard perspective. Now the height of the blue line looks onlyabout two units high: perspective has shortened it.

Page 4: Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew a blue line of height 3, and you can see it’s accurate by comparing it with the

4 Kathy Davis

Figure 4: Eiger Mountain

What to do on a summer vacation:climb a mountain. The red lines on themountain show two possible routes totake.

Figure 5: Paraboloid

z = x2 + y2. I call it a cup.

Figure 6: Another Paraboloid

z = 1− (x2 + y2). I call it a flipped cup.

Figure 7: Hemisphere

z =√

1− (x2 + y2). Top half of asphere.

Figure 8: Hyperbolic Paraboloid

z = y2 − x2. I call it a saddle.

Now that I have 3D co-ordinates and plotting all sorted out, it’s timeto bring in functions. I want to introduce a physical model for theideas I’ll be developing, Figure 4. When people climb the Eiger,they’re climbing on the outside of the mountain, not the inside. Theoutside of the mountain is an example of a surface, just like the sur-face of the earth. I’ll think of sea level as the xy-plane, the heightsabove sea level are z. If I walk along the earth, I can control what di-rection I walk: x, y are independent variables. But I can’t decide myheight; I have to be where the earth is: z is a dependent variable. Ona mountain, the heights above sea level are given by z = f (x, y); thisis the model for a surface.

Later, I’ll be finding the volume inside the mountain; the area of themountain surface; the paths climbers take (parametric equations),and the slopes of the routes they take.

As I work through this theory, there are some standard examples I’lluse; the drawings of the surfaces are to the right. Most are coloredwith false color: the colors represent the height above the xy-plane.The equations are:

z = x2 + y2: Figure 5. Technically called a paraboloid; I’ll call it a cup.

z = 1− (x2 + y2): Figure 6. Still a paraboloid; I’ll call it a flipped cup.

z =√

1− (x2 + y2): Figure 7. A hemisphere (top half of a sphere); I’llcall it a hemisphere.

z = y2 − x2: Figure 8. A hyperbolic paraboloid; I’ll call it a saddle.

The sketch below explains the name. One of my students took thepicture. He knew my spouse is a licensed psychologist; he said Ishould show it to her and ask what she thought. Dr. Mrs. Spousesaid it was very good for a three year old.

Page 5: Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew a blue line of height 3, and you can see it’s accurate by comparing it with the

calculus lectures 5

Figure 9: Saddle Traces

z = f (x, 1) and z = f (0, y), blue on red.

Figure 10: Level Curves

The two level curve z = 0, or y = ±x fitright onto the surface.

Figure 11: Hyperbolic Levels

The level curves y2 − x2 = .25 arehyperbola. This time in red, making iteasier to see.

I’m going to talk about where these names come from. That’s ac-tually not important, but the ideas behind them are important, andI’ll be using the terminology from now on. The important words aretraces, level curves.

Traces are used to draw graphs like the ones on these pages; a traceis a curve on the surface of a special kind: either x or y is held con-stant. A level curve is a curve on the surface for which the height zis constant (If I’m walking around and I keep going up or down, zis changing, so I’m not on a "level" surface). Taking a trace or a levelcurve eliminates one of the three variables, so I get a 2D curve, and Iknow a lot about 2D, so this is a good move.

Look at the above: on the left, the cup f (x, y) = x2 + y2. On the right,the flipped cup, f (x, y) = 1 − (x2 + y2). I’ll take the trace y = 0,so I have f (x, 0) = x2 + 02 = x2 on the left, and then on the rightf (x, 0) = 1− (x2 + 02) = 1− x2. Both of these are parabolas; seeabove. Even the trace x = .5 gives f (.5, y) = (.5)2 + y2 = .25 + y2,another parabola. All traces of these two surfaces are parabolas.

Take the trace on a hemisphere y = 0, then z =√

1− (x2 + 02) =√1− x2 – a half circle. All the traces are half circles.

The saddle is more fun. Figure 9 shows the traces z = f (0, y), aparabola, and, for variety, z = f (x, 1), an upside down parabola. Itlooks like all the traces are parabolas (they are) so why is this surfacecalled a hyperbolic paraboloid? Because of the level curves. Which Imentioned but didn’t do yet.

Take the level curve z = 0 or, y2 − x2 = 0 so y2 = x2 and y = ±x. It’shard to imagine how two lines are going to fit on a saddle, but Figure10 shows it: there they are!

To get hyperbolas, take the level curve z = 1 or, y2 − x2 = 1: that’sa hyperbola – and Figure 11 shows how it sits on the surface. To getthe drawing, I parameterized a hyperbola using cosh and sinh.

Page 6: Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew a blue line of height 3, and you can see it’s accurate by comparing it with the

6 Kathy Davis

Figure 12: False Colors

A saddle drawn with false colors.

Figure 13: Crevasse

If you’re climbing a mountain, youdon’t want to run into one of these.

Figure 14: The Signum Function

Graph of signum(x) = x|x| . If you put

in a negative number, it gives −1; apositive number gives +1. Hence theterm ’signum’ – it gives the sign of x.

Figure 15: Which Way?There’s a lot of different ways to get toa point. Which do I choose?

Figure 12 is the usual saddle, except plotted in false color. RememberI said false color gives a different color to each height (plus or minusa few dozen pixels)? If I follow just one color on the plot, I’m fol-lowing a level curve. And I can see exactly that in Figure 12: there’sthe hyperbolas stacked up against each other, and even the lines. It’sblurred because of the pixels, but there they are.

A plot with level curves is a contour map. Geologists use it for forma-tions on the earth, and I’ll do an engineering application later.

Limits And Derivatives

Figure 13 shows an example of a discontinuity – in this case a suddenjump in the surface. Continuity is about finding those in the equa-tions for a surface. In 2D, a function is continuous at c if the followingthree conditions hold:i) f (c) exists.ii) limx→c f (x) exists.iii) limx→c f (x) = f (c).

Figure 14 shows an example of function not continuous at c = 0; thelimit doesn’t exist because

limx→0+

x|x| = 1 but lim

x→0−

x|x| = −1

For continuity, limits to c have to exist from both directions towardsc, and the limits have to be equal. The example shows a simple wayto find discontinuities for very basic functions: if there’s a zero in adenominator, there’s a discontinuity.

The basic functions are built up from polynomials, roots, com-positions, sums quotients and products of other basic functions:y = x, y = ex, y = ln x, y = sin x, y = cos x. For basic functions,there’s a discontinuity whenever there’s a zero in a denominator orthe value inside a log is zero.

So what should I do in 3D? If z = f (x, y), what does it mean for fto be continuous at (c, d)? I could just copy the definition for 2D, butthere’s a problem with (x, y)→ (c, d): in 2D I could approach c fromthe left or right; in 3D – well, look at Figure 15: there’s lots of waysto get to (c, d). At the very least, I’d have to check every continuouspath towards (c, d). Path? Parametric curve – If x = x(t), y = y(t)and limt→a (x(t), y(t)) = (c, d), I’d need

limt→a

f (x(t), y(t)) = f (c, d)

Best to see an example, next page.

Page 7: Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew a blue line of height 3, and you can see it’s accurate by comparing it with the

calculus lectures 7

Figure 16: this Way

this time, I take a curved path to (0, 0).

Figure 17: Event Horizon

A model of a discontinuity all alongx2 + y2 = 1. Again, the graph is weirdbecause the computer drawing programcan’t handle discontinuities.

Figure 18: Any Which Way

You can place a discontinuity along anycurve!

f (x, y) =x2y

x2 + y4 when (x, y) 6= (0, 0), but = 0 when (x, y) = (0, 0).

Now, what path should I choose? How about any straight line goingthe origin? So, x = at, y = bt gives straight lines of different slopes.If one of a = 0, b = 0, then the numerator of f , x2y, is zero, sof (at, bt) = 0 = f (0, 0) and I have continuity along that path. Ingeneral, when a 6= 0,

limt→0

f (at, bt) = limt→0

a2bt3

a2t2 + b4t4 = limt→0

a2bta2 + b4t2 =

0a2 = 0

since a2 6= 0. So I have continuity along every straight line throughthe origin. Figure 16 shows this isn’t enough: I can see a curve, inblue, that sits right ontop of the surface but stays away from zeroheight (the graph is a bit weird near (0, 0), because the computergraphing program can’t deal with the discontinuity there).

Now try this curvy path: x = t, y = t2. I get:

limt→0

f (t, t2) = limt→0

t2 · t2

t4 + (t2)2 = limt→0

t4

2t4 =12

Since f (0, 0) 6= 12 , f is not continuous at (0, 0)!

Worked this time, but how can I possibly check limits along everycurve? The 2D idea works here: for basic functions, I’ll have a discon-tinuity whenever there’s a zero in a denominator or inside a log.

I’m used to having a discontinuity at a point in 2D, but Figure 17

shows the graph of f (x, y) = ln |x2 + y2 − 1|. There’s a discontinuityall along x2 + y2 = 1. For that matter, if y = f (x) in 2D,

z =1

y− f (x)

has a discontinuity along the graph of y = f (x). So discontinuitiescan be curves too, not just points; see Figure 18.

Again, this was a section with no problems or activities or quiz stufffor you. The next section, though: Wham!

Page 8: Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew a blue line of height 3, and you can see it’s accurate by comparing it with the

8 Kathy Davis

Figure 19: Snowmobile Competition

the idea is to get to the top of a verysteep mountain. For this guy, too steep.At 75o , his snowmobile flips. Rider OK,snowmobile bites the dust.

Figure 20: Trace On A Surface

The trace z = f (x, 0), in blue, on thesurface z = 1− (x2 + y2).

Figure 21: Trace All Alone

The trace without the surface. It’s just a2D curve, drawn in 3D.

Figure 22: the ∆x Trick

The first-semester calculus way to find aderivative.

Partial Derivatives

The goal here is to find slopes; slopes on mountains. Figure 19 showswhy extreme sports people care. But avalanches depend on slopestoo: if the slope is very small or large, snow will stay put or slidedown on its own. Only in a middle range of slopes is there a dangerof avalanches.

It will take several days to get to general slopes; here I’ll look attwo special slopes, those for traces: z = f (c, y) and z = f (x, d),where c, d are constants; Figure 20 is an example. In that Figure, f isf (x, y) = 1− (x2 + y2) and the trace is f (x, 0) = 1− x2. Figure 21

shows the trace without the surface in the way. It’s really just a 2Dcurve, and I can try and find the slope using 2D ideas.

I’ll start with ∆ f∆x , Figure 22. then the slope is

∆ f∆x

=f (x + ∆x, y)− f (x, y)

∆x

Now I take a limit and get a derivative:

∂ f∂x

= lim∆x→0

∆ f∆x

= lim∆x→0

f (x + ∆x, y)− f (x, y)∆x

The ∂ symbol is pronounced partial, so this is called a partial deriva-tive, and ∂ f

∂x is pronounced the partial derivative of f with respect to x.It’s called partial because the whole function f (x, y) has y’s in it too.And why not do y too:

∂ f∂y

= lim∆y→0

∆ f∆y

= lim∆y→0

f (x, y + ∆y)− f (x, y)∆y

I’m going to compute a partial derivative using the ∆y definition. I’llnever do it again and I won’t ask you to either. But I intend to learn alot from doing it. I’ll start with f (x, y) = x3 + 3x2y + y2.

f (x, y+∆y)− f (x, y) =[

x3 + 3x2(y + ∆y) + (y + ∆y)2]−[

x3 + 3x2y + y2]

=[

x3 + 3x2y + 3x2∆y + y2 + 2y∆y + (∆y)2]−[

x3 + 3x2y + y2]

After cancelling stuff,∆ f∆y

=3x2∆y + 2y∆y + (∆y)2

∆y= 3x2 + 2y + ∆y

And, taking the limit,

∂ f∂y

= 3x2 + 2y

Page 9: Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew a blue line of height 3, and you can see it’s accurate by comparing it with the

calculus lectures 9

f (x, y) = x3 + 3x2y + y2;∂ f∂y

= 3x2 + 2y

What did I learn? If I look at the x3 term, it differentiated to zero!But that’s what a partial derivative should do; in ∂ f

∂y , only y changes.

Since x doesn’t change, ∂ f∂y thinks x is a constant, and therefore it

differentiates to zero. In general, if f (x, y) = g(x) + h(y), then

∂ f∂x

=∂g∂x

+∂h∂x

=∂g∂x

+ 0; ditto for∂ f∂y

Next thing I learned: If I look at the y2 term, it differentiated like aregular quadratic would. In general, if f (x, y) = g(x) + h(y), then

∂ f∂x

=dgdx

∂ f∂y

=dhdy−− partials become regular derivatives

Last thing I learned: if I look at the 3x2y term, the y got differentiatedto 1, which is right, leaving the 3x2 term alone. The x2 term justpulled out of the derivative, just like the constant 3 did.If f (x, y) = g(x)h(y), then

∂ f∂x

=dgdx· h(y) ∂ f

∂y= g(x) · dh

dy

Now I can do some "real" problems: things that could appear onpractice or quizzes.

Worked Problems

Problem: What does a chain rule look like?Let f (x, y) =

√1− (x2 + y2) = (1− x2 − y2)

12

∂x

[(1− x2 − y2)

12

]=

12(1− x2− y2)−

12

∂x(1− x2− y2) =

12(1− x2− y2)−

12 (−2x) =

−x

(1− x2 − y2)12

Just like a regular chain rule:

∂x[ f (x, y)]a = a [ f (x, y)]a−1 ∂ f

∂x

∂xsin f (x, y) = cos f (x, y)

∂ f∂x

∂xln f (x, y) =

1f (x, y)

∂ f∂x

And so on.

Page 10: Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew a blue line of height 3, and you can see it’s accurate by comparing it with the

10 Kathy Davis

Now I’ll try a quotient rule. Find the partial with respect to x andsimplify:

f (x, y) =xy

x2 + y2 ;∂

∂x

[xy

x2 + y2

]=

∂∂x (xy) · (x2 + y2)− (xy) · ∂

∂x (x2 + y2)

(x2 + y2)2

=y · (x2 + y2)− (xy) · 2x

(x2 + y2)2 =y[x2 + y2 − 2x2](x2 + y2)2 =

y[y2 − x2]

(x2 + y2)2

WARNING: Simplifying requires two things: First, factor out the y;second, put everything over a common denominator. Because of thesecond, it’s easier for me to use the quotient rule, where everything isalready over a common denominator.

Now do the same for the y partial derivative:

∂y

[xy

x2 + y2

]=

∂∂y (xy) · (x2 + y2)− (xy) · ∂

∂y (x2 + y2)

(x2 + y2)2

=x · (x2 + y2)− (xy) · 2y

(x2 + y2)2 =x[x2 + y2 − 2y2](x2 + y2)2 =

x[x2 − y2]

(x2 + y2)2

to summarize,

∂ f∂x

=y[y2 − x2]

(x2 + y2)2∂ f∂y

=x[x2 − y2]

(x2 + y2)2

These derivatives look alike. But then f treats x and y the same:

Definition: f is symmetric in x and y if switching x and y doesn’tchange the function. That is, f (x, y) = f (y, x). Try it:

f (x, y) =xy

x2 + y2 f (y, x) =yx

y2 + x2

So what? If f is symmetric in x and y, then I can get ∂ f∂y from ∂ f

∂x by

switching x and y: ∂ f∂y (x, y) = ∂ f

∂x (y, x). Try it:

∂ f∂x

(x, y) =y[y2 − x2]

(x2 + y2)2 ;∂ f∂x

(y, x) =x[x2 − y2]

(y2 + x2)2 =∂ f∂y

(x, y) Check!

For symmetric functions, I can save a lot of time by just switching.The 14U will have some practice.

Warning

When I simplify a derivative, I bring all fractions together over acommon denominator 1

x −1y = y−x

xy .

Also, I factor to difference of squares: x2y3 − y2x3 = x2y2(y − x).Warning: Ignoring simplification will cost considerable points.

Page 11: Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew a blue line of height 3, and you can see it’s accurate by comparing it with the

calculus lectures 11

Worked Problem

Show that the function f (x, y) = ln(x2 + y2) satisfies the partialdifferential equation (PDE)

y∂ f∂x− x

∂ f∂y

= 0

Solution: I’m asked to compute the two partials, then substitute intothe equation and see everything cancels to zero. I’ll use the chain rulefor ln: [ln u]′ = u′

u .

∂ f∂x

=∂

∂x [x2 + y2]

x2 + y2 =2x

x2 + y2

I can get ∂ f∂y using symmetry;

∂ f∂y

=2y

x2 + y2

So,

y∂ f∂x− x

∂ f∂y

= y · 2xx2 + y2 − x · 2y

x2 + y2

=2yx− 2xy

x2 + y2 = 0

Check. This is actually here for a reason: I’ll show, later, that the PDEmeans, in polar co-ordinates, that f has no θ in it. But, that’s for later.There’s some more practice in the 14U.

Figure 23: Surface & Tan Line

Surface, trace and tangent line. I caneasily see the slope.

Figure 24: Perspective, Perspective

Change perspective and the slope looksnegative.

I want to see what the partials are telling me. In Figure 10, I said∂ f∂x (x, 0) is the slope of the trace z = f (x, 0). I’ll look at that in apicture and also do a computation.

Figure 23 shows the tangent line to the surface z = 1 − (x2 + y2)

at the point ( 12 , 0). I can see the slope is obviously positive. On the

other hand,

∂x

[1− (x2 + y2)

]= −2x so

∂ f∂x

(12

, 0) = −212= −1

OK, so is the slope positive or negative?

The answer is that the picture lies; compare Figure 24. Now the slopelooks negative. This is the problem in 3D: perspective can changelengths, angles and even changes positive to negative. The partials,though, don’t lie.

Page 12: Calculus Lectures: Intro to 3D · calculus lectures 3 In the left side of the figure below, I drew a blue line of height 3, and you can see it’s accurate by comparing it with the

12 Kathy Davis

Figure 25: Easy Barcode

In the 1970’s, these didn’t even exist.This picture shows a barcode that’s easyfor a computer to read.

Figure 26: Hard Barcodes

Very hard for a computer to read.

Figure 27: Hard Barcodes

Harder for a computer to read.

There’s a vector version of this; again vectors aren’t required inM408D, so just go with it. Like the derivative of a parametric func-tion, v(t), there’s a vector version of the partials. It’s called the gradi-ent:

∇ f =

(∂ f∂x

,∂ f∂y

)The gradient is what’s called an invariant: as I change perspective,∇ f changes along with me, but in just the right way. This makes thegradient important in applications.

When I first came to UT in 1978, one of my students was a TexasInstruments engineer; he told me TI was working on a computervision problem: scanning bar codes. Now everyone knows whatthis is, but in 1978, you bought groceries by waiting in a long line,gave them to a clerk, who looked at the price and typed it on a cashregister. If a sale was on, the clerk might or might not put in the rightprice.

Bar codes would change everything, but first computers had to tellthe difference between Figure 26 and Figure 25. But it’s all just achange in perspective! So, just use ∇: it can detect edges, Figure27. What the picture shows is a bike, after a digital filter has beenapplied to emphasize the edges in the picture. The filter is called agradient filter – because it applies a digital version of the gradient.And the gradient can handle all the different angles in the picture.

So that’s why an engineer was taking a calculus class in 1978: partialderivatives are important in all kinds of modern digital applications.