The Student Room Group

Function of 2 variables in a certain plane?

NB This is a physics question which I feel is most suited to maths.

A hill is described h(x,y) = 300exp(-(x^2+y^2)).
A railway runs along the line x-y=2
What's the steepest slope that the train will need to climb?

I want to do as much as I ran myself, so am principally asking for a starting hint please. Specifically: there must be a way to view a 3D surface plot like this side on as defined by the railway line. Then I could parameterise this function h = f(t) and use normal 1D diff' to solve. Is this vaguely correct reasoning? If so, I don't have a clue how to carry put the initial 'projection'

Thanks in advance.
Reply 1
Original post by Sm0key
NB This is a physics question which I feel is most suited to maths.

A hill is described h(x,y) = 300exp(-(x^2+y^2)).
A railway runs along the line x-y=2
What's the steepest slope that the train will need to climb?

I want to do as much as I ran myself, so am principally asking for a starting hint please. Specifically: there must be a way to view a 3D surface plot like this side on as defined by the railway line. Then I could parameterise this function h = f(t) and use normal 1D diff' to solve. Is this vaguely correct reasoning? If so, I don't have a clue how to carry put the initial 'projection'

Thanks in advance.


Why not plug y=x2y = x-2 into h(x,y)h(x,y) to get h(x)=300exp((x2+(x2)2))h(x) = 300\exp(-(x^2 + (x-2)^2)) and then find a way to maximise h(x)h'(x) (this is probably all wrong) - otherwise, this sounds like something that can be tackled by Lagrange Multipliers, something I'm not very familiar with, in which case, I'll let somebody like atsruser or Greg jump in.
Original post by Zacken
Why not plug y=x2y = x-2 into h(x,y)h(x,y) to get h(x)=300exp((x2+(x2)2))h(x) = 300\exp(-(x^2 + (x-2)^2)) and then find a way to maximise h(x)h'(x)


I would do this.
Parametrise x and y, and then h(x, y) = h(t), which is 1 dimensional.

Spoiler

(edited 8 years ago)
Reply 3
Original post by EricPiphany
I would do this.
Parametrise x and y, and then h(x, y) = h(t), which is 1 dimensional.

Spoiler



Clever.
Original post by Sm0key
NB This is a physics question which I feel is most suited to maths.


Looks more like a maths question that's turned up in a physics course :-)


A hill is described h(x,y) = 300exp(-(x^2+y^2)).
A railway runs along the line x-y=2
What's the steepest slope that the train will need to climb?


I think that the usual way to approach this is to

a) find the gradient function h\nabla h for the surface in terms of x,yx,y
b) use that to find the directional derivative hn=hn^\frac{\partial h}{\partial n} = \nabla h \cdot \hat{n} in the direction of the line, unit vector n^\hat{n}
c) then reduce the problem to one dimension via xy=2x-y=2

The gradient function encapsulates information about the gradient of the surface at every point (x,y)(x,y). The directional derivative extracts gradient information from the gradient function along a line defined by a vector. A trivial directional derivative is fx\frac{\partial f}{\partial x}, which extracts gradient information from the function f(x,y)f(x,y) along the line defined by the x-axis, or the vector i\bold{i}.
Reply 5
Thanks all for the replies - much appreciated.
Reply 6
Original post by atsruser
Looks more like a maths question that's turned up in a physics course :-)



I think that the usual way to approach this is to

a) find the gradient function h\nabla h for the surface in terms of x,yx,y
b) use that to find the directional derivative hn=hn^\frac{\partial h}{\partial n} = \nabla h \cdot \hat{n} in the direction of the line, unit vector n^\hat{n}
c) then reduce the problem to one dimension via xy=2x-y=2

The gradient function encapsulates information about the gradient of the surface at every point (x,y)(x,y). The directional derivative extracts gradient information from the gradient function along a line defined by a vector. A trivial directional derivative is fx\frac{\partial f}{\partial x}, which extracts gradient information from the function f(x,y)f(x,y) along the line defined by the x-axis, or the vector i\bold{i}.


I wanted to do a directional derivative approach BUT didn't know how to compute the actual scalar product.

Please could you guide me through those steps?
Original post by atsruser

a) find the gradient function h\nabla h for the surface in terms of x,yx,y


We have h=hxi+hyj\nabla h = \frac{\partial h}{\partial x}\bold{i} + \frac{\partial h}{\partial y}\bold{j}

