Main content

### Course: Multivariable calculus > Unit 3

Lesson 2: Quadratic approximations- What do quadratic approximations look like
- Quadratic approximation formula, part 1
- Quadratic approximation formula, part 2
- Quadratic approximation example
- The Hessian matrix
- The Hessian matrix
- Expressing a quadratic form with a matrix
- Vector form of multivariable quadratic approximation
- The Hessian
- Quadratic approximation

© 2024 Khan AcademyTerms of usePrivacy PolicyCookie Notice

# Quadratic approximation example

A worked example for finding the quadratic approximation of a two-variable function. Created by Grant Sanderson.

## Want to join the conversation?

- Is a cubic approximation any better than a quadratic approximation? I know it would be even more monstrous with the third partial derivative and the third partial derivative would most likely be 0 but is it any better?(7 votes)
- Yes, the cubic approximation would be better than a quadratic approximation. I assume you've completed single-variable calculus. What Grant is doing in this video is basically a "two-term Taylor expansion" for multivariable functions (but the multivariable version has much more than the two terms of it's single-variable cousin).

A cubic approximation would be a "three-term Taylor approximation" basically, and as you probably know, the more terms you add in the Taylor approximation, the more accurate the approximation is. A quartic approximation would be better than a cubic approximation, and a quintic approximation would be even better than a quartic approximation, etc...

At a certain point, adding terms would affect the approximated value so minutely that it would be unnecessary and too cumbersome to do by hand for most practical situations.(23 votes)

- Hello. Can You explain please, why did you put 1/2 in front of "fxx" and "fyy" in the formula, I did not understand that part? Thank you n advance.(13 votes)
- It was shown in the previous video where Grant derive the formula for QA.(4 votes)

- how to find the value of cos 61.8 by approximation formula?(3 votes)
- This is not a multivariable calculus problem. You might want to review Sal's approximation formula video for single variable calculus: https://www.khanacademy.org/math/differential-calculus/derivative-applications/differentiation-application/v/approximating-incremental-cost-with-derivative

The linear approximation formula is f(x) ~= f(x_0) + f'(x_0) * (x - x_0)

In the case of cos(61.8 degrees), or cos(1.0786 radians) --> x = 1.0786; x_0 = pi/3 = 1.0472 :

cos(1.0786) ~= cos(pi/3) - sin(pi/3) * (1.0786 - pi/3)

cos(1.0786) ~= 1/2 - √3/2 * (0.0314) = 0.4728

In reality, cos(1.0786) = 0.4726.

Realistically, there would be no easy way to convert 61.8 degrees into radians and to convert √3/2 into decimal form without a calculator, and if you have a calculator, you might as well directly plug in cos(61.8) into it.

If you wanted an even more accurate quadratic approximation, you would simply add

f''(x_0)/2 * (x-x_0)^2 to the first result (0.4728) so

cos(1.0786) ~= 0.4728 + (-cos(pi/3)/2 * (pi/3 - 1.0786)^2) = 0.4728 - 0.0002 = 0.4726

which is basically equal to cos(1.0786), to the nearest tenthousandths place.(9 votes)

- How does this situation or quadratic approximation equation change in the case that we're dealing with a function where ꝺ^2Q/ꝺxꝺy ≠ ꝺ^2Q/ꝺyꝺx ?(4 votes)
- The Hessian matrix captures such an eventuality, and you could adapt the maths from there - although you might not be able to do anything with it.

Researching Clairaut's theorem (aka: Schwarz's theorem, or Young's theorem) states that where there is continuity of the second derivatives in the neighbourhood of your input point, the mixed second derivatives are the same irrespective of the order of differentiation.

https://en.wikipedia.org/wiki/Symmetry_of_second_derivatives#Schwarz's_theorem

Hmmm...: for some reason, this text editor doesn't seem to like apostrophes in URLs, but the link still gets you there.(1 vote)

- At1:00, did you forget to put 1/2 before fxx and fyy?(3 votes)
- Hi everyone - I think I missed the nature of the mistake that was made at4:55. Can someone explain why he needed to have 1/2 as a coefficient in front of the f terms? Thanks for any insight.(1 vote)
- The reason for the 'half' is explained in the previous video...

The quadratic function, Q(x, y) that we want to use to approximate the original function needs the same 2nd derivatives as the original. We're assuming it has a term of the form:

a.(x - x_0)^2

When we take the 2nd derivative of Q with respect to x, all other terms vanish, and we're left with 2a.

Therefore, taking the second derivative of the original function evaluated at (x_0, y_0), we're looking for '2a'...

'a' (what we need for the coefficient of the '(x - x0)' term of 'Q') is obviously half of '2a'.

The same logic applies to the (y-y_0) term.(2 votes)

- Can we just increase the power for better and better approximations like taylor series?(1 vote)
- What would the general form of an nth degree approximation look like (where n is a non-negative integer)? Intuition tells me it would be a massive sum of all permutations of possible partial derivatives, but Anna's question made me curious. Also, what would a quadratic approximation look like if f was a function of three variables?(1 vote)

