# Calculus

Calculus is a game played by mathematicians and physicists, the object of which is to find the rate at which something changes or the area or volume of a curved shape. Of course, they do not think of it as a game - they prefer to call it mathematical analysis.

Calculus is all about turning one set of numbers and letters (called a function) into another set of numbers and letters, just like using a cipher to codify information. There are two 'ciphers' that you can use - one is called differential calculus, or differentiation; the other, integral calculus, or integration. Functions are continually integrated or differentiated and play can continue until you reach a single number1. If you differentiate a function and then integrate it, you get back to where you started; and likewise if you integrate a function and then differentiate it, you will also return to where you started. This is the most important rule of the game you should remember, and is fittingly called the fundamental theorem of calculus.

Calculus can be interchangeably referred to as 'the calculus', depending on how much significance you feel like ascribing to it.

### History

We have the Ancient Greeks to thank for the basis of integral calculus - Archimedes used a basic form of it for calculating the area under curves, around 3BC. Integration was revived in the Renaissance and used by people like Johannes Kepler for analysis of the orbits of planets2. Differential calculus was first explored by Pierre de Fermat3, who confided his method of finding the maximum and minimum points of curves to René Descartes4. We'll look at this method ourselves later.

Like many things in maths and physics, the full and unadulterated treatment of the topic was formulated by two people independently and at roughly the same time. One of them was Gottfried Leibniz; the other, Sir Isaac Newton. Unfortunately, Newton delayed publishing his ideas, and so Leibniz, who published in 1684, was initially given all the credit for calculus. His notation and his name for it (calculus) stuck with us (Newton called it fluxions). Newton suspected Leibniz of stealing his work, though modern historians have reached a consensus to the contrary.

At the time however, mathematicians were feuding over who had invented calculus, and development of the maths was set back. When the hostilities had abated, the calculus was brought up to the rigour expected of contemporary mathematics. The work of Augustin Cauchy in the early 19th Century is notable for providing greater insight into the calculus in a modern context.

Today, calculus is one of the most indispensable methods of calculation that exists, and though we describe it here as a 'game' (for it allows us to solve difficult problems with similar logic to that of game-play), the methods can be applied to problems not just in mathematics and physics, but in all sciences, including kinematics (and hence engineering), as well as computing, economics and statistics. Uses of calculus are myriad - everything from predicting the weather, through describing ecological population changes, to compressing data. Anything that changes can be mapped on a graph - and since change is everywhere, calculus, as the most accurate way to analyse graphs, can describe almost anything.

### Etymology

What do toothpaste, Romans and the most successful mathematical tool in the universe have in common? They all derive from calx, the Latin for limestone. The Romans (and Greeks) used pebbles for their arithmetical studies, and 'calculus' literally means 'pebble' in Latin. It is also similar to the Latin verb 'calculare', which unsurprisingly means 'to calculate'.5 A calculus is also a medical term for a stone - such as that causing kidney stones.

### Differential Calculus

To explain this, we shall use a 'real world' example, but when you get really good at this game, you can dispense with the 'real world' and jump straight into the maths. You might want to try it as an alternative to counting sheep.

You are left alone in the cockpit of a spacecraft, and you can't help fiddling with the controls. You cruise five kilometres in ten minutes at a constant speed, then you hit a button and suddenly the craft accelerates, zooming over a hundred kilometres in the next ten minutes, at which point you find the control to stop it. We assume that the craft has undergone constant acceleration.

Using this information, we can represent your movement on a distance-time graph, in which we put time along the bottom and distance up the side. For the first ten minutes, the line on the graph would be straight; for the next 25, it would steadily get steeper because when you accelerate, you cover a greater distance in the second minute of your acceleration than in the first, so the line curves upward.

Anyway, you're fined for speeding, but you're convinced you're in the clear. You must therefore consult your graph and find your maximum speed, in order to prove your case. You therefore need to analyse the highest point on the graph.

Going at a constant speed, covering five kilometres in ten minutes means a speed of half a kilometre per minute, or 30 km/h. This is the same as the gradient of the line on your graph. The gradient of a line is how steep it is, and is equal to its vertical height divided by its horizontal distance - in this case, five divided by ten. If a road has this gradient, for example (it would probably be marked as 50%), then it means that for every ten units of direction you go in the horizontal direction, you'll go five of the same units in the vertical6. The reason that this particular line's gradient yields the speed is because speed is equal to distance divided by time, which is the same as the vertical (y-axis) divided by the horizontal (x-axis).

