Showing posts with label area of triangle. Show all posts
Showing posts with label area of triangle. Show all posts

Thursday, 18 July 2024

Area of Triangle Using Matrices and Determinants

I watched an interesting YouTube video explaining how to use matrices and determinants to find the area of a triangle given its vertices. Of course, one could use the distance formula to find the lengths of the sides and then use Heron's formula to find the area but this method is far quicker as we'll see.

The first example used in the video involved the points (1,1), (4,1) and (4,5). These coordinates are used to form a 3 x 3 matrix with the x coordinates forming the first column, the y coordinates forming the second column, and the third column consisting of three 1's. The result is as shown below:$$ \begin{bmatrix} 1 & 1 & 1 \\ 4 & 1 & 1\\ 4 & 5 & 1 \end{bmatrix} $$The determinant of this matrix is 12 and the area of the triangle is simply half the value of the determinant, namely 6. The coordinates were chosen by the author of the video so that the the triangle formed by the vertices is right-angled and its area quickly calculated. See Figure 1.


Figure 1: f = 3 units and g = 4 units
and so area is  3 x 4 / 2 = 6 square units

Here is a permalink to a SageMath algorithm that will calculate the area form the coordinates of the input vertices. The second example in the video involved the vertices (2, 3), (5, 7) and (10, -5). This produces the following matrix:
$$ \begin{bmatrix} 2 & 3 & 1 \\ 5 & 7 & 1\\ 10 & -5 & 1 \end{bmatrix} $$This matrix has a determinant of -56 and we take half of its absolute value to calculate the area of the triangle to be 28 square units. See Figure 2.


Figure 2

The video goes through the process of finding the lengths of f, g and h using the Pythagorean theorem and then using Heron's formula to find the area. This is done to confirm that matrix/determinant method actually works so I won't reproduce that here. Suffice to say that once the matrix M is constructed, we can say that:$$\text{Area of Triangle }=\frac{1}{2} \times \text{ det } |M|$$This got me thinking about quadrilaterals and whether this method could be extended to find the area of quadrilaterals but it doesn't appear to. The quadrilateral would need to be broken up into two triangles and the area of each calculated using the matrix/determinant method.

Sunday, 10 July 2016

Pythagorean Numbers

Of course I knew about Pythagorean triples and even primitive Pythagorean triples but I hadn't heard of Pythagorean numbers. The term emerged when I was researching my daily number, 24570, using the OEIS. This number was paired with 24576 and the smaller followed the larger in sequence A228875: Pairs of Pythagorean numbers differing by 6. This difference is apparently the minimum possible. The sequence started:
24, 30, 54, 60, 210, 216, 330, 336, 480, 486, 540, 546, 720, 726, 750, 756, 1344, 1350, 1710, 1716, 2160, 2166, 8664, 8670, 8970, 8976, 10080, 10086, 10290, 10296, 12144, 12150, 15600, 15606, 18144, 18150, 24570, 24576, 28560, 28566, 30240, 30246, 34650, 34656
This didn't really explain what constituted a Pythagorean number. However, as I discovered here, the definition of such as number is that it is the area of a Pythagorean triangle and primitive Pythagorean number is the area of a primitive Pythagorean triangle. Sequence A009111 provides an ordered list the areas of Pythagorean triangles, effectively providing a list of the initial Pythagorean numbers. Oddly, 24570 turns out to be 294th and 295th in this list. The reason for this will soon become clear.

While I knew that 24570 was a Pythagorean number and thus the area of a Pythagorean triangle, I didn't know the integer sides that comprised such a triangle but it seemed that there were two possible triangles because the number occupied two positions in the list. It took a little fiddling around in WolframAlpha to come up with the numbers.


Thus the triangles were 84, 585, 591 and 180, 273, 327. The number 24570 is not a primitive Pythagorean number because the members of each triplet are divisible by three. The equivalent Pythagorean triplets are 28, 195, 197 and 60, 91, 109.