You are currently browsing the tag archive for the ‘geometry’ tag.

**The Shoelace Algorithm to find areas of polygons**

This is a nice algorithm, formally known as Gauss’s Area formula, which allows you to work out the area of any polygon as long as you know the Cartesian coordinates of the vertices. The case can be shown to work for all triangles, and then can be extended to all polygons by first splitting them into triangles and following the same approach.

Let’s see if we can work out the algorithm ourselves using the construction at the top of the page. We want the area of the triangle (4), and we can see that this will be equivalent to the area of the rectangle minus the area of the 3 triangles (1) (2) (3).

Let’s start by adding some other coordinate points for the rectangle:

Therefore the area of the rectangle will be:

(1) + (2) +(3) +(4): (x_{3}-x_{2})(y_{1}-y_{3})

And the area of triangles will be:

(1): 0.5(x_{3}-x_{2})(y_{2}-y_{3})

(2): 0.5(x_{1}-x_{2})(y_{1}-y_{2})

(3): 0.5(x_{3}-x_{1})(y_{1}-y_{3})

Therefore the area of triangle (4) will be:

Area = (x_{3}-x_{2})(y_{1}-y_{3}) – 0.5(x_{3}-x_{2})(y_{2}-y_{3}) – 0.5(x_{1}-x_{2})(y_{1}-y_{2}) – 0.5(x_{3}-x_{1})(y_{1}-y_{3})

Therefore we have our algorithm! Let’s see if it works with the following coordinates added:

x_{1 } = 2 x_{2 } = 1 x_{3 } = 3

y_{1 } = 3 y_{2 } = 2 y_{3 } = 1

Area = (x_{3}-x_{2})(y_{1}-y_{3}) – 0.5(x_{3}-x_{2})(y_{2}-y_{3}) – 0.5(x_{1}-x_{2})(y_{1}-y_{2}) – 0.5(x_{3}-x_{1})(y_{1}-y_{3})

Area = (3-1)(3-1) – 0.5(3-1)(2-1) – 0.5(2-1)(3-2) – 0.5(3-2)(3-1)

Area = 4 – 1 – 0.5 – 1 = 1.5 units squared

We could check this using Pythagoras to find all 3 sides of the triangle, followed by the Cosine rule to find an angle, followed by the Sine area of triangle formula, but let’s take an easier route and ask Wolfram Alpha (simply type “area of a triangle with coordinates (1,2) (2,3) (3,1)). This does indeed confirm an area of 1.5 units squared. Our algorithm works. We can of course simplify the area formula by expanding brackets and simplifying. If we were to do this we would get the commonly used version of the area formula for triangles.

**The general case for finding areas of polygons**

The general formula for the area of an n-sided polygon is given above.

For a triangle this gives:

For a quadrilateral this gives:

For a pentagon this gives:

You might notice a nice shoelace like pattern (hence the name) where x coordinates criss cross with the next y coordinate along. To finish off let’s see if it works for an irregular pentagon.

If we arbitrarily assign our (x_{1}, y_{1}) as (1,1) and then (x_{2}, y_{2}) as (3,2), and continue in a clockwise direction we will get the following:

area = absolute of 0.5( 1×2 + 3×4 + 3×1 + 4×0 + 2×1 – 3×1 – 3×2 – 4×4 – 2×1 – 1×0)

area = 4.

Let’s check again with Wolfram Alpha – and yes it does indeed have an area of 4.

It could be a nice exploration task to take this further and to explore how many different methods there are to find the area of polygons – and compare their ease of use, level of mathematics required and aesthetic appeal.

**A geometric proof for the Arithmetic and Geometric Mean**

There is more than one way to define the mean of a number. The arithmetic mean is the mean we learn at secondary school – for 2 numbers a and b it is:

(a + b) /2.

The geometric mean on the other hand is defined as:

(x_{1}.x_{2}.x_{3}…x_{n})^{1/n}

So for example with the numbers 1,2,3 the geometric mean is (1 x 2 x 3)^{1/3}.

With 2 numbers, a and b, the geometric mean is (ab)^{1/2}.

We can then use the above diagram to prove that (a + b) /2 ≥ (ab)^{1/2} for all a and b. Indeed this inequality holds more generally and it can be proved that the Arithmetic mean ≥ Geometric mean.

Step (1) We draw a triangle as above, with the line MQ a diameter, and therefore angle MNQ a right angle (from the circle theorems). Let MP be the length a, and let PQ be the length b.

Step (2) We can find the length of the green line OR, because this is the radius of the circle. Given that the length a+b was the diameter, then (a+b) /2 is the radius.

Step (3) We then attempt to find an equation for the length of the purple line PN.

We find MN using Pythagoras: (MN)^{2} = a^{2} +x^{2}

We find NQ using Pythagoras: (NQ)^{2} = b^{2} +x^{2}

Therefore the length MQ can also be found by Pythagoras:

(MQ)^{2} = (MN)^{2 } + (NQ)^{2}

(MQ)^{2 } = a^{2} +x^{2} + b^{2} +x^{2}