Your highest speed will have been reached during your period of acceleration. Again, we can find this speed by looking at the gradient of the line. However, the curve that represents acceleration does not have a straightforward gradient; a curve is made up of an infinite number of tiny, infinitesimally small straight lines. What you're trying to find is the gradient of this tiny straight line at 20 minutes. Obviously, since your speed is constantly increasing when you accelerate, the gradients of these lines is constantly increasing too, which is what creates the gradually steeper curve.

If you analyse this curve, you will see that after two minutes of accelerating, you have travelled four kilometres. After three minutes, you have gone nine kilometres; after four minutes, you've gone 4 x 4 = 16 kilometres; after five, 5 x 5 = 25 kilometres. We can generalise the situation to x minutes (because time is on the x axis): after x minutes you've travelled x times x kilometres, or x2 kilometres. We can generalise the distance by calling it y (because distance is plotted on the y axis)7. Therefore we can say that y = x2, which in this example means that you can find the value of the distance travelled by squaring the value of the time taken. This is called the function of the graph.

#### Functions

A function is a method of torturing a number in order to get another number by applying various painful operations to it. In this example, the function y = x2 tells us that the number, which we blindfold with an x, is being squared to give a number called y.

We could make an approximation of the speed you've gone by using speed=distance/time. If we imagine that the line between x=8 and x=10 is straight, rather than curved, we can form a triangle whose base has a length of 10 - 8 = 2, and whose height is 100 - 64 = 36. We then do the vertical divided by the horizontal: 36 / 2 = 18. The proper notation is this:

Δy / Δx = 18

The Greek letter Δ means 'difference', so the notation literally means 'the difference in y over the difference in x'.

The closer together the points we choose are, the more accurate our result will be, but we'll only get 100% accuracy when the distance between the two points is zero.

This is where the game begins, because by using good old calculus, you can obtain a simple formula that tells you the gradient of those tiny tiny lines at any point on the curve. This formula is called the derivative or, more helpfully, the gradient function. The process of finding the derivative is what is known as differentiation. The gradient of the curve at that point is also the gradient of the tangent to the curve at that point, which is a line that touches the curve only at that point.

It's high time we learned the rules of the game, then, so that we can get out of this fix.

#### The Rules

If you've got a very simple function like y = 0.5x (which is the constant speed example we had above), this means that the y value of any point on the line is equal to 0.5 times x (or half of x). In this case, the derivative (or gradient) is simply 0.5. In other words, just shun the x. The proper notation is this:

dy / dx = 0.5

But you may also see:

y' = 0.5, or f'(x) = 0.5 where f(x) = 0.5x.

(Here, the little apostrophe is pronounced 'prime'.)

If you wanted to, you could call the time t instead of x and the distance could be called s instead of y. You could then put ds / dt, which means 'differentiate s with respect to t. What that tells you is that you have started with a function that gives s (the distance) and that you should apply the rules of differentiation to t.

When the x has a power (or index number, which is the little number at the top), such as in x2, you grab hold of the power and put it before the x, then you reduce the power by 1. In this example, we just put the 2 at the front and reduce the power by one, giving us 2x1. Anything to the power of 1 is itself, so we can write that as 2x.

If you have something like 4x3, then you do the same thing: bring the little number to the front and reduce the power by one, which would give you 3 4x2, except this is not 34x2, because in maths, when two different numbers are next to each other, it means they're being multiplied together, so we actually get 12x2.

If you have 5x6, then, the derivative is 6 x 5 x x6-1, which is 30x5.

To re-iterate: when x has a power, just multiply it by the number in front of the x (called the coefficient), and reduce the power by one.

If you have something like y = 3/x, then you need an extra step. Put down the number at the top of the division (the numerator), then put x-1, then differentiate as above. In this case, we get y = 3x-1, which yields -3x-2. This isn't pretty, so you should put -3/x2.

Those are some of the most difficult rules. The easier ones are these:

• If you've got sinx, the derivative is cosx

