You are currently browsing the category archive for the ‘investigation’ category.

**Project Euler: Coding to Solve Maths Problems**

Project Euler, named after one of the greatest mathematicians of all time, has been designed to bring together the twin disciplines of mathematics and coding. Computers are now become ever more integral in the field of mathematics – and now creative coding can be a method of solving mathematics problems just as much as creative mathematics has always been.

The first problem on the Project Euler Page is as follows:

*If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.*

*Find the sum of all the multiples of 3 or 5 below 1000.*

This is a reasonably straight forward maths problem which we can solve using the summation of arithmetic sequences (I’ll solve it below!) but more interestingly is how a computer code can be written to solve this same problem. Given that I am something of a coding novice, I went to the Project Nayuki website which has an archive of solutions. Here is a slightly modified version of the solution given on Project Nayki, designed to run in JAVA:

The original file can be copied from here, I then pasted this into an online JAVA site jdoodle. The only modification necessary was to replace:

*public final class p001 implements EulerSolution* with *public class p001*

Then after hitting execute you get the following result:

i.e the solution is returned as 233,168. Amazing!

But before we get carried away, let’s check the answer using some more old fashioned maths. We can break down the question into simply trying to find the sum of multiples of 3 under 1000, the sum of the multiples of 5 under 1000 and then subtracting the multiples of 15 under 1000 (as these will have been double counted). i.e:

(3 + 6 + 9 + … 999) + (5 + 10 + 15 + … 995) – (15 + 30 + 45 + …990)

This gives:

S_333 = 333/2 (2(3)+ 332(3)) = 166,833

+

S_199 = 199/2 (2(5) + 198(5)) = 99, 500

–

