Stewart's Theorem

Theorem
Let $a, b, c$ be the sides of a triangle.

Let $CP$ be any cevian from $C$ to $P$.

Then:


 * $a^2 \cdot AP+b^2 \cdot PB=CP^2 \cdot c+AP \cdot PB \cdot c$



Proof
There are two cases to consider:


 * 1) When the cevian is an altitude, the result follows directly from the law of cosines on $\triangle APC$ and $\triangle CPB$.
 * 2) When the cevian is not an altitude, we proceed as follows.

One of $\angle APC$ and $\angle BPC$ must be less than $90^\circ$ and the other must be greater.

WLOG let $\angle APC < 90^\circ$ and $\angle BPC > 90^\circ$.

Also note that $\angle APC$ and $\angle BPC$ are supplementary.

Then we have:


 * We multiply the first by $PB$ and the second by $AP$:


 * $b^2 \cdot PB = AP^2 \cdot PB + CP^2 \cdot PB - 2 PB \cdot AP \cdot CP \cdot \cos \left({\angle APC}\right)$


 * $a^2 \cdot AP = PB^2 \cdot AP + CP^2 \cdot AP + 2 AP \cdot CP \cdot PB \cdot \cos \left({\angle APC}\right)$


 * Now we add the two eqns:

Note
This is also known as Apollonius's Theorem.