• If you've got cosx, you get -sinx

• If you've got tanx, you get sec2x, which is (1/cosx)2

• If you've got logx, you get 1/x

• If you've got ex, leave it be!8 The derivative is also ex.

• If you've just got a number - and no x is involved - the derivative is 0.

There are a lot more rules than this, of course. The game gets interesting when many of these functions are combined. For example, how do you differentiate y = 5x2 + cosx + 4 ?

You simply go through each bit of it and apply the relevant rule in turn. 5x2 becomes 10x, as we have seen; cosx becomes -sinx; and 4 becomes zero. So the answer is 10x - sinx.

The function that described our acceleration in the rocket, y = x2, was sorted out long ago when we found that the derivative is equal to 2x.

So what can we do with this? Well, we now know that at all points on our graph, including the maximum, our speed was equal to 2 times the time value (or speed = 2x). Ten minutes after we started accelerating, the time value was 10 (ie, x = 10). At this moment, the gradient (your speed) is found by multiplying 2 x 10, which equates to 20 kilometres per minute, or 1800 km/h. However, because we were already travelling at 30 km/h when we started accelerating, this offsets our final speed. The final speed is therefore 1770 km/h.

Though we have won that round of the game, we can go on to another. We turned the function y = x2 into another function, y = 2x. What's to stop us from plotting this second function and differentiating that? Nothing, of course! You'll recall that 2x is giving us the speed. The letter x still represents the time, so we can put this on the x axis. We now have a graph that shows us how fast you're going at any point in time along the journey! This is just a different way of representing the same motion, and it's called the second derivative. The graph we have constructed with it is called a velocity-time graph. Velocity is the combination of speed with the direction of travel9, but we can assume you were going in a straight line in one direction, so we will use speed and velocity interchangeably.

To differentiate 2x, we just get rid of the x, leaving us with 210. We write d2y / dx2 = 2 (pronounced 'd two y by d x squared equals 2'). What does this mean in the context of our velocity-time graph?

Before, we had distance and time, and we knew that the derivative gave us the speed because that's distance divided by time. What is velocity divided by time? It's acceleration11.

There - we have just calculated the precise acceleration of your jaunt: every minute, your speed increased by two kilometres per minute.

### Integral Calculus

As we know, integration is the reverse of differentiation. If we integrate 2x, therefore, we will get x2. The rules should be simple to infer. You simply raise the power of x by one and divide by that number. Here, the original power of x is one, so we increase that to two, and then divide by two.

The problem, as you may have spotted, is that had our function been x2 + 2, the derivative would still have been 2x. So when we integrate 2x, we have to specify that it could be x2 plus any number; we usually put x2 + c. This is called the indefinite integral of the function.

When we integrate 2x in our real-world scenario, we are integrating the velocity-time graph, and converting it to a distance-time graph. Big point: applying the rules of integration (the reverse of those of differentiation) to a formula that plots speed, we get a formula that will plot distance travelled. To sound flash about it, we can say that we turn a velocity function into a distance function12, or even posher, a displacement function.

We can calculate the distance travelled in any portion of the journey - that is, between any of the x values. For the whole journey, this means that we integrate the function with the limits of 0 and 10 (because we want the distance between 0 and 10 minutes after the start of our acceleration). When we integrate now, we get a definite integral, which means that we don't need to add the constant c to the end of our final function. So, integrating 2x gives x2. When x is 10, x2 is 100; when x is 0, x2 is also 0. The definite integral is equal to 100 - 0 (i.e. the difference between the value of the function at the upper limit and its value at the lower limit). This gives us a value for the distance of 100km, which is correct.

