# Calc III type question: gradients, normal vectors, and the like

**URL:** <https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362>\
**Category:** Factual Questions\
**Created:** [July 11, 2002, 3:54am UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362 "2002-07-11T03:54:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [July 11, 2002, 3:54am UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/1 "2002-07-11T03:54:46Z")

</div>

All right, I was playing around with a function of four variables tonight, and I want to know how to find the normal vector to its surface at an arbitrary point.

The function is f(u, v, x, y) = 1 - w - x - y - z + 2ux + 2vy + uy + vx. The gradient is simple to compute; it’s [symbol]Ñ[/symbol]f(u, v, x, y) = (-1 + 2x + y, -1 + 2y + x, -1 + 2u + v, -1 + 2v + u). Note the symmetry, cause it’s interesting.

Now I want the normal vector to the tangent plane at the point (a, b, c, d). Based on what I found in my calc III book, my best guess is that the gradient _is_ the normal vector to the tangent plane. But it’s been a long time since I took calc III.

So howsabout it, folks? Is this right, or am I way off base? If I’m wrong, could someone steer me in the right direction, with an explanation of how to find said normal vector?

I’d appreciate it greatly.

---

<div class="post-metadata">

**Author:** ![Achernar](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Achernar](https://boards.straightdope.com/u/Achernar)\
**Post date:** [July 11, 2002, 4:50am UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/2 "2002-07-11T04:50:49Z")

</div>

I’m a little confused on one point. Are the coordinates of your system (u, v, x, y) or (w, x, y, z)? I’m not sure that it makes much of a difference. Just wondering.

I’m fairly sure that in three dimensions, the gradient vector of a scalar function f is the normal vector to a plane tangent to a surface _of constant f_. (Don’t forget that last part.) It points in the direction of increasing f. I never took 4-d Calculus, but I believe that you’d have to have a _space_ tangent to a _3-surface_ of constant f, but other than that, it would be the same.

---

<div class="post-metadata">

**Author:** ![greatZebu](https://avatars.discourse-cdn.com/v4/letter/g/ed655f/32.png) [@greatZebu](https://boards.straightdope.com/u/greatZebu)\
**Post date:** [July 11, 2002, 5:14am UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/3 "2002-07-11T05:14:54Z")

</div>

Hey ultrafilter, your book is right on. The gradient most certainly is perpendicular to the tangent hyperplane at every point. Enjoy your higher-dimensional math!

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [July 11, 2002, 5:50am UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/4 "2002-07-11T05:50:45Z")

</div>

Yep, I still got it, I guess. Thanks, guys.

The coordinate system is (u, v, x, y). Substitute u and v for w and z (geez, how’d I do that?).

Now I’m gonna see if I can’t argue that fact (“The gradient most certainly is perpendicular to the tangent hyperplane at every point”). Well, not tonight, but you know what I mean…

Just FYI, this function arose out of my working with the Monty Hall problem. If the host puts the prize behind door 1, 2, or 3 with respective probabilities u, v, and 1 - u - v, and you choose door 1, 2, or 3 with respective probabilities x, y, and 1 - x - y, then f(u, v, x, y) represents the probability that you chose correctly. I can’t plot it, so I decided to analyze it.

---

<div class="post-metadata">

**Author:** ![Erika](https://avatars.discourse-cdn.com/v4/letter/e/47e85d/32.png) [@Erika](https://boards.straightdope.com/u/Erika)\
**Post date:** [July 11, 2002, 5:53am UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/5 "2002-07-11T05:53:33Z")

</div>

The gradient is perpendicular to the “level curve/surface” at your point (a,b,c,d). I’m not entirely convinced that that makes it perpendicular to the surface itself. I s’pose it should be. But something doesn’t sound quite right…

---

<div class="post-metadata">

**Author:** ![Tyrrell\_McAllister](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/tyrrell_mcallister/32/16772_2.png) [@Tyrrell\_McAllister](https://boards.straightdope.com/u/Tyrrell_McAllister)\
**Post date:** [July 11, 2002, 7:59am UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/6 "2002-07-11T07:59:57Z")

</div>

**Erika** is right. Something is wrong here. For 2D surfaces with equations of the form _z = f(x,y)_, the gradient is a _2_-dimensional vector in the plane that points in the direction of the greatest increase of the funtion (_i.e._ “the direction to walk if you want to climb the mountain the fastest”). To find the normal vector to a 2D surface at a point, take the cross product of the two vectors tangent to the surface at the point that have slope given by the partial derivatives (at the point) and that are parallel to the (x,z)-plane and the (y,z)-plane (respectively). More precisely, take the cross product of

**i** + D[sub]_x_[/sub]_f(x,y)_ **k**

and

**j** + D[sub]_y_[/sub]_f(x,y)_ **k**.

These two vectors span the tangent plane at that point, so their cross-product is normal to that plane.

(This will give you a vector pointing in the right direction. But you will still need to normalize it if you want the unit norm at that point, say.)

In the case of a 3D “surface”, you’d need to find a vector pair-wise perpendicular to three other vectors, rather than the two above. The cross-product worked for doing this in the 2D case above, but in the 3D case I guess you’ll have to pull in some linear algebra and solve _A_ **x** = **0** , where _A_ is the 3-by-4 matrix which has your three tangent vectors as rows. **x** will then be a normal vector at that point. Note that the tangent vectors will be _4_-vectors, though some of their coordinates will be zero.

I haven’t worked out what the three tangent vectors are that would be analogous to the two I gave above, but I imagine they look similar, and should be deducible from similar considerations…

---

<div class="post-metadata">

**Author:** ![Tyrrell\_McAllister](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/tyrrell_mcallister/32/16772_2.png) [@Tyrrell\_McAllister](https://boards.straightdope.com/u/Tyrrell_McAllister)\
**Post date:** [July 11, 2002, 8:25am UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/7 "2002-07-11T08:25:47Z")

</div>

Oh; I just realized that you have a 4D surface. So you need to find four 5-dimensional tangent vectors, and solve _A_ **x** = **0** where _A_ is the 4-by-5 matrix whose rows are you tangent vectors. But the same pattern should hold…I hope.

---

<div class="post-metadata">

**Author:** ![Achernar](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Achernar](https://boards.straightdope.com/u/Achernar)\
**Post date:** [July 11, 2002, 8:27am UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/8 "2002-07-11T08:27:25Z")

</div>

Um, you realize that the cross product of those two vectors you give in your first post will be:

-D[sub]x[/sub]_f(x, y)_ **i** - D[sub]y[/sub]_f(x, y)_ **j**

which is simply -1 times the gradient vector. If this is a tangent, then the gradient vector will be a tangent too.

---

<div class="post-metadata">

**Author:** ![Achernar](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Achernar](https://boards.straightdope.com/u/Achernar)\
**Post date:** [July 11, 2002, 7:03pm UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/9 "2002-07-11T19:03:29Z")

</div>

Sorry. I was thinking two-dimensionally. To be more accurate, I should have said that the cross product is

-D[sub]x[/sub]_f(x, y)_ **i** - D[sub]y[/sub]_f(x, y)_ **j** + **k**

But this is still -1 times grad f(x, y, z), because in this case, z = f(x, y), and so in order for f(x, y, z) to be constant we’d have to require that f(x, y, z) = f(x, y) - z + const.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [July 11, 2002, 7:48pm UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/10 "2002-07-11T19:48:46Z")

</div>

Basically, this boils down to two questions:[ol][li] How do you find the tangent hyperplane to a hypersurface?[/li] How do you find the normal vector to a hyperplane?[/ol]The first one is definitely the harder of the two, and I’ll look into it once I get home tonight.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [July 11, 2002, 8:04pm UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/11 "2002-07-11T20:04:20Z")

</div>

From [this page](http://www-math.mit.edu/~djk/18_013a/chapter06/section06.html):

> [@](#):
>
> The gradient vector is in the direction of the projection of the normal to the tangent hyperplane into the hyperplane of coordinates.

So it’s close, but no cigar. Drat.

---

<div class="post-metadata">

**Author:** ![Achernar](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Achernar](https://boards.straightdope.com/u/Achernar)\
**Post date:** [July 11, 2002, 8:24pm UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/12 "2002-07-11T20:24:58Z")

</div>

Ah, I realize what you’re asking about now. You don’t want a 4-vector normal to a 3-plane tangent to a surface of constant f. You want the 5-vector normal to a 4-plane tangent to a surface _defined by_ f. Well if that’s the case then I would make a new function (sort of like what I did in my last post) defined thusly:

F(u, v, x, y, z) = f(u, v, x, y) - z

Notice that for every point defined by f (that is, z = f(u, v, x, y)), F is a constant (0). Now take the gradient of F. It’s going to be:

\<-1 + 2x + y, -1 + 2y + x, -1 + 2u + v, -1 + 2v + u, -1\>

If you want a vector that points “upward” (in direction of increasing z) multiply this by -1. I believe that that should give you what you seek.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [July 11, 2002, 8:27pm UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/13 "2002-07-11T20:27:59Z")

</div>

That looks like it might work. I’m gonna sanity check it, just to be sure, with a couple of lower-dimensional functions.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [July 11, 2002, 10:51pm UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/14 "2002-07-11T22:51:20Z")

</div>

All right, **Achernar** , it looks like you might have it. I’m gonna work through some more stuff, but thanks for your help.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [July 11, 2002, 11:14pm UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/15 "2002-07-11T23:14:42Z")

</div>

Yep, **Achernar** ’s right. Thanks, everyone.

---

<div class="post-metadata">

**Author:** ![Tyrrell\_McAllister](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/tyrrell_mcallister/32/16772_2.png) [@Tyrrell\_McAllister](https://boards.straightdope.com/u/Tyrrell_McAllister)\
**Post date:** [July 12, 2002, 12:14am UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/16 "2002-07-12T00:14:29Z")

</div>

> [@](#):
>
> \*Originally posted by Achernar \*  
> \*\*But this is still -1 times grad f(x, y, z), because in this case, z = f(x, y), and so in order for f(x, y, z) to be constant we’d have to require that f(x, y, z) = f(x, y) - z + const. \*\*

I’m not sure what the problem is with this. Isn’t that what you’d expect? The normal vector of a surface should be the gradient of the function for which that surface is a level curve. In fact the solution you did provide reflects exactly this reasoning.

---

<div class="post-metadata">

**Author:** ![Achernar](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Achernar](https://boards.straightdope.com/u/Achernar)\
**Post date:** [July 12, 2002, 12:55am UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/17 "2002-07-12T00:55:41Z")

</div>

Oh, sorry. I thought you were disagreeing with that. I think we’re on the same page now though.

Good luck, **ultrafilter**. Sorry I misunderstood you early on.

---

<div class="post-metadata">

**Author:** ![Ring](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@Ring](https://boards.straightdope.com/u/Ring)\
**Post date:** [July 12, 2002, 9:30pm UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/18 "2002-07-12T21:30:31Z")

</div>

The simplest way to do this is to construct the gradient _vector_ which _is_ perpendicular to the tangent plane. Then (Del f) dot \<x,y,z\> = 0 is the equation of the tangent plane.

For a sphere

f[sub]x[/sub] = 2x  
f[sub]y[/sub] = 2y  
f[sub]z[/sub] = -2z

\<2x[sub]0[/sub],2y[sub]0[/sub],-2z[sub]0[/sub]\> dot \<x,y,z\> = 0

2x[sub]0[/sub]x + 2y[sub]0[/sub]y- 2z[sub]0[/sub]z = f(x,y,z,) = equation of the tangent plane at the point (x[sub]0[/sub], y[sub]0[/sub], z[sub]0[/sub])

---

<div class="post-metadata">

**Author:** ![Ring](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@Ring](https://boards.straightdope.com/u/Ring)\
**Post date:** [July 12, 2002, 9:57pm UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/19 "2002-07-12T21:57:35Z")

</div>

That should be

z = (2x[sub]0[/sub]x +2y[sub]0[/sub]y) / 2x[sub]0[/sub]= equation of the tangent plane  
at the point(x[sub]0[/sub],y[sub]0[/sub],z[sub]0[/sub])

---

<div class="post-metadata">

**Author:** ![Ring](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@Ring](https://boards.straightdope.com/u/Ring)\
**Post date:** [July 13, 2002, 2:25am UTC](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362/20 "2002-07-13T02:25:55Z")

</div>

_Sigh_ a mind is a terrible thing not to have.

\<2x[sub]0[/sub],2y[sub]0[/sub],-2z[sub]0[/sub]\> dot \<x-x[sub]0[/sub],y-y[sub]0[/sub],z-z[sub]0[/sub]\> = 0

[Next page](https://boards.straightdope.com/t/calc-iii-type-question-gradients-normal-vectors-and-the-like/118362.md?page=2)
