# Taking Gradients: Partial Derivatives vs. Geometric Reasoning

In your homework, you are asked to derive an expression for the gradient of the area of a triangle with respect to one of its vertices. In particular, if the triangle has vertices $a,b,c \in \mathbb{R}^3$, then the gradient of its area $A$ with respect to the vertex $a$ can be expressed as
$\nabla_a A = \tfrac{1}{2} N \times (b-c).$
This formula can be obtained via a simple geometric argument, has a clear geometric meaning, and generally leads to a an efficient and error-free implementation.

In contrast, here’s the expression produced by taking partial derivatives via Mathematica (even after calling FullSimplify[]):

Longer expressions like these will of course produce the same values. But without further simplification (by hand) it will be less efficient, and could potentially exhibit poorer numerical behavior due to the use of a longer sequence of floating-point operations. Moreover, they are far less easy to understand/interpret, especially if this calculation is just one small piece of a much larger equation (as it often is).

In general, taking gradients the “geometric way” often provides greater simplicity and deeper insight than just grinding everything out in components. Your current assignment will give you some opportunity to see how this all works.

Update: As mentioned by Peter in the comments, here’s the expression for the gradient of angle via partial derivatives (as computed by Mathematica). Hopefully by the time you’re done with your homework, you’ll realize there’s a better way!

## 2 thoughts on “Taking Gradients: Partial Derivatives vs. Geometric Reasoning”

1. peter says:

Let $a,b,c\in\mathbb{R}^3$ and consider the angle formed at $b$ by the vectors $a-b$ and $c-b$. What’s a nice formula for it? How about$\theta = \cos^{-1}\left(\frac{\langle a-b,c-b\rangle}{\sqrt{\langle a-b,a-b\rangle}\sqrt{\langle c-b,c-b\rangle}}\right).$(BTW, why is the use of just $\cos$ not such a great idea in general?) Feel free to ask Mathematica what the gradient of this expression is with respect to $c$. ðŸ™‚ Whereas it’s trivial to figure out which direction a movement of $c$ increases $\theta$ the most. And further it’s easy to see what the constant of proportionality is. (Try it!)

1. Keenan says:

Great example. ðŸ™‚

For those of you without Mathematica (or the patience to grind it out by hand…) I’ve updated the post to include the “partial derivative” expression for the gradient of angle.