We have
∇h=∂x∂hi+∂y∂hjI'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=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+jYou must now
1) turn this into a unit vector
n^ and
2) compute the dot product of
n^ with the gradient that you found above.
When you've done this, you will have a function
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) 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=x−2. But to get that function, you merely have to impose the constraint
y=x−2 on
d(x,y) i.e. use it to substitute for either
x or
y in
d(x,y), to give you, say,
e(x).
You can then find
e′(x) in the usual way to maximise the gradient.