The Prime Number Theorem explained

People have asked me to explain how Gauss’ Prime Number Theorem actually works. I mentioned it in my “How to Find Prime Numbers” post, but never explained it, so here is a short and (relatively) simple guide.

To begin with, let’s take a look at the trends in the density of primes up to a certain integer. We can find the density of primes by calculating p / x, where x is the number of integers and p is the number of primes from 1 to x. If we make a table of the density to each power of 10, it will look like this:

x p Density
10 4 40%
100 25 25%
1,000 168 16.8%
10,000 1,229 12.29%
100,000 9,592 9.592%
1,000,000 78,498 7.8498%
10,000,000 664,579 6.64579%
100,000,000 5,761,455 5.761455%

You can see that the density is always decreasing, but the rate is also decreasing. This is very similar to a logarithmic pattern. In fact, if we plot the graph of y = ln(x), mirror it along the horizontal axis so that it becomes y = 1 / ln(x), and compare it to the graph of the density of prime numbers, there is a striking similarity.

Green:  y = 1 / ln(x) Blue: Density of primes

Green: y = 1 / ln(x)
Blue: Density of primes

You’ll find that as the value of x increases, the correlation between the two graphs becomes stronger and stronger. The density of primes follows an almost instinctive natural curve.

This link makes it possible for us to predict the density of primes up to any value of x with the formula 1 / ln(x). The higher the value of x, the higher the accuracy of the prediction. To find the expected number of primes, you only need to find the area under the graph of the density, which can be found using integration. Gauss refined this a little to create the logarithmic integral Li(x), which gives a slightly more accurate estimate for the lower values of x. I ought to give Adrien-Marie Legendre some credit here as well, because he and Gauss both independently conjectured Li(x) at around the same time. Gauss is generally more associated with this, however, mainly because of his legacy.

l talk about how this links into the Riemann hypothesis (and more) in my previous post, which you can read here.

Thank you for reading.

-Ollie James

Trigonometry and Life

We’re all familiar with the concept of trigonometry. It’s most commonly used, of course, to determine the angles and lengths in right-angled triangles. Provided you know any three side lengths or angles (including the right angle) in a right-angled triangle, you can easily use sin, cos and tan to work out the sides and angles you don’t know.

You'll remember these basic trigonometric formulae from school.

You’ll remember these basic trigonometric formulae from school.

You can also work out all the sides and angles in any triangle using the sine rule

Diagram of what each unknown corresponds to.

Screen Shot 2015-02-10 at 17.48.34

and the cosine rule.

Cosine rule

Alternatively, you can simply dissect any triangle into two right-angled triangles and use SOHCAHTOA from there.

Examples of one triangle dissected into two right-angled triangles.

Examples of one triangle dissected into two right-angled triangles.

However, the amount of people whose knowledge of trigonometry stops there surprises me. To many people, sin, cos and tan are just buttons on a calculator. The nature of simply plugging in values and receiving an irrational number is somewhat menial, particularly if you have little of an idea of what is happening. Sadly, this is what a lot of people have experienced to be trigonometry.


The reality is that the functions of sine, cosine and tangent are embedded in the foundations of modern mathematics and, as you’ll discover, the world around us. First, you must understand that each of these functions has its own graph.


Sine graph 


Cosine graph


Tangent graph

These graphs act as a reference every time you use a trigonometric function. Whenever you type ‘sin(90)’ into your calculator, for example, the calculator will find 90° on the x-axis and return whatever y value the sine graph has at that point; hence why sin(90) = 1.

Now, that’s all very nice, but where exactly do these graphs come from? The answer may be a surprise to some people, considering that the trigonometric experiences of many focus around triangles. In fact, all of the trigonometric functions are created from circles.

The sine graph is created by plotting the angle of the radius of a circle against the y-coordinate. The cosine graph is created in exactly the same way, except the angle is plotted against the x-coordinate. If you’re confused, it makes a lot more sense visually.

Sine is the horizontal graph, cosine is the vertical one.

Sine is the horizontal graph, cosine is the vertical one.

You may have noticed that the cosine graph is exactly the same shape as the sine graph, except in the GIF it is rotated 90°. This is exactly the reason why, when the graphs are plotted on grids as above, the cosine graph is equivalent to the sine graph, omitting the fact that it is shifted, or translated, 90° to the left. Additionally, this is how the name ‘cosine’ appeared; the two coincide, they cohere, they coexist.

Tangent, however, is a different story. It is called tangent because the graph is created by drawing a circle adjacent to the y-axis, so that the axis is a tangent to the circle, and then plotting the points where the extended radius of the circle would touch the tangent. Once again, this is much more easily explained visually.Tangent animation

Tan diagram

The characteristic that sets the tangent graph apart the most is that it includes asymptotes. An asymptote is the singularity on a graph that cannot possibly contain any values. On either side however, lines become exponentially closer to it but never actually touch it. This happens because as you can see in the GIF, when the radius is at 90° from its initial position (vertical, in other words), it is parallel to the tangent. If you were to scroll up and try to find the point of intersection between the tangent and the radius, you would be scrolling for a very long time; there is no point of intersection, hence why there are no values exactly on the asymptotes.

I understand that I’m not exactly a master of clarity, so I’ll try to explain in a more logical way why there is no tan(90).

Let’s go back to SOHCAHTOA. The last of the three formulae, you’ll recall, is:

Tan formula

