Deriving a New Formula
Way back in the day, I was fairly obsessed with triangles. I really enjoyed my trigonometry class in high school. In addition to being interesting, it was the impetus for me learning to code. I got a little tired of doing all the myriad of sin()
and cos()
and tan()
functions to solve the triangles needed by my homework, so I decided to write an app for my TI-83+ graphing calculator to do it all for me. The app would ask you for the three things you knew about the triangle (almost any combination of sides or angles) and give you back all the rest of the information (including perimeter and area). I still have that source code.
In the course of writing this little app, I realized that, with rare exception, you could “solve” a triangle with any three pieces of information chosen from the side lengths, angles, area, or perimeter.
Unfortunately, I couldn’t really find formulae to handle some of the cases. Given three sides, you can use Heron’s Formula for finding the area, but I couldn’t find a formula to derive a side length from the area.
So, I set out to find a way to do it myself. It wasn’t very hard… just a lot of algebra to flip around.
Since I wanted to get the length of a side given two other sides and the area, it seemed logical to use Heron’s Formula: it has all the components I need, just in the wrong format. Here’s how I did it.
First, we start with Heron’s formula:
\[K = \sqrt{S * (S-a) * (S-b) * (S-c)}\]Then, we proceed to manipulate the terms to isolate one of the side lengths on one side of the equals sign, while moving \( K \) (the area) to the other side:
\[K^2 = S * (S-a) * (S-b) * (S-c)\] \[K^2 = \frac{a + b + c}{2} * \frac{b + c - a}{2} * \frac{a + c - b}{2} * \frac{a + b - c}{2}\] \[K^2 = \frac{1}{16} * \left( (a + b + c) * (b + c - a) * (a + c - b) * (a + b - c) \right)\]Distribute through the first group:
\[16K^2 = (ab + b^2 + bc + ac + bc + c^2 - a^2 - ab - ac) * (a + c - b) * (a + b - c)\]And simplify:
\[16K^2 = (b^2 + 2bc + c^2 - a^2) * (a + c - b) * (a + b - c)\]Distribute through the next group:
\[16K^2 = ab^2 + 2abc + ac^2 - a^3 + b^2c + 2bc^2 + c^3 - a^2c - b^3 - 2b^2c - bc^2 + a^2b * (a + b - c)\]And simplify:
\[16K^2 = ab^2 + 2abc + ac^2 - a^3 - b^2c + bc^2 + c^3 - a^2c - b^3 + a^2b * (a + b - c)\]And finally the last group:
\[16K^2 = a^2b^2 + 2a^2bc + a^2c^2 - a^4 - ab^2c + abc^2 + ac^3 - a^3c - ab^3 + a^3b + ab^3 + 2ab^2c + abc^2 - a^3b - b^3c + b^2c^2 + bc^3 - a^2bc - b^4 + a^2b^2 - ab^2c - 2abc^2 - ac^3 + a^3c + b^2c^2 - bc^3 - c^4 + a^2c^2 + b^3c - a^2bc\]And simplified:
\[16K^2 = 2a^2b^2 + 2a^2c^2 + 2b^2c^2 - a^4 - b^4 - c^4\]At this point, let’s decide we want to isolate \( c \) and say that’s the side we’re solving for. Let’s start pulling it out:
\[0 = -c^4 + (2a^2 + 2b^2)c^2 - a^4 - b^4 - 2a^2b^2 - 16K^2\]We can see this is in the quadratic form if we let \(x = c^2 \):
\[0 = -x^2 + (2a^2 + 2b^2)x - (a^4 + b^4 + 2a^2b^2 + 16K^2)\]By applying the quadratic formula, we can solve for \( x \):
\[x = \frac{-(2a^2 + 2b^2) \pm \sqrt{(4a^4 + 8a^2b^2 + 4b^4) - (4 * -1 * (-a^4 - b^4 - 2a^2b^2 - 16K^2))}}{-2}\]This is readily simplifiable:
\[x = \frac{-2a^2 - 2b^2 \pm \sqrt{4a^4 - 4a^4 + 8a^2b^2 + 8a^2b^2 + 4b^4 - 4b^4 - 64K^2}}{-2}\] \[x = \frac{-2a^2 - 2b^2 \pm \sqrt{16a^2b^2 - 64K^2}}{-2}\] \[x = \frac{-2a^2 - 2b^2 \pm 4 \sqrt{a^2b^2 - 4K^2}}{-2}\]Finally, we divide through the \( -2 \):
\[x = a^2 + b^2 \mp 2 \sqrt { a^2b^2 - 4K^2 }\]And substitue back in our value for \( x \):
\[c^2 = a^2 + b^2 \mp 2 \sqrt { a^2b^2 - 4K^2 }\]And like that, we’re able to solve a triangle given two sides and the area.
There are a couple of really interesting things about this:
- This is a variant of the Pythagorean theorem (\(c^2 = a^2 + b^2 \))
- This also looks an awful lot like the Law of cosines, which isn’t surprising since the Pythagorean theorem is a special case of the Law of cosines (the case where \(cos(C) = 0\)): (\(c^2 = a^2 + b^2 -2ab * cos(C) \)
-
By applying the Law of cosines to our newly-derived formula, you can also figure out how to solve for \( C \) (the angle opposite side \(c\)) with the area of the triangle:
\[cos(C) = \pm \sqrt{ 1 - \frac{4K^2}{a^2b^2}}\]
So, that’s a formula and some other stuff I derived when I was (slightly) bored and moderately curious 17-year-old. Is this useful? Mildly. But is it fun? It sure is!