In a homework we were tasked to calculate the gradient of a triangle respective to a corner vertex. The instructions didn't say what to calculate and mentioned, one could derive it by a derivative of the triangle area using the corner vertex coordinates. I exactly came to the same formula explained by Futurologist.
In case someone wants to know, this is the derivation:
Let $\vec{x},\vec{y}, \vec{z} \in \mathcal{V}$ be the vertex corners of the triangle.
First, the area of a triangle is the length of the cross product between two sides of it divided by 2 (because the determinant calculates the area of a parallelogram which is twice the area of the triangle):
$A(\vec{x}) = \left|(\vec{y}-\vec{x})\times(\vec{z}-\vec{x})\right|/2 = \sqrt{\left((\vec{y}-\vec{x})\times(\vec{z}-\vec{x})\right)^2}/2$
The multiplication of vectors should be the dot product whose meaning depends on the operands left and right to it. Using differential calculus rules for vectors, this is what I get:
$\frac{\partial A}{\partial \vec{x}} = \frac{\frac{\partial \left((\vec{y}-\vec{x})\times(\vec{z}-\vec{x})\right)^2}{\partial \vec{x}}}{4\sqrt{\left((\vec{y}-\vec{x})\times(\vec{z}-\vec{x})\right)^2}}$
$= \frac{\frac{\partial \left((\vec{y}-\vec{x})\times(\vec{z}-\vec{x})\right)}{\partial \vec{x}} \cdot 2\left((\vec{y}-\vec{x})\times(\vec{z}-\vec{x})\right) }{4A}$
How to calculate the gradient of a cross product? If we would look for the divergence, we would use the determinant $\text{det}(\nabla_\vec{x},\vec{y}-\vec{x},\vec{z}-\vec{x})$ but that's not the gradient. The gradient $\partial A/\partial \vec{c}$ must be a vector itself so that $\partial(\vec{a}\times\vec{b})/\partial \vec{b}$ must be a matrix!
Now, just think of $M \times \vec{b}$ like a matrix product but using $M_i \times \vec{b}$ to replace the dot product $M_i \cdot \vec{b}$ of a normal matrix multiplication (each result component will now be a row vector, not a scalar).
Next step is to split those cross products up into a sum:
$\frac{\partial A}{\partial \vec{x}}= \frac{\frac{\partial \left(\vec{y}\times\vec{z}-\vec{x}\times\vec{z} - \vec{y}\times\vec{x} + \vec{x}\times\vec{x}\right)}{\partial \vec{x}} \cdot \left((\vec{y}-\vec{x})\times(\vec{z}-\vec{x})\right) }{2A}$
$\vec{y}\times\vec{z}$ does not depend on $\vec{x}$, $\vec{x}\times\vec{x}$ is $\vec{0}$. It now is used that $\partial(\vec{a}\times\vec{b})/\partial \vec{a} = I\times\vec{b}$, where $I$ is the eye matrix. It is a fact that $Y_\times = I\times\vec{y}$ is the (left) cross product matrix from $\vec{y}$ so that $\left(I \times \vec{z}\right)^T = \left(I\times(-\vec{z})\right)$ is the right cross product matrix from $\vec{z}$. Hence
$\frac{\partial A}{\partial \vec{x}}= \frac{\frac{\partial \left(\vec{x}\times\vec{y}-\vec{x}\times\vec{z}\right)}{\partial \vec{x}} \cdot \left((\vec{y}-\vec{x})\times(\vec{z}-\vec{x})\right) }{2A}$
$= \frac{\left(I\times\vec{y}-I\times\vec{z}\right) \cdot \left((\vec{y}-\vec{x})\times(\vec{z}-\vec{x})\right) }{2A}$
$= \frac{\left(I\times(\vec{y}-\vec{z})\right) \cdot \left((\vec{y}-\vec{x})\times(\vec{z}-\vec{x})\right) }{2A}$
$= \frac{\left((\vec{y}-\vec{x})\times(\vec{z}-\vec{x})\right)\times(\vec{z}-\vec{y}) }{2A}$
So this result is exactly the same as $-\frac{\mathcal{J}\vec{e_{j_i}}}{2} = \frac{(-\vec{n})\times\vec{e_{j_i}}}{2}$ where $\vec{e_{j_i}} = \vec{z}-\vec{y}$, $i = \vec{x}$ and the direction will always show towards the opposite edge of $\vec{x}$ indepent of which vertex is chosen to be $\vec{y}$ and which is $\vec{z}$. That's the reason, why the $2$ in the original formula for $(\text{grad} f)(j)$ is needed, to divide away the factor of $2$ within the $\vec{e_{j_i}}$.
If you work with parallelograms instead of triangles you can remove the $2$ entirely.
What does the gradient of a triangle mean after all? The triangle gradient is the direction, where -- if you move $\vec{x}$ in that direction -- the triangle experiences the biggest change in area. You can add together the gradient of multiple triangles from $\vec{x}$ to use it for minimizing surface area of a discrete 3D surface.