I'll assume that you are happy with computing that unless you say otherwise.


b) use that to find the directional derivative hn=hn^\frac{\partial h}{\partial n} = \nabla h \cdot \hat{n} in the direction of the line, unit vector n^\hat{n}


We need a vector in the direction of the line. Since y=x2y=x-2, we have a line of gradient 1 in the x-y plane, which means that we go 1 unit along the y-axis for 1 unit along the x-axis. A vector in this direction is thus i+j\bold{i}+\bold{j}

You must now

1) turn this into a unit vector n^\hat{n} and
2) compute the dot product of n^\hat{n} with the gradient that you found above.

When you've done this, you will have a function d(x,y)d(x,y) which computes the gradient of the surface in the *direction* of your line (i.e. along a vector parallel to it), but at any point (x,y)(x,y) in the x-y plane...


c) then reduce the problem to one dimension via xy=2x-y=2


... What you want, however, is a function that computes the gradient of the surface specifically on the points that lie on y=x2y=x-2. But to get that function, you merely have to impose the constraint y=x2y=x-2 on d(x,y)d(x,y) i.e. use it to substitute for either xx or yy in d(x,y)d(x,y), to give you, say, e(x)e(x).

You can then find e(x)e'(x) in the usual way to maximise the gradient.
Original post by Sm0key
I wanted to do a directional derivative approach BUT didn't know how to compute the actual scalar product.

Please could you guide me through those steps?


Please see my response to my response above.
Original post by atsruser
We have h=hxi+hyj\nabla h = \frac{\partial h}{\partial x}\bold{i} + \frac{\partial h}{\partial y}\bold{j}

I'll assume that you are happy with computing that unless you say otherwise.



We need a vector in the direction of the line. Since y=x2y=x-2, we have a line of gradient 1 in the x-y plane, which means that we go 1 unit along the y-axis for 1 unit along the x-axis. A vector in this direction is thus i+j\bold{i}+\bold{j}

You must now

1) turn this into a unit vector n^\hat{n} and
2) compute the dot product of n^\hat{n} with the gradient that you found above.

When you've done this, you will have a function d(x,y)d(x,y) which computes the gradient of the surface in the *direction* of your line (i.e. along a vector parallel to it), but at any point (x,y)(x,y) in the x-y plane...



... What you want, however, is a function that computes the gradient of the surface specifically on the points that lie on y=x2y=x-2. But to get that function, you merely have to impose the constraint y=x2y=x-2 on d(x,y)d(x,y) i.e. use it to substitute for either xx or yy in d(x,y)d(x,y), to give you, say, e(x)e(x).

You can then find e(x)e'(x) in the usual way to maximise the gradient.


What if the curve in the x-y plane wasn't a line?
Say y=x2y= x^2, the unit 'direction vector' of the curve varies.

I suppose you could parametrise the 'direction vector' in terms of x too, in my head that looks very messy.
(edited 8 years ago)
Original post by EricPiphany
I would do this.
Parametrise x and y, and then h(x, y) = h(t), which is 1 dimensional.

Spoiler



Just realized why this won't work in the general case.
You would have to parametrise in terms of curve length l think.
(edited 8 years ago)
Original post by EricPiphany
What if the curve in the x-y plane wasn't a line?
Say y=x2y= x^2, the unit 'direction vector' of the curve varies.

I suppose you could parametrise the 'direction vector' in terms of x too, in my head that looks very messy.


The tangent line to y=x2y=x^2 at any point P(x,y)P(x,y) has the gradient 2x2x, so the tangent vector at P has components "1 along x, 2x2x along y" i.e. it is i+2xj\bold{i} + 2x \bold{j} giving n^=11+4x2(i+2xj)\hat{n} = \frac{1}{\sqrt{1+4x^2}}(\bold{i} + 2x \bold{j})

So you can follow the prescription as above with that unit vector, and finally constrain the gradient to y=x2y=x^2 to get a 1D problem, then differentiate.
Original post by Zacken
Why not plug y=x2y = x-2 into h(x,y)h(x,y) to get h(x)=300exp((x2+(x2)2))h(x) = 300\exp(-(x^2 + (x-2)^2)) and then find a way to maximise h(x)h'(x) (this is probably all wrong) - otherwise, this sounds like something that can be tackled by Lagrange Multipliers, something I'm not very familiar with, in which case, I'll let somebody like atsruser or Greg jump in.


