4

I am analyzing a regular grid. I see that there is an equation for calculating the slope of this grid about the central point:

$$\text{slope} = \arctan\sqrt{f_x^2 + f_y^2}$$

where $f_x$ is the slope (change in $z$ over change in $x$) in the $x$ direction, $f_y$ is the slope (change in $z$ over change in $y$) in the $y$ direction.

$f_x$ and $f_y$ can be calculated using different algorithms; I am not concerned about those algorithms.

How does taking the arctangent of the resulting "hypotenuse" of the square root of the sum of squared ratios (slopes)?

I can sort of understand it physically (drawing it, rotating a piece of paper about, etc.), but not mathematically.

Travis Willse
  • 99,363
  • what you have is equivalent to $\tan\phi=|\nabla f|$, but this formula does not encode 'slope' so much as it does a skewed measure of how quickly $f$ varies at some point – obataku Feb 02 '15 at 07:14
  • @oldrinb, well, then I am not sure why I've read several papers that tell me that formula encodes slope. Should I quote from one of them? – traggatmot Feb 02 '15 at 07:18
  • Probably the term slope could stand to be put more specifically here; it is the slope of the line tangent to the graph of $f$ in the direction of steepest ascent at a point. – Travis Willse Feb 02 '15 at 07:31
  • Relative to the $xy-$plane, I would say the "slope" should be $$\dfrac{\text{rise}}{\text{run}} \approx \dfrac{f_x\Delta x+f_y\Delta y}{\sqrt{\Delta x^2+\Delta y^2}}$$ – David P Feb 02 '15 at 07:55

2 Answers2

2

There's a short answer and a long answer here. The short answer shows that this is a reasonable definition of a slope. The long answer shows a cleaner connection with the Pythagorean Theorem and how this really is a hypotenuse of a relevant triangle.

Short Answer

For small distances, the rise of a function $f(x,y)$ is approximately $f_x D_x + f_y Dy$, where $f_x$ denotes the $x$ derivative and $D_x$ denotes the distance in the $x$ direction (similarly for $y$). As the distances get smaller, this approximation becomes more exact (this is a differential). So the rise over run in this this direction $(D_x, D_y)$ is given by $$ \frac{f_x D_x + f_y D_y}{\sqrt{D_x^2 + D_y^2}} \tag{1}.$$

A well-known theorem from multivariable calculus is that the gradient gives the direction of greatest ascent. The gradient gives the direction $(f_x, f_y)$. If we use the gradient as our source of $(D_x, D_y)$ in $(1)$, then we get $$ \frac{f_x^2 + f_y^2}{\sqrt{f_x^2 + f_y^2}} = \sqrt{f_x^2 + f_y^2},$$ and so this is the slope of the function $f(x,y)$ in the direction of greatest ascent (in the sense that this is a local approximation of rise over run in that one particular direction).

If you want to convert this to an angle, you take arctangents, as is normal. So this is a purely mechanical way of understanding why.

Longer Answer

A surface is given by an equation $f(x,y) = z$. It is in this two-dimensional sense that we thought about this above. But let us now think of this as $$F(x,y,z) = z - f(x,y) = 0 \tag{2},$$ so that our surface is a level curve of a 3-dimensional function. (It might be useful to remind yourself that the graph of a 3-dimensional function is a four-dimensional object).

The gradient of $F$ is $(-f_x, -f_y, 1)$ and always lies perpendicular to the level surface. So the vector $(-f_x, -f_y, 1)$ will always be normal to our surface. Slope is a measure of hoe much this normal vector is in line with "up", which is $(0,0,1)$.

But there is a key difference. If the slopes are $0$, then the normal vector will be $(0,0,1)$, which points straight up. But if the slopes are huge, then the normal vector will be almost horizontal. By looking at the normal vector, we have turned the problem into a problem about slope with respect to the vertical axis.

What is the slope with respect to the vertical axis of the vector $(-f_x, -f_y, 1)$? As posed, this question is a bit ill-defined. But what's clear is that the $z$ coordinate is in line with the vertical axis, while $-f_x$ and $-f_y$ are perpendicular. So the "rise" in this case should be the contribution of $-f_x$ and $-f_y$, while the "run" will from the $z$ coordinate, which is $1$ in this case. If we go $-f_x$ in the $x$ direction and $-f_y$ in the $y$ direction, how much total distance have we gone? We've gone $\sqrt{f_x^2 + f_y^2}$ (and this is how the Pythagorean Theorem comes into play).

Then the "slope" with respect to the vertical axis is given by

$$\frac{\sqrt{f_x^2 + f_y^2}}{1} = \sqrt{f_x^2 + f_y^2}.$$

In summary, the Pythagorean Theorem makes sense here because we have transitioned to thinking about normal vectors, which flips the problem over. In this case, adding distances becomes straightforward.

Understanding why these two are related is very much incorporated with the basic proofs of the gradient and level surfaces. But that aside, I hope you have some understanding how $\sqrt{f_x^2 + f_y^2}$ gives a reasonable interpretation of slope.

0

For a path in the $(x,y)$ plane parametrized in $s$ by arclength, we have $$ \left|\left(\frac{\mathrm{d}x}{\mathrm{d}s},\frac{\mathrm{d}y}{\mathrm{d}s}\right)\right|=1\tag{1} $$ The Chain Rule and Cauchy-Schwarz say that $$ \begin{align} \left|\,\frac{\mathrm{d}f}{\mathrm{d}s}\,\right| &=\left|\,f_x\frac{\mathrm{d}x}{\mathrm{d}s}+f_y\frac{\mathrm{d}y}{\mathrm{d}s}\,\right|\\ &=\left|\left(f_x,f_y\right)\cdot\left(\frac{\mathrm{d}x}{\mathrm{d}s},\frac{\mathrm{d}y}{\mathrm{d}s}\right)\right|\\ &\le\left|\left(f_x,f_y\right)\right|\,\left|\left(\frac{\mathrm{d}x}{\mathrm{d}s},\frac{\mathrm{d}y}{\mathrm{d}s}\right)\right|\\[6pt] &=\left|\left(f_x,f_y\right)\right|\tag{2} \end{align} $$ where equality is attained in $(2)$ if $\left.\left(\frac{\mathrm{d}x}{\mathrm{d}s},\frac{\mathrm{d}y}{\mathrm{d}s}\right)\middle\|\left(f_x,f_y\right)\right.$.

Thus, the slope of $f$, which is the maximum of $\left|\,\frac{\mathrm{d}f}{\mathrm{d}s}\,\right|$, is $$ \left|\left(f_x,f_y\right)\right|=\sqrt{f_x^2+f_y^2}\tag{3} $$ The angle of the slope is $$ \arctan\left(\sqrt{f_x^2+f_y^2}\right)\tag{4} $$

robjohn
  • 345,667