## Video transcript

- [Voiceover] When we last
left off in the riveting saga of quadratic approximations
of multi variable functions, we were approximating a two
variable function, f of xy, and we ended up with this
pretty monstrous expression, and because it's written its
full abstract form, I almost feel like it looks more
monstrous than it needs to, so I'm going to go ahead
and go through a specific example here, and just to
remind you of kind of what all these terms are, how
there's actually kind of a pattern to what's going
on, this here represents, you can think of it as the
constant term, where you know this is just going to evaluate
to some kind of number. These two terms are what you
might call the linear term, linear, because if you
actually look, the only places where the variable x
and y comes up is here, where it's just being
multiplied by a constant, and here, where it's just
being multiplied by a constant, so it's just variables
times constant in there. And then all of this stuff
at the end, which is kind of the whole essence of a
quadratic approximation, where you start to have things
like you get an x squared, and you get x gets to be multiplied by y, all of this stuff is the
quadratic term, and though it seems like a lot now,
you'll see in the context of an actual example, it's
not necessarily as bad as it seems. So let's say we're looking
at the function f of xy and let's say it's going to be e to the x divided by two, multiplied by sin of y. This is our multi variable function. And let's say we want to
approximate this near some kind of point, and I'm going
to choose a point that's something that we can
actually evaluate these at, so like x, it would be
convenient if that was zero, and then y, I'll go with
pi halves, because that's something where I'll
know how to evaluate sin, and where I'll know how to
evaluate its derivatives, things like that. So we're trying to
approximate this function near this point. Now first things first. We're just going to need
to get all of the different partial derivatives and
second partial derivatives. We know we're going to need
them, so let's just kind of start working it through,
and figuring out what all of them are. Let's start with the partial
derivative with respect to x. So this is also a function of xy, and we look up at the original function, the only place where x shows
up is in this e to the x over two, the derivative
of that is one half, we bring down that one half, times e to the x over two, and this is being multiplied
by something that looks like a constant, as far as x is concerned, sin of y. Now when we do the partial
derivative with respect to y, what we get, this first part just looks
like a constant, so we kind of keep that constant there,
as far as y is concerned, and the derivative of sin is cosin. Cosin of y. And then now we let's start taking second
partial derivatives, so I'll start by doing the one where we take the partial derivative
with respect to x twice. Now here I'll actually do
this in a different color. Let's do yellow. Just to make clear which
ones are the second partial derivatives. So partial with respect to x twice, also, function of xy,
like all of these guys. So let's look up at the
original partial derivative with respect to x, and we're
now going to take its derivative, again with respect to x. This is the only place where x shows up, that one half kind of comes down again, so now it's going to be one fourth times e to the x over two, and we just keep that sin of y, because it looks like
we're just multiplying by a constant, sin of y. Next we'll do the mixed partial
derivative, where you do first with respect to x,
then with respect to y, or you could do it the other
way, because with almost all functions, it kind
of doesn't matter which order you take the two. So I'll go ahead and
just look at the one that was with respect to x,
and now let's think of its derivative with respect to y. This whole one half e to the x halves looks like a constant,
derivative of sin of y is cosin y. So we take that constant,
the one half e to the x halves, and then we multiply it by
the derivative of sin of y, which is cosin of y. And then finally we take
the second derivative, second partial derivative with respect to y, twice in a row. So f with respect to y, twice in a row. And for this one, let's
take a look at the partial derivative with respect to y. This part is the only
part where y shows up, derivative of cosin is negative sin, and then e to the x halves just
still looks like a constant, so we'll bring that negative out front, that constant e to the x halves, and it was negative sin, so that negative went out front, sin of y. So that's all of the partial
differential information that we're going to need. And now we know we're
going to need to evaluate all of these guys, all of
these partial derivatives at the specific point,
because if we go up and look at the original
function that we have, we're going to need to
evaluate f at this point, both of the partial
derivatives at this point, the second partial derivatives. Oh, I'm realizing, actually,
that I made a little bit of a mistake here. This should be a one half out in front of each of these guys. That should be plus
one half of this second partial derivative, and
one half of this second partial derivative. The mixed partial
derivative it's still one, but these guys should have a one half. That was a mistake on my part. In any case, though, we're
going to need to evaluate all of these guys, so if we go back down, let's just start plugging
in the point zero and pi halves to each one of these. So the function itself,
when we plug in zero, e to the zero is one,
and sin of pi halves, sin of pi halves is also one, so this entire thing just comes to one. If we do this for the next one, again e to the zero is going to be one, sin of y is also going to be one, but now we have that
one half sitting there, so that'll end up as one half. If we look at the partial
derivative with respect to y, cosin of pi halves is zero, so this entire thing is going to be zero. Moving right along, let's
take a look at this second partial derivative with respect to x. Again, e to the zero will be one, and sin of pi halves will be one, so this ends up just
being that one fourth, the mixed partial derivative here, if we have one half by the
pattern's starting to continue, you've got the one, this
one's actually zero, so cosin of pi halves is zero, so the whole thing will be zero. And then the last one it'll be negative one times that one again, for sin of pi halves is one, so all of that just comes
out to be negative one. So this, I mean I kind of
chose a convenient example, where all the derivatives
look very similar to the thing itself, which is
actually pretty common, so we get to leverage
a lot of the work that we did earlier. So now we have these
six different constants, can't keep them all on the
screen at the same time. But we've got these six
different constants, so now we just plug each
one of them in to the quadratic approximation. So if we make our quadratic
approximation of our function, the first term is that constant term, so we take a look up and
we say where does f of xy go at this point, and it'll just be one. We're going to have to do
a lot of scrolling back and forth here. There's a lot of text to deal with. The next thing is going to be something times x minus zero, the
kind of x coordinate of our specified point, and that something is
the first derivative with respect to x, so that's
going to be one half. So come back down here. That one half. And then similarly, we're
going to have something multiplied by y minus the y coordinate of the point about which
we are approximating, and for that we take a look
at the partial derivative with respect to y, which was just zero, so that's pretty convenient. That's just going to end up being zero. And then for the second
partial derivative terms, maybe I'll actually be able to keep it on the same screen here. We're going to have
something multiplied by x minus its coordinate squared, and that something is whatever
the partial derivative with respect to x twice
is, which is one fourth, so we go ahead and plug in one fourth, and then for the mixed partial derivative, I'll put it down here, it'll be something multiplied
by x, minus its constant, and then y minus that pi halves, and that something is the
mixed partial derivative, which in this case is zero. Oh and I'm realizing I made
the same mistake again. It's not one fourth, it's one half. For the same reason that I
made a mistake up here earlier, where it's actually one
half multiplied by this second partial derivative,
and one half by the second partial derivative there, I
guess I keep forgetting that. Good lesson, I suppose, that
that's an easy thing to forget, if you find yourself
computing one of these, where I'll put it in here, multiply that guy by one half. It's similar to a Taylor
expansion in single variable calculus, where you kind
of have to remember what's what that squared term
would be, has a one half associated with it. So for that same reason,
now we're going to have, and this time I won't forget it, will be one half multiplied by something, multiplied by the y minus pi halves, minus that y coordinate of
the point we're approximating there, and this time that something is negative one. So we can kind of plug
in here negative one. And now this is something
we can simplify quite a bit, because that one stays there, one half of x minus zero, that's just x halves, this whole part cancels out to zero, so there's nothing there. Over here we have half
times a fourth, one eighth times x squared, so that's x squared divided by eight. This mixed partial
derivative term is zero, so that's pretty nice. And then this last term here is just negative one half, so let's see, I'll write
it down as negative one half by y minus pi halves squared, by y minus pi halves squared. So that is the quadratic approximation, and you can see this actually feels like a quadratic function. We've got up to x squared,
and up to y squared, and there's a sense in which this is a simpler function. I mean, it looks like it's
got more terms than the original one, which was e
to the x halved sin of y, but if it's a computer
that needs to compute these things, for example, it's
much easier to deal with polynomials, that's a faster thing to do. Also for theoretical
purposes, it can be nice to deal with just a quadratic
polynomial to make conclusions about things. We'll see that in the context
of something called the second partial derivative test. But just to get a feel for
what this means, let's pull up the graph of the relevant functions. So this here is the graph
of the original function, e to the x halves times sin of y, and the point that
we're approximating near was where x equals zero, so let's see how we get oriented. X is equal to zero, and then
y is equal to pi halves. So this is the point
we're approximating near. And the quadratic approximation,
when you plug everything in, has a graph that looks
like this white surface here. So if I get rid of that
original graph, this is how we're approximating the
function near that point. And that does a pretty good job, right? Because even as you step
pretty far away from that point, it's pretty closely
hugging the original surface. If you go very far away,
it certainly doesn't get the oscillating nature
of that sin component, and the exponential
component grows faster than the quadratic one, but nearby, nearby this actually
gives a very good feel for the shape of the graph. And again, later on we'll
see how this is a pretty useful theoretical tool for
drawing conclusions about qualitative features of
the shape of the graph, the fact that this looks
kind of like a saddle, is going to end up being kind of important in certain contexts. But before we get to any
of that, in the next couple videos I'm going to talk about a simpler, or rather a more generalizable form, of writing down this
quadratic approximation using vector notation. Because right now we're just limited to two variables, and you can
imagine how monstrous this might look if you were
dealing even just with a three variable function, where think of all the
different possible second partial derivatives of a
three variable function, or a four variable function. It would quickly get out
of hand, but there is kind of a nice general way
to write all of these. So with that, I will see you next video.