# Triangle trigonometry - finding the distance between a corner and any point on the opposite side

The question states: a triangle ABC has acute angles at A and B, where |BC| = a, |CA| = b and |AB| = c. The point P lies on the side AB. Find an expression for |CP|^2.

$$\frac{a^2}{c}\cdot |AP|+\frac {b^2}c\cdot (c-|AP|)-|AP|\cdot |BP|$$

I have tried using the formula for the sides of a kite however it gets very messy and complicated. I suspect there is a more elegant solution. Here's my thought process on a diagram. Picture of triangle and my kite

• Use the law of cosines in triangles $CPA$ and $CPB$ – Lozenges Apr 29 at 19:36

As @Lozenges suggests in the comments, whenever you have such a configuration, the Law of Cosines might help. Why? Easy: because $$\color{blue}{\cos(\angle APC)=-\cos (\angle CPB)}$$. This might not help a lot, but you'll see later how we can take advantage of this fact!
Now, in virtue of the Law of Cosines in $$\triangle CPA$$ and $$\triangle CPB$$, we obtain \begin{align*}a^2&=PC^2+PB^2-2PC\cdot PB\cdot \cos (\angle CPB)\\b^2&= PC^2+AP^2\color{blue}+2PC\cdot AP\cdot\color{blue}{\cos (\angle CPB)}\end{align*} Or equivalently
\begin{align*}a^2\color{brown}{\cdot AP}&=PC^2\color{brown}{\cdot AP}+PB^2\color{brown}{\cdot AP}-2PC\cdot PB\color{brown}{\cdot AP}\cdot \cos (\angle CPB)\tag{1}\\b^2\color{brown}{\cdot PB}&= PC^2\color{brown}{\cdot PB}+AP^2\color{brown}{\cdot PB}+2PC\color{brown}{\cdot PB}\cdot AP\cdot\cos (\angle CPB)\tag{2}\end{align*}
Why doing this? Well, adding $$(1)$$ and $$(2)$$ yields (the cosines magically disappear!)
$$a^2\cdot AP+b^2\cdot PB=PC^2(AP+PB)+AP\cdot PB(AP+PB)=PC^2\cdot c+AP\cdot PB\cdot c$$