To try out tan(90), we’ll have to make θ equal to 90°. That’s easy enough.

A triangle in which two angles equal 90°.

A triangle in which two angles equal 90°.

Now we’ll need to make this back into a triangle. The only thing we can do to do that is to make the adjacent side length equal 0.

We've shortened the adjacent so that the triangle has no gaps between edges.

This is now what our triangle looks like. Isn’t it wonderful?

Next, we need to input the values back into the SOHCAHTOA formula.

Tan 90 formula

Oh dear. Dividing by zero never ends well, so let’s not attempt it. It appears that a value for tan(90) simply doesn’t exist.

You can see from the tangent graph that it’s not only at 90° that an asymptote appears. Each of the graphs is a repeating pattern, and the length of one cycle on a tangent graph is 180°. In other words, you have to travel 180° along the x-axis to get from a certain point in one pattern to the same point in the next.

A 'zoomed out' tangent graph showing 180° between x values for any y value.

A ‘zoomed out’ tangent graph showing 180° between x values for any y value.

This is why the asymptotes appear at ±90°, ±270°, ±540°, etc. The difference between each one is 180°.


So we’ve talked about the main three trigonometric functions and their respective graphs. You may have seen the graphs before, or you may not have. However, you’re less likely to know that these graphs are actually scattered around us in various aspects of everyday life.

Let’s start with a spring. Springs can be found in all manner of items, particularly in physical mechanisms. However, if you look at a spring directly from the side, this is what it will look like.

Spring horizontal

Oh look, a sine graph! What happens if we rotate our view 90° about the spring so that we’re looking at it from above?

Spring vertical

A cosine graph appears. Not only is this a real-world visual representation of both graphs, but it also demonstrates that a cosine graph is simply a sine graph at a displacement of 90°. You can try it yourself.

As you’d expect, this can be observed in any helical object (meaning any object pertaining to the form of a helix). Common examples include drill bits, spiral staircases, and any object with a screw mechanism, such as a water bottle.

If you’re interested, the mathematical equations of the helix are as follows:

x = A cos t

This means that when a helix is observed from the x direction, it is simply a cosine graph that is vertically enlarged by A and horizontally enlarged by the reciprocal of t.

y = A sin t

This means that when the same helix is observed from the y direction, it is a sine graph enlarged to exactly the same scale as the cosine graph from the x direction.

z = b t

This just means that the helix has b length in the z direction. When viewed from the z direction, all you will see is a circle when radius of length A.


You can also map tides using a sine graph very simply. I’ve created one to show you now.

An example of a graph of tides on a beach.

An example of a graph of tides on a beach.

In this instance, we can say that the x-axis represents time of day in hours, and the y-axis represents height of tide in metres. Tides work on a 12-hour cycle, which you can see from the graph. In fact (disregarding any outliers which might affect the sea levels temporarily, such as a storm), tides will follow the exact pattern of a sine wave when plotted on a height-time graph.


Tangent graphs are also embedded in much of the real world, although they can’t exactly be observed in the same way that sine and cosine graphs can due to their asymptotes. However, their properties are often present.

Let’s revisit the spring. When a force is applied to the spring on one end, it is compressed, provided the force is in the direction of the spring. The more force is applied, the more compressed the spring becomes.

What happens if we draw a graph of the length of the spring against the force applied?

Graph force against length

In this instance, the x-axis represents length of the spring in centimetres, and the y-axis represents force applied in Newtons.

Spring force diagram

On the graph, we get an asymptote, because you’d need an infinite amount of force to compress the spring so much that it had 0 length. It’s very similar to a tangent graph. In fact, the graph you’re seeing actually is a transformed tangent graph, with the equation y = tan(-x +90). The –x mirrors the graph horizontally (over the y-axis), while the +90 translates the graph 90° to the left so that the asymptote occurs when x = 0. It’ll become clearer when I show a wider perspective of the graph.

Graph of y=tan(-x+90)

Another application of tangent graphs is to do with the motion of pendulums. Imagine a small ball hanging from the end of a string, which is attached to the roof of the interior of a car.

Pendulum 1

Once the car starts accelerating, the pendulum will swing in the opposite direction of motion. The equation that determines the angle between the pendulum and the vertical axis is:

Pendulum 2

Does this equation look familiar? That’s right, it’s the tangent formula from SOHCAHTOA! We’ve simply replaced ‘opposite’ with ‘ma’ and ‘adjacent’ with ‘mg’.

This equation also shows us why it’s impossible for the pendulum to be parallel to the roof (ignoring the fact that the ball is in the way). If the pendulum were parallel to the roof, then θ would be equal to 90°. As we know, there is no value for tan(90). To make it possible, either a would have to equal ∞, or m would have to equal either 0 or ∞, all of which are beyond the laws of physics. (Quantum theory may disagree, but we won’t get into that right now.)

Of course, you could just go into space, where g would equal 0, but then the formula wouldn’t apply there. You can’t cheat maths.


To finish, I’ll just leave this link here. It’s a brilliant interactive resource that lets you visualise the three basic trigonometric graphs (plus their hyperbolic counterparts) and how they are related to the circle. If you didn’t understand something in my explanations, then hopefully this will clear things up.

By the way, the scale is in radians as opposed to degrees. If you don’t know, radians are a way of expressing angles in a circle relative to π. If you delve further into them they become thoroughly interesting, but to understand the graph all you need to know is that π radians = 180°.

Thank you for reading.

-Ollie James