But MQ = a + b. Therefore:

(a + b)^{2 } = a^{2} +x^{2} + b^{2} +x^{2}

a^{2}+ b^{2} + 2ab = a^{2} +x^{2} + b^{2} +x^{2}

2ab = x^{2} +x^{2}

ab = x^{2}

x = (ab)^{1/2}

Therefore our green line represents the arithmetic mean of 2 numbers (a+b) /2 and our purple line represents the geometric mean of 2 numbers (ab)^{1/2}. The green line will always be greater than the purple line (except when a = b which gives equality) therefore we have a geometrical proof of our inequality.

There is a more rigorous proof of the general case using induction you may wish to explore as well.

**Circular inversions II**

There are some other interesting properties of circular inversions. One of which is that they preserve the “angle” between intersecting circles. Firstly, how can circles have an angle between them? Well, we draw 2 tangents to both the circles at the point of intersection, and then measure the angle between the 2 tangents:

Therefore we can see that the “angle” between these 2 circles is 59.85 degrees. If we then carry out a circular inversion we see the following:

The inversion has been done with regards to the black circle centred around the origin. The red and blue circles are mapped from outside the the black circle onto circles inside the black circle. Now if we do the same as before – by finding the 2 tangents at the point of intersection, we find that the angle has remained the same – it is still 59.85 degrees.

It is also possible to find circles which remain unchanged under the inversion. This happens when a circle is orthogonal (at a 90 degree angle) to the circle with which the inversion is being carried out.

The small circle has an angle of 90 degrees with the large circle, and therefore when we invert with respect to the large circle, we map the small circle onto itself.

The question is, why is all this useful? Well, an entire branch of mathematics (non-Euclidean geometry) is concerned with being able to map points in our traditional Euclidean worldview (the geometry of high school triangles, parallel lines and circle theorems) to different geometrical systems entirely. Circular inversion is a good introduction to this concept.

Also, circular inversion can sometimes make studying mathematical shapes easier to understand and explain. For example, (from Wolfram):

It would be very difficult to explain mathematically how the shape above is generated – whilst there are patterns, it is not obvious how to explain them. However, if we invert this shape through a circular inversion (with the circle at centre of the image) then we get the following:

This is the image inside the circle – and now we can clearly see the pattern behind the generated image. So, inversion has a lot of potential for simplifying geometrical problems.

**Visualising Algebra Through Geometry**

This picture above is a fantastic example of how we can use geometry to visualise an algebraic expression. It’s taken from Brilliant – which is a fantastic new forum for sharing maths puzzles. This particular puzzle was created and uploaded by Arron Kau. The question is, which of the following mathematical identities does this image represent?

See if you can work it out! I will put the answer in white text at the bottom of the post – highlight it to reveal the solution.

Another example of the power of geometry in representing mathematical problems is provided by Ian Stewart’s Cabinet of Mathematical Curiosities. The puzzle itself is pretty famous:

*A farmer wants to cross a river and take with him a wolf, a goat, and a cabbage. There is a boat that can fit himself plus either the wolf, the goat, or the cabbage. If the wolf and the goat are alone on one shore, the wolf will eat the goat. If the goat and the cabbage are alone on the shore, the goat will eat the cabbage. How can the farmer bring the wolf, the goat, and the cabbage across the river?*

The standard way of solving it is trial and error with some logic thrown in. However, as Ian Stewart points out, we can actually utilise 3 dimensional geometry to solve the puzzle. We start with a 3D wolf-goat-cabbage (w,g,c) space (shown in the diagram). All 3 start at (0,0,0). 0 represents this side of the bank, and 1 represents the far side of the bank. The target is to get therefore to (1,1,1). In (w,g,c) space , the x direction represents the wolf’s movements, the y direction the goat and z the cabbage. Therefore the 8 possible triplet combinations are represented by the 8 vertices on a cube.

We can now cross out the 4 paths:

(0,0,0) to (1,00) as this leaves the goat with the cabbages

(0,0,0) to (0,0,1) as this leaves the wolf with the goat

(0,1,1) to (1,1,1) as the farmer would leave the goat and cabbage alone

(1,1,0) to (1,1,1) as the farmer would leave the wolf and goat alone.

which reduces the puzzle to a geometric problem – where we travel along the remaining edges – and the 2 solutions are immediately evident.

(eg. (0,0,0) – (0,1,0) – (1,1,0) – (1,0,0) – (1,0,1)- (1,1,1) )

What’s really nice about this solution is that it shows how problems seemingly unrelated to mathematics can be “translated” in mathematics – and also it shows how geometrical space can be used for problem solving.

Solution to the initial puzzle, highlight to reveal: The answer is the third option – 1^{3} + 2^{3}…. = (1+2+….)^{2}. This is quite a surprising identity. You can see it by seeing that there are (for example) 2 squares of length 2 – this gives you a total area of 2x2x2 = 2^{3}. Adding all the squares will give you the same area as a square of sides (1+2+3….)(1+2+3….) – hence the result.