S_66 = 66/2 (2(15) +65(15) = 33, 165.

166,833 + 99, 500 – 33, 165 = 233, 168 as required.

Now that we have seen that this works we can modify the original code. For example if we replace:

if (i % 3 == 0 || i % 3 == 0)

with

if (i % 5 == 0 || i % 7 == 0)

This will find the sum of all the multiples of 5 or 7 below 1000. Which returns the answer 156,361.

Replacing the same line with:

if (i % 5 == 0 || i % 7 == 0 || i % 3 == 0)

will find the sum of all the multiples of 3 or 5 or 7 below 1000, which returns the answer 271,066. To find this using the previous method we would have to do:

Sum of 3s + Sum of 5s – Sum of 15s + Sum of 7s – Sum of 21s – Sum 35s – Sum of 105s. Which starts to show why using a computer makes life easier.

This would be a nice addition to any investigation on Number Theory – or indeed a good project for anyone interested in Computer Science as a possible future career.

**Measuring the Distance to the Stars**

This is a very nice example of some very simple mathematics achieving something which for centuries appeared impossible – measuring the distance to the stars. Before we start we need a few definitions:

- 1 Astronomical Unit (AU) is the average distance from the Sun to the Earth. This is around 150,000,000km.
- 1 Light Year is the distance that light travels in one year. This is around 9,500,000,000,000km. We have around 63000AU = 1 Light Year.
- 1 arc second is measurement for very small angles and is 1/3600 of one degree.
- Parallax is the angular difference in measurement when viewing an object from different locations. In astronomy parallax is used to mean the half the angle formed when a star is viewed from opposite sides of the Earth’s solar orbit (marked on the diagram below).

With those definitions it is easy to then find the distance to stars. The parallax method requires that you take a measurement of the angle to a given star, and then wait until 6 months later and take the same measurement. The two angles will be slightly different – divide this difference by 2 and you have the parallax.

Let’s take 61 Cyngi – which Friedrick Bessel first used this method on in the early 1800s. This has a parallax of 287/1000 arc seconds. This is equivalent to 287/1000 x 1/3600 degree or approximately 0.000080 degrees. So now we can simply use trigonometry – we have a right angled triangle with opposite side = 1 AU and angle = 0.0000080. Therefore the distance is given by:

tanΦ = opp/adj

tan(0.000080) = 1/d

d = 1/tan(0.000080)

d = 720000 AU

which is approximately 720000/63000 = 11 light years away.

That’s pretty incredible! Using this method and armed with nothing more than a telescope and knowledge of the Earth’s orbital diameter, astronomers were able to judge the distance of stars in faraway parts of the universe – indeed they used this method to prove that other galaxies apart from our own also existed.

**Orion’s Belt**

The constellation of Orion is one of the most striking in the Northern Hemisphere. It contains the “belt” of 3 stars in a line, along with the brightly shining Rigel and the red super giant Betelgeuse. The following 2 graphics are taken from the great student resource from the Royal Observatory Greenwich:

The angles marked in the picture are in arc seconds – so to convert them into degrees we need to multiply by 1/3600. For example, Betelgeuse the red giant has a parallax of 0.0051 x 1/3600 = 0.0000014 (2sf) degrees. Therefore the distance to Betelgeuse is:

tanΦ = opp/adj

tan(0.0000014) = 1/d

d = 1/tan(0.0000014)

d = 41,000,000 AU

which is approximately 41,000,000/63000 = 651 light years away. If we were more accurate with our rounding we would get 643 light years. That means that when we look into the sky we are seeing Betelgeuse as it was 643 years ago.

This post is inspired by the Quora thread on interesting functions to plot.

**The butterfly**

This is a slightly simpler version of the butterfly curve which is plotted using polar coordinates on Desmos as:

Polar coordinates are an alternative way of plotting functions – and are explored a little in HL Maths when looking at complex numbers. The theta value specifies an angle of rotation measured anti-clockwise from the x axis, and the r value specifies the distance from the origin. So for example the polar coordinates (90 degrees, 1) would specify a point 90 degrees ant clockwise from the x axis and a distance 1 from the origin (i.e the point (0,1) in our usual Cartesian plane).

2. **Fermat’s Spiral**

This is plotted by the polar equation:

The next 3 were all created by my students.

3. **Chaotic spiral (by Laura Y9)**

I like how this graph grows ever more tangled as it coils in on itself. This was created by the polar equation:

4. **The flower (by Felix Y9)**

Some nice rotational symmetries on this one. Plotted by:

5. **The heart (by Tiffany Y9)**

Simple but effective! This was plotted using the usual x,y coordinates:

You can also explore how to draw the Superman and Batman logos using Wolfram Alpha here.

**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.

This is an example of how an investigation into area optimisation could progress. The problem is this:

A farmer has 40m of fencing. What is the maximum area he can enclose?

**Case 1: The rectangle:**

Reflection – the rectangle turns out to be a square, with sides 10m by 10m. Therefore the area enclosed is 100 metres squared.

**Case 2: The circle:**

Reflection: The area enclosed is greater than that of the square – this time we have around 127 metres squared enclosed.

**Case 3: The isosceles triangle:**

Reflection – our isosceles triangle turns out to be an equilateral triangle, and it only encloses an area of around 77 metres squared.

**Case 4, the n sided regular polygon**

Reflection: Given that we found the cases for a 3 sided and 4 sided shape gave us the regular shapes, it made sense to look for the n-sided regular polygon case. If we try to plot the graph of the area against n we can see that for n ≥3 the graph has no maximum but gets gets closer to an asymptote. By looking at the limit of this area (using Wolfram Alpha) as n gets large we can see that the limiting case is the circle. This makes sense as regular polygons become closer to circles the more sides they have.

**Proof of the limit using L’Hospital’s Rule**

Here we can prove that the limit is indeed 400/pi by using L’Hospital’s rule. We have to use it twice and also use a trig identity for sin(2x) – but pleasingly it agrees with Wolfram Alpha.

So, a simple example of how an investigation can develop – from a simple case, getting progressively more complex and finishing with some HL Calculus Option mathematics.