# How to express gradient of a hat function mapped on a triangle as a linear combination of triangle points

I have:
a triangle $ABC$
A linear function $f_0(X)$ where:
$f_0(A + s(B-A) + t(C-A)) = 1-s-t$
$s,t \in \mathbb{R}$

Can I express $\nabla f_0(x)$ as a linear combination of $A,B,C$?

I noticed that I can calculate the gradient by solving the system
$\nabla f_0(x) \cdot (B-A) = -1$
$\nabla f_0(x) \cdot (C-A) = -1$

.. but I'd like to avoid such a solution, as I was looking for something more immediate

Thanks.

-
What's a hat function? Why does it appear in the title but not in the body? The problem in the body appears to be drastically underdetermined -- are you making additional assumptions about $f_0$? – joriki Nov 27 '12 at 10:10
a) That's a function of one variable; here you seem to have a function of (at least) two variables? b) What about the rest of my questions? – joriki Nov 27 '12 at 10:39
The equations you've added determine $f_0$ on two edges of the triangle; you still haven't expressed any assumptions on $f_0$ that would allow to calculate its gradient in general. I'm getting the impression that what you actually mean is that $f_0$ is a linear function, but the question doesn't say that. – joriki Nov 27 '12 at 10:48
It seems rather audacious to omit the most important property of your function and hope that people will infer it from a term in the title that's apparently only defined for one-dimensional functions, and which apparently doesn't even refer to linear functions in that case. Generally speaking, the body of the question should be self-contained and shouldn't rely on assumptions implicit in the title. – joriki Nov 27 '12 at 10:54
By the way, now your first two equations are redundant since they're special cases of the third. – joriki Nov 27 '12 at 10:55

Let $a=B-C$, $b=C-A$ and $c=A-B$. Then the solution to

\begin{align} x\cdot c&=+1\;,\\ x\cdot b&=-1 \end{align}

is

$$x=\frac{a\times(b\times c)}{|b\times c|^2}=\frac{b(a\cdot c)-c(a\cdot b)}{(b\cdot b)(c\cdot c)-(b\cdot c)^2}\;.$$

-
Thanks for the answer, it's much better than my linear system solution, one question though: Is the final expression for $x$ considered a linear combination? (probably not) – Babis Nov 27 '12 at 12:13
@Babis: It's not better than your linear system solution; it's just an elegant way of writing down the solution to your linear system. Yes, it's a linear combination of the vertices, but the coefficients of the linear combination depend on the vertices, so it's not a linear function of the vertices -- which wasn't to be expected, since the magnitude of the gradient is inversely proportional to the side lenghts (which is reflected in the fact that the nominator has units of length to the third and the denominator has units of length to the fourth). – joriki Nov 27 '12 at 12:20
Ok, I think this covers it then now, thanks again for the solution and the explanation! – Babis Nov 27 '12 at 12:38
@Babis: You're welcome! – joriki Nov 27 '12 at 12:42
If I may, one more related question: If the function was $f(A+s(B−A)+t(C−A))= a−sb−tc$, how would the 'elegant form' of the solution be? I would try to derive it myself, but it is unclear to me how $x \cdot c = +1$, $x \cdot b = -1$ evolves to the expression with the cross products. Do you have any links for the derivation instead, or do you know how could I search it on the internet somehow? – Babis Nov 28 '12 at 16:35