# Thread: Tricky equation?

1. ## Tricky equation?

a^2 = k(k-u)(k-v)(k-w) where 2k = u+v+w

Given a, u and v, w = ?

2. ## Re: Tricky equation?

This is basically Heron's formula. So, if you know the area of the triangle and the lengths of two of its sides, then $w$ is the length of one of the sides.

So, we have $a = \dfrac{1}{2}uv\sin \gamma$ where $\gamma$ is the angle between $u$ and $v$.

We also have (by the law of Cosines): $w^2 = u^2+v^2-2uv\cos \gamma$ (again, where $\gamma$ is the angle between $u$ and $v$).

So, we have $\sin \gamma = \dfrac{2a}{uv} = \dfrac{\text{opp}}{\text{hyp}}$, so $\cos \gamma = \dfrac{\text{adj}}{\text{hyp}} = \dfrac{\sqrt{u^2v^2-4a^2}}{uv}$.

This gives $w = \sqrt{u^2+v^2-2\sqrt{u^2v^2-4a^2}}$

3. ## Re: Tricky equation?

Originally Posted by SlipEternal
This gives $w = \sqrt{u^2+v^2-2\sqrt{u^2v^2-4a^2}}$
Thanks Slip. Your 1st - sign should be a +, right?

Seems that works only if w = longest side.
Tried it with u,v,w = 4,13,15 : area = 24
If u=4, v=15, then w<>13.
Do I need another coffee?!

4. ## Re: Tricky equation?

Originally Posted by DenisB
Thanks Slip. Your 1st - sign should be a +, right?

Seems that works only if w = longest side.
Tried it with u,v,w = 4,13,15 : area = 24
If u=4, v=15, then w<>13.
Do I need another coffee?!
I think the first - sign should be a $\pm$. One of those will give the correct answer. We just need to figure out which. We will have to use guessing and checking.

With the - sign as is, it worked with u=4,v=15 and with u=13,v=15. It did not work with u=4,v=13.
With the - sign changed to a +, it worked with u=4,v=13, but not with the other two.

I think this is because $\cos \gamma$ could be negative (if $\gamma > \dfrac{\pi}{2}$), but $\dfrac{\sqrt{u^2v^2-4a^2}}{uv}>0$ always (so long as it is a valid triangle).

Edit: Yes, it is definitely a $\pm$. It could be either. Example: $u=4,v=13,w=\sqrt{145},a=24$ works just as well as $u=4,v=13,w=15,a=24$.

This gives:

$$w = \sqrt{u^2+v^2 \pm 2\sqrt{u^2v^2-4a^2}}$$

6. ## Re: Tricky equation?

It is possible for $w$ to be negative. Example: $u=4,v=13,w=-15,a=24$

So there is another $\pm$ on the entire formula. This gives four solutions for $w$ which makes sense given that the original equation works out to a 4th degree polynomial in $w$.

Second issue: the creation of the formula relied on $uv$ in the denominator. We should consider either value being zero as a degenerate case and solve that separately.

7. ## Re: Tricky equation?

Originally Posted by SlipEternal
Second issue: the creation of the formula relied on uv in the denominator. We should consider either value being zero as a degenerate case and solve that separately.
Can we not simply add "......where u>0 and v>0"?

8. ## Re: Tricky equation?

Originally Posted by DenisB
Can we not simply add "......where u>0 and v>0"?
Yes, that should work.

9. ## Re: Tricky equation?

Originally Posted by SlipEternal
Yes, that should work.
Lol, if $u=0$ or $v=0$, then the area is going to be zero, as well. So, my formula will still work. Turns out there are no degenerate cases. I asked on math.stackexchange.com if I caught all degenerate cases, and it turns out there were none.