This looks fine, except that I think you may end up out by a constant factor of 2\sqrt{2} if you do it naively, due to the fact that you have ended up with a function of xx, and a unit increment in xx does not equate to a unit increment along y=x2y=x-2, which defines the direction that you are really interested in.

In fact, a unit increment along xx gives you an increment of 2\sqrt{2} along y=x2y=x-2 so this will make the calculated gradient too big (too small?). The gradient method that I showed evades this, since it allows us to differentiate naturally in the direction of the line in question, and at one point we calculate a unit tangent along that direction to make sure that we are working in terms of unit increments along that line.

[edit: in calculating the gradient along the line via Zacken's method, this happens: Suppose that the height of the function above the x-y plane is z(x,y)z(x,y). We work with an x-change of dxdx along the x-axis - however, due to the slope of y=x2y=x-2, this corresponds to points on the function that are really 2dx\sqrt{2}dx apart along y=x2y=x-2, so our z-delta turns out to be 2dz\sqrt{2}dz and the slope of z(x,y)z(x,y) is computed as 2dzdx\frac{\sqrt{2}dz}{dx} which is too big.]
(edited 8 years ago)
Original post by EricPiphany
I would do this.
Parametrise x and y, and then h(x, y) = h(t), which is 1 dimensional.

Spoiler



I don't think that this is fundamentally different from Zacken's suggestion, but it suffers from the same problem (of step size) which I described above.
Original post by atsruser
I don't think that this is fundamentally different from Zacken's suggestion, but it suffers from the same problem (of step size) which I described above.


Thanks. Realised that eventually over here.

Original post by EricPiphany
Just realized why this won't work in the general case.
You would have to parametrise in terms of curve length l think.
Original post by Zacken
Why not plug y=x2y = x-2 into h(x,y)h(x,y) to get h(x)=300exp((x2+(x2)2))h(x) = 300\exp(-(x^2 + (x-2)^2)) and then find a way to maximise h(x)h'(x) (this is probably all wrong) - otherwise, this sounds like something that can be tackled by Lagrange Multipliers, something I'm not very familiar with, in which case, I'll let somebody like atsruser or Greg jump in.


You can, in fact, do this via Lagrange multipliers, but I couldn't see how for a bit (because I'm quite thick). You need to first find the directional derivative function hn(x,y)\frac{\partial h}{\partial n}(x,y) then maximise subject to the constraint xy=2x-y=2. So you form:

g(x,y)=hnλ(xy2)g(x,y) = \frac{\partial h}{\partial n} - \lambda(x-y-2)

and then solve the series of equations:

gx=0,gy=0,gλ=0\frac{\partial g}{\partial x} = 0, \frac{\partial g}{\partial y} = 0, \frac{\partial g}{\partial \lambda} = 0

The last one is boring; it just reproduces the constraint that you started with, but the other two give you the equations in x,yx,y that you need to solve to find the extrema. This looks like it's equivalent to the gradient method in some sense, though [Maybe Gregorius can explain the exact connection?]
Original post by atsruser
[Maybe Gregorius can explain the exact connection?]


Eeek! I was never any good at this sort of stuff. But from a geometric point of view, one needs to observe that to do the parametrization approach correctly (the idea of if x-y=2 then y = x - 2) the resulting curve must be normalized by arc-length - or you end up out by a factor of root two as has already been observed. My guess is getting the unit vector n^\hat{n} corresponds to the arc length normalization step.
Original post by Gregorius
Eeek! I was never any good at this sort of stuff. But from a geometric point of view, one needs to observe that to do the parametrization approach correctly (the idea of if x-y=2 then y = x - 2) the resulting curve must be normalized by arc-length - or you end up out by a factor of root two as has already been observed. My guess is getting the unit vector n^\hat{n} corresponds to the arc length normalization step.


This is correct (see my insightful geometric explanation earlier :smile:) but the question that I was a little hazy on was the connection between solving the problem via Lagrange multipliers and by merely substituting for y to reduce the problem to 1D.

Having thought about it a bit, in this simple case, these are indeed merely the same thing, since once we have got our 3 equations by partial differentiation (one of which just gives us back the constraint) we then have to solve them (by substitution..) so Lagrange multipliers gives us nothing here.

My question was fairly stupid, in fact.
Original post by atsruser

My question was fairly stupid, in fact.


They're often the best sorts of questions!

Quick Reply