If you draw the graph of y = 2x (that's the velocity function) it's just a straight line going up. By setting '10 minutes' as the upper limit, we can form a triangle. The area of this triangle is just like any other: half its base multiplied by its vertical height. The base is 10; the height is 20 (because our maximum speed was 20 km/min, if you remember). Five times 20 is 100. This is the same as the distance travelled during this time period, and is also the same as the definite integral of the graph.

In other words, the area under a graph between two limits can be calculated by integrating the graph's function. In this example, we find that the distance travelled can be calculated from a velocity-time graph by finding the area under the line.

Of course, this seems more powerful when we find the area under a curve.

Suppose we want to calculate the area under the curve defined by y = 9x2-2x3+5x, between the x values of 0 and 5.

We integrate like this:

• For, 9x2, increase the power by one then divide the 9 by this number. That is, (9/3)x2+1 gives 3x3.

• For -2x3, increase the power by one and divide the -2 by this number, giving -0.5x4.

• For 5x, increase the power of x to 2, then divide 5 by 2 to get 2.5x2.

Put the bits together and you have 3x3-0.5x4+2.5x2. How jolly! But you'll want to conform to the notation of the game, so you should write it like this13:

∫50 ( 9x2-2x3+5x dx ) = [ 3x3-0.5x4+2.5x2 ]50

Now put in the upper limit as the value of x. In other words, we have to torture the number 5 to the tune of this function.

(3 * 53) - (0.5 * 54) + (2.5 * 52) = 375 - 312.5 + 62.5 = 125 units.

We don't know what the units are, but they'll be something like square metres.

### Recap

Differentiation allows us to calculate the gradient of a curve, so that we can see the rate of change of a quantity. Integration allows us to find the area under a curve, and is the reverse of differentiation. The 'rate of change' of something could refer to anything: such as how your bank balance changes with time, or how the amount of rainfall changes with temperature. In the case of movement, velocity is the rate of change of distance over time; acceleration is the rate of change of velocity over time. Therefore, differential calculus allows you to find velocity from distance (also called displacement) or acceleration from velocity; integration allows you to go the other way, as shown:

Displacement (distance)
Differentiate ↓Integrate ↑
Velocity (speed)
Differentiate ↓
(higher derivative)
Integrate ↑
Acceleration

Like chess, Dungeons & Dragons and politics, calculus has a number of rules that aren't obvious unless you look at specific examples.

#### Product functions

Consider y = cosx ( 3+6x3-2x2 ) - 9 lnx.

The strange thing here is that you needn't worry about what cos (cosine) or ln (natural logarithm) mean in order to play the game.

If we wish to differentiate this function, we have to split it up into separate bits. We will give these bits names so that we can identify them easily afterwards:

• The derivative of cosx is -sinx. We'll call cosx... say, Fred, and we'll imagine that -sinx (his derivative) is his wife, who we'll call Wilma.14

• The derivative of 3+6x3-2x2 is 18x2-4x (remember that a number on its own, called a constant, just vanishes into thin air when you differentiate, as happens here with the 3 at the beginning). So, what say we call 3+6x3-2x2 Barney, and its derivative, 18x2-4x, we'll call Betty.

• The derivative of lnx is 1/x, as we have seen. So the derivative of -9lnx is -9 times that. -9 * 1/x is simply -9/x. We could call this bit Dino.

Because cosx is being multiplied by (3+6x3-2x2), we have to cross-multiply the derivatives with the original functions - that is, multiply the first function (cosx) by the derivative of the other function, and vice versa.

We'll use our names to clarify this. It's a well-known rule of etiquette that husband and wife should not sit at the table next to each other, which means that we shall sit Fred (cosx) with Betty (18x2-4x), and Wilma (- sinx) with Barney (3+6x3-2x2). We'll then tag Dino on the end. We literally just sling all these different bits together in that exact order, like this:

cosx(18x2-4x) - sinx(3+6x3-2x2).

Note that we could easily have put (3+6x3-2x2)(-sinx) at the end. If we had, then we would have put a plus sign between the two couples15.

The final result is therefore:

dy/dx = cosx(18x2-4x) - sinx(3+6x3-2x2) - 9/x

If you got that, then you've just learnt the so-called 'product rule', which you use whenever two things with an x in them are being multiplied together.

#### Quotient functions

Let's differentiate 9x7 / 5x3 (you know, just for a laugh). This is called a 'quotient' function because we have two things with an x in them that are being divided. We can divide 9 by 5 to get 1.8, and we can then subtract the powers (7-3=4), giving us 1.8x4. Differentiate as usual to get 7.2x3. However, if one of the things on the top or bottom was a trigonometrical function, like sinx, we could not have done this. In that case, you need the quotient rule. To see how it works, we'll use the same example:

• The derivative of 9x7 is 63x6

• The derivative of 5x3 is 15x2

The rule is to multiply the bottom bit by the derivative of the top, then subtract the product of the top bit and the derivative of the bottom, then divide all that by the square of the bottom bit. In other words, you do the same as the product rule, but instead of slinging everything together like we did before, you must subtract the two couples from each other, and you must also then divide by the square of original bottom bit. Thus:

 dy / dx = 5x3(63x6) - 9x7(15x2) / 25x6 = 315x9 - 135x9 / 25x6 = 180x9 / 25x6 = 7.2x3

#### Turning points

Without a computer, it would be very difficult to draw some functions, say x3 + 6x2 + 9x + 3. However, using mathematical analysis we can determine a lot. For example, when a curve reaches a maximum or minimum point, its gradient is zero. These are also called stationary points or turning points, because it's where the curve is turning around from going up to down, or down to up. So let's stick with that example and see how it goes determining where this curve peaks and where it's at an all-time low:

dy / dx = 3x2 + 12x + 9

If we specify that 3x2 + 12x + 9 = 0 we can solve to find the x value of the maximum or minimum points:

x2 + 4x + 3 = 0

(x + 3)(x + 1) = 0

(This bit requires knowledge of factorising quadratics, which is a different topic.)

So the curve of the gradient function cuts the x axis when x + 3 = 0 (x = -3) and when x + 1=0 (x = -1). This tells us that there are maximum/minimum points at x = -3 and x = -1 on the original curve. To find out which is which, we use the second derivative:

d2y / dx2 = 2x + 4

When x = -3, 2x+4 = -2. This negative result tells us that the turning point at x = -3 is a maximum point.

When x = -1, 2x+4 = 2. This positive result tells us that the turning point at x = -1 is a minimum point.

If x were 0, this would tell us that we have found a 'point of inflexion', or 'saddle point', which is where the curve kind of flattens out into a zero gradient before continuing in the same direction.

#### Complex calculus

The fun doesn't end here, because we have only explored 'real-number calculus', which means calculus that doesn't involve the square roots of negative numbers. As you would expect, calculus that involves the square roots of negative numbers is complex, and is appropriately named 'complex calculus'. This was developed by Cauchy and Georg Riemann, mostly, and it is their equations that you must use to differentiate and integrate complex functions. One saving grace, however, is that in complex calculus, you only need to differentiate a function once; you can thereafter use a technique called 'contour integration' to skip straight to any higher derivative you choose.

### Good luck

Mathematical analysis is essential to a wide range of careers, and is a crucial part of any college course in mathematics - but, seriously, you can have fun with it too.

1Except that in some cases, you can never do this. These are called C-smooth functions, and they prove that calculus can provide literally endless fun.2Kepler's second law is that a line between the Sun and a planet sweeps out equal areas in equal times. He needed at least a crude form of integration for calculating these areas, since they were bounded by an ellipse.3Of last theorem fame.4Of 'therefore I am' fame.5Toothpaste contains calcium carbonate in the form of chalk (another form is marble). Clearly, the word 'calcium' also derives from calx.6They don't make any allowances for the curvature of the Earth, of course. Don't even think about it.7We will continue to generalise by using letters (technically called 'variables'), because this allows us to analyse a graph with any value that suits us.8The number e is called the base of the natural logarithm, and is roughly equal to 2.718 (but, like π, it goes on forever).9Quantities like this are called 'vector' quantities (whereas speed is called a 'scalar' quantity).10You can actually merge this rule with the one for powers of x, if it makes you happier. If you do, then the x in 2x has a power of 1. When you bring it to the front, you multiply it by the 2, and then reduce the power of x to zero. Anything to the power of zero (except zero itself) is equal to 1, so 2x0 = 2 * 1 = 2.11When you see a dividing sign, you can invariably interpret it as a 'per' sign. So, you can think of velocity as metres divided by seconds, and as metres per second. Likewise, you can think of acceleration as a change in velocity divided by the time for the change, or as a change in metres per second, per second.12Not to be confused with a social gathering that's just a long way away.13Except that the small numbers (the limits) should be vertically aligned.14Plucking names completely at random here.15Because in maths, we usually assume something is positive unless there's a negative sign; so when we just 'sling' something together like this, we must remember what sign to put.