Sign in

Libre University uses your GitHub account. Signing in is only needed to sit a final test, so the score is kept on your profile.

Calculus

What a limit actually is, and then how to differentiate and integrate: the mathematics of change, built solidly enough to read the physics that uses it.

Two problems algebra cannot solve

Two questions about a curve resist every technique in school mathematics, and calculus is the machinery built to answer them: how steep is a curve at one particular point, and how much area lies underneath it.

Both questions sound like geometry, and both are answered daily by anyone who reads a graph. What makes them hard is that the ordinary methods run out at exactly the moment they are needed. This lesson shows where they run out, what people did about it before the modern definitions existed, and why the two problems turn out to be the same problem twice. It assumes the algebra, functions and graphs of the previous course, plus the geometric series from its late lessons, and nothing else.

The slope of a curve at a point

A straight line has one slope, and it is the same everywhere on the line: pick any two points on it and the ratio of the rise to the run is the same number. That number is what the line means physically. Plot the position of a car against time, get a straight line, and its slope is the speed.

A curve has no such number. On the parabola y=x2 the graph is nearly flat near the origin and steep at x=3, so any honest answer to "how steep is it" has to name a point. Ask for the steepness at exactly x=1 and the difficulty appears immediately: slope is a ratio built from two points, and one point does not determine a ratio. Trying to compute the rise and run at a single point gives 0/0, which is not a number.

The obvious repair is to use a second point nearby and accept a small error. Take the point at x=1, where y=1, and a second at x=1+h, where y=(1+h)2. The line through the two, a secant, has slope

(1+h)2-1h=2h+h2h

which for h=0.1 is 2.1, for h=0.01 is 2.01, and for h=0.001 is 2.001. Coming in from the other side, h=-0.001 gives 1.999. The numbers are converging on 2 from both directions and never reaching it, and the one value of h that would give the slope at the point itself, h=0, turns the fraction into 0/0 and says nothing at all.

Something is clearly true here: the numbers are closing in on 2 and would go on closing in forever. Saying what that means, precisely enough to calculate with, is the whole of the next lesson.

Example. Estimate the slope of y=x3 at x=2 using secants.

With h=0.1 the second point is x=2.1, where y=9.261, so the secant slope is (9.261-8)/0.1=12.61. With h=0.01 the point is x=2.01, where y=8.120601, giving (8.120601-8)/0.01=12.0601. With h=0.001 the slope is 12.006001. The values are converging on 12, and every one of them is an honest slope of an honest line, none of which is the tangent.

Now you. Estimate the slope of y=1/x at x=2 with h=0.1, h=0.01 and h=0.001.

Answer

The secant slope is (1/(2+h)-1/2)/h. For h=0.1 that is -0.238095, for h=0.01 it is -0.248756, and for h=0.001 it is -0.249875. The values are closing on -0.25, and the sign is negative because the curve falls as x increases.

The area under a curve

The second problem is older. Areas bounded by straight lines are elementary: a rectangle is a product, a triangle is half of one, and any polygon can be cut into triangles. Curved boundaries defeat this completely, because no finite number of straight cuts will follow a curve.

Take the region under y=x2 from x=0 to x=1. There is obviously an area there, somewhere between nothing and the unit square, but no formula in school geometry produces it. The available approximation is to fill the region with rectangles. Cut [0,1] into four strips of width 1/4 and give each rectangle the height of the curve at the right end of its strip: the heights are (1/4)2,(2/4)2,(3/4)2,(4/4)2, and the total area is 0.46875. Do the same with the left end of each strip and the total is 0.21875.

Those two numbers bracket the truth, because x2 rises across the interval, so right ends overestimate and left ends underestimate. The bracket is embarrassingly wide. Going to ten strips narrows it to between 0.285 and 0.385; a hundred strips gives 0.32835 to 0.33835; a thousand gives 0.332834 to 0.333834. The gap is closing on zero and both ends are closing on 1/3.

Again something is true and unstated. No finite number of rectangles ever gives the area, every one of them is wrong, and the sequence of wrong answers is unmistakably heading somewhere.

Example. Bracket the area under y=x2 from 0 to 1 using five strips.

Each strip is 0.2 wide. Right ends give heights 0.04,0.16,0.36,0.64,1, summing to 2.2, so the area estimate is 0.2×2.2=0.44. Left ends give heights 0,0.04,0.16,0.36,0.64, summing to 1.2, for an estimate of 0.24. The true area lies between them, and the width of the bracket, 0.2, is exactly one strip width times the total rise of the function, which is a pattern worth remembering.

Now you. Bracket the area under y=x2 from 0 to 1 using ten strips.

Answer

Each strip is 0.1 wide. The right sum is 0.1×(0.01+0.04++1.00)=0.385 and the left sum is 0.285. The bracket has halved in width, as expected, and still contains 1/3.

What Archimedes did about it

The area problem was solved, in particular cases, about nineteen centuries before calculus existed. Archimedes of Syracuse, working around 240 BC, computed the exact area of a parabolic segment: the region cut off from a parabola by a straight chord.

His construction inscribes the largest triangle in the segment, then the two largest triangles in the two gaps that remain, then four in the four gaps left by those, and so on. He proved geometrically that each generation of triangles has one quarter of the total area of the previous generation. The segment is therefore the first triangle multiplied by 1+1/4+1/16+1/64+, and that geometric series sums to 4/3. The area of the segment is four thirds of the inscribed triangle, exactly, with no approximation surviving in the answer.

The same author bracketed π in Measurement of a Circle by inscribing and circumscribing regular polygons of 96 sides, obtaining 31071<π<317, which is 3.14085<π<3.14286, against the true 3.14159. The technique, called the method of exhaustion, is rigorous by any standard: to prove the area equals A, show that assuming it larger and assuming it smaller both lead to contradictions.

The trouble with exhaustion is that it is a proof technique, not a method of discovery. Each new region needs its own geometric argument, invented from nothing, and Archimedes needed to know the answer before he could prove it. Two thousand years produced only a handful of successes. What was missing was not rigour but a procedure.

The two problems are one

Here is the connection that makes a subject out of two puzzles, and it is easiest to see in physics. Let s(t) be the distance a body has travelled by time t, and v(t) its speed. If you plot s against t, the slope at any instant is the speed at that instant: speed is a rate, and a rate is a slope. If instead you plot v against t, the area under the graph up to time t is the distance covered, since distance is speed accumulated over time.

So the slope problem takes position to speed, and the area problem takes speed back to position. They run in opposite directions between the same two quantities, which suggests they are inverse operations, and that whichever is easier to compute solves both.

A falling body makes the claim checkable. Near the Earth's surface a body released from rest falls with speed v=9.8t metres per second after t seconds, which plots as a straight line through the origin. The area under it from 0 to 3 seconds is a triangle of base 3 and height 29.4, so the area is 44.1. The distance formula for constant acceleration, from mechanics, is s=12gt2, giving 12(9.8)(9)=44.1 metres. The area under the speed graph is the distance, to the last digit.

Example. Use the area under v=9.8t to find the distance fallen in 5 seconds, and check it.

The region is a triangle of base 5 and height 9.8×5=49, so the area is 12(5)(49)=122.5. The formula s=12gt2 gives 12(9.8)(25)=122.5 metres. They agree, and notice that the area calculation needed no formula for falling bodies: it read the answer off the graph.

Now you. A car accelerates from rest so that its speed is v=4t metres per second. How far does it travel in the first 6 seconds, and what is the slope of the distance graph at t=6?

Answer

The area under v=4t from 0 to 6 is a triangle of base 6 and height 24, so the distance is 72 metres. The slope of the distance graph at t=6 is the speed there, which is 4×6=24 metres per second. The two problems are answering each other.

Ghosts of departed quantities

Isaac Newton and Gottfried Wilhelm Leibniz, working independently in the 1660s and 1670s, each found the procedure that exhaustion lacked, and each published a calculus in which slopes and areas are computed by rules rather than reinvented per problem. Newton spoke of fluxions, rates at which quantities flow; Leibniz wrote dx and dy for infinitesimal differences and invented the notation still used today. The results were spectacular and immediately convincing, because they reproduced everything the ancients had done and much they had not.

The reasoning was not defensible. In a typical Leibnizian calculation, dx is a quantity small enough that (dx)2 may be discarded as negligible, and at the end of the calculation dx is divided out, which requires it to be non-zero, and then dropped, which requires it to be zero. Bishop George Berkeley attacked exactly this in The Analyst of 1734, asking of the vanishing increments: "May we not call them the ghosts of departed quantities?" The complaint was fair, and no clean answer existed for almost a century.

The repair came from Augustin-Louis Cauchy, whose Cours d'Analyse of 1821 made the limit rather than the infinitesimal the basic notion, and from Karl Weierstrass, who in the 1860s gave the limit the tolerance-based definition that removes every appeal to intuition about the infinitely small. Nothing in the results changed. What changed is that the results acquired proofs.

Two remarks about that history are worth carrying forward. First, useful mathematics is regularly used for a century before it is made rigorous, so a working physicist's cheerful manipulation of dx is not ignorance but inheritance. Second, the rigorous version is not decoration: without it there is no way to tell a valid infinitesimal argument from an invalid one, and both kinds were published.

What the rest of this course does

The plan follows the trouble. The immediate need is a precise account of what it means for the secant slopes to close in on 2, which is the limit, and that occupies the next two lessons, since the limit also settles what it means for a function to have no breaks in it.

With limits available, the slope problem is solved in one definition and then made practical: a handful of rules reduce a page of limit algebra to a line, and by the middle of the course any function that can be written down can be differentiated. Those derivatives immediately answer questions that look nothing like slopes, from the maximum range of a projectile to the angle at which light bends entering water.

The area problem is then defined properly as a limit of rectangle sums, computed the hard way once, and after that the connection glimpsed above is proved as the Fundamental Theorem of Calculus. That theorem converts every area problem into the search for a function with a given derivative, which is what makes areas, volumes, work and averages computable at all.

The last lesson does the reverse trick: instead of computing exactly, it replaces a function by a polynomial that matches it near a point, which is where every approximation in a physics textbook comes from. Before any of that, a definition is owed.

Limits

The secant slopes of the previous lesson closed in on a number without ever reaching it, and that behaviour needs a definition before anything can be built on it.

The word usually offered is "approaches", which is a description rather than a definition: it says what the numbers are doing without saying what would settle whether a claimed answer is right. This lesson replaces it with something checkable, and then, having made limits precise, shows that most of them are computed in one step by substitution. The interesting ones are exactly the ones where substitution fails.

The tolerance game

Consider the claim that f(x)=2+x approaches 2 as x approaches 0. It is obviously true, but ask what makes it true and the answer is not "the values get near 2", since the values also get near 2.0001 and near 3.

The claim that distinguishes 2 from every other candidate is this: name any tolerance, however small, and I can keep f(x) within it. Ask for f(x) within 0.01 of 2 and I keep x within 0.01 of 0. Ask for 0.000001 and I keep x within 0.000001. No other number survives this game. If you propose 2.0001 as the limit and I ask for a tolerance of 0.00001, you cannot deliver, because once x is small the values are nowhere near 2.0001.

The limit is therefore not a description of motion but a guarantee about tolerances, and the guarantee has two players: a challenge, and a response that must exist for every challenge. Weierstrass turned exactly this into notation in the 1860s. Writing ε for the challenge tolerance on the output and δ for the response tolerance on the input,

limxaf(x)=L

means: for every ε>0 there is a δ>0 such that 0<|x-a|<δ forces |f(x)-L|<ε.

Two details in that sentence carry real weight. The order is fixed: ε is named first and δ may depend on it, never the reverse. And the condition on the input is 0<|x-a|, which explicitly excludes x=a. The limit is a statement about the punctured neighbourhood of a, and it is deliberately blind to the value of f at a, which may be anything or may not exist. That blindness is not a technicality: it is the only reason the definition is usable for difference quotients, which are always undefined at the point of interest.

Producing a delta

The definition earns its keep when a δ is actually produced, so here is one. Claim: limx3(4x-5)=7. Given ε, the requirement is |(4x-5)-7|<ε, which is |4x-12|<ε, which is 4|x-3|<ε. So taking δ=ε/4 works, for every ε at once. The proof is the formula for δ.

A curve needs one extra move. Claim: limx2x2=4. The quantity to control is |x2-4|=|x-2||x+2|. The first factor is what δ controls directly; the second must be bounded before it can be used. So agree in advance that δ will never exceed 1, which confines x to the interval from 1 to 3 and makes |x+2|<5. Then |x2-4|<5|x-2|<5δ, so choosing δ to be whichever of 1 and ε/5 is smaller finishes it.

Check it numerically with ε=0.05, which gives δ=0.01. At x=2.01 the error is |4.0401-4|=0.0401, and at x=1.99 it is 0.0399. Both are under the requested 0.05, with room to spare, which is normal: δ has to work, not to be optimal.

Nobody computes everyday limits this way, any more than anyone adds by returning to the axioms of arithmetic. The definition is there so that the shortcuts can be proved, and so that a disputed limit has a court of appeal.

The limit laws, and why substitution usually works

From the definition it can be proved, once and for all, that limits respect arithmetic. If limxaf(x)=L and limxag(x)=M, then the limit of f+g is L+M, of f-g is L-M, of fg is LM, and of f/g is L/M provided M0. Constants pull out, and powers and roots behave as expected.

Add the two limits that are true directly from the definition, limxac=c and limxax=a, and a large class of limits collapses. A polynomial is built from constants and x by multiplication and addition, so for any polynomial P, limxaP(x)=P(a): substitute and stop. A rational function is a quotient of polynomials, so the same holds wherever the denominator is not zero at a.

That is the useful summary. For every function assembled by arithmetic from polynomials, the limit is the value, and the calculation is one substitution. So limx2(x3-4x+1)=8-8+1=1, and there is nothing more to say about it.

The whole subject therefore lives in the exceptions, and there is essentially one: the denominator goes to zero at the same moment as the numerator. The law for quotients does not apply, the expression 0/0 is not defined, and yet the limit frequently exists. Such an expression is called an indeterminate form, and the name is precise. It is not that the answer is unknown; it is that the form itself determines nothing, since 0/0 arises in limits equal to 6, to 0, to -1/4 and to nothing at all.

Working the indeterminate forms

The technique is always the same: change the expression algebraically so that the cancellation happens before the limit is taken. This is legitimate because the limit ignores the point itself, so any manipulation valid for xa is valid here even if it is invalid at a.

For limx3x2-9x-3, substitution gives 0/0. Factor: x2-9=(x-3)(x+3), so for every x3 the expression equals x+3, and the limit is 6. The cancelled factor is the whole difficulty, and cancelling it is legal for exactly the values the limit is about.

Example. Evaluate limx2x3-8x-2.

Substitution gives 0/0, so factor the numerator: x3-8=(x-2)(x2+2x+4), which the factor theorem from the previous course guarantees since x=2 is a root. For x2 the quotient is x2+2x+4, a polynomial, so the limit is 4+4+4=12. Numerically, at x=2.001 the original expression is 12.006, which agrees.

Now you. Evaluate limx1x3-1x2-1.

Answer

Both parts vanish at x=1. Factoring gives (x-1)(x2+x+1) over (x-1)(x+1), so for x1 the expression is (x2+x+1)/(x+1), and the limit is 3/2.

Roots need a different device: multiply by the conjugate, which moves the difficulty from the numerator to the denominator where it does no harm.

Example. Evaluate limh09+h-3h.

Multiply top and bottom by 9+h+3. The numerator becomes (9+h)-9=h, so the expression is h/[h(9+h+3)], which for h0 is 1/(9+h+3). Now substitution is legal and gives 1/6=0.1667. Checking with h=0.001 in the original gives 0.166662, so the algebra and the arithmetic agree.

Now you. Evaluate limh04+h-2h.

Answer

The same conjugate trick gives 1/(4+h+2), so the limit is 1/4. At h=0.001 the original expression is 0.249984.

Both of those are difference quotients in disguise, which is the point. The limit machinery was invented for them.

When there is no limit

A limit can fail to exist, and the ways it fails are worth knowing by sight, because a rule applied to a limit that does not exist produces confident nonsense.

The commonest failure is a jump: the two sides disagree. For f(x)=|x|/x, every positive x gives +1 and every negative x gives -1. Approaching zero from the right the values sit at 1, from the left at -1, and no single number is being approached. This motivates one-sided limits, written limxa+ and limxa-, with the obvious definitions restricted to one side. The two-sided limit exists exactly when both one-sided limits exist and are equal, which is a theorem, and it is the standard way to test a function defined by different formulas on either side of a point.

The second failure is blowing up. For f(x)=1/x2 near zero the values exceed any bound you name. Writing limx01/x2= is standard and convenient, but it does not assert that the limit exists: it is shorthand for a specific mode of not existing, namely that the values eventually exceed every fixed number. Treating that as a quantity to cancel or divide by is how people prove that 1=2.

The third failure is oscillation. As x approaches zero, sin(1/x) runs through every value between -1 and 1 infinitely often, no matter how small an interval around zero you take. Nothing is approached, nothing blows up, and no tolerance smaller than 1 can ever be met.

Limits at infinity, and squeezing

Reversing the roles of the two tolerances gives the other kind of limit. Saying limxf(x)=L means: name any ε, and there is a value of x beyond which f stays within ε of L. The graph of such a function has a horizontal asymptote at height L.

For rational functions these limits are settled by dividing top and bottom by the highest power present. Take (3x2+2x-1)/(5x2-x+4) and divide through by x2 to get (3+2/x-1/x2)/(5-1/x+4/x2). Every term with an x downstairs vanishes, so the limit is 3/5. The arithmetic bears this out: at x=10 the value is 0.6457, at x=100 it is 0.60514, and at x=1000 it is 0.60052.

Example. Evaluate limx2x3-x6x3+5.

Divide by x3: the expression becomes (2-1/x2)/(6+5/x3), and the limit is 2/6=1/3. At x=100 the original is 0.333316, closing on 0.3333 from below.

Now you. Evaluate limx4x2+7x3-2.

Answer

Divide by x3 to get (4/x+7/x3)/(1-2/x3). The numerator goes to zero and the denominator to 1, so the limit is 0. Whenever the denominator has the higher degree, the limit at infinity is zero.

One further tool is needed later and is easiest to state now. The squeeze theorem says that if g(x)f(x)h(x) near a, and g and h both have limit L at a, then f does too: a function trapped between two things converging to the same place has nowhere else to go.

Its standard use is f(x)=x2sin(1/x) near zero. The oscillating factor never leaves [-1,1], so -x2f(x)x2, and both bounds go to zero. Hence f(x)0, despite oscillating infinitely often on the way. The values confirm it: at x=0.01 the function is about -5.06×10-5, and at x=0.001 about 8.27×10-7. This theorem is what will deliver the derivative of the sine function, where no algebraic trick works at all.

What has been bought

The limit is now a definition rather than a gesture, and with the limit laws most limits are one substitution. The exceptions are the indeterminate forms, and the two shown here, factoring and rationalising, handle a large fraction of what the next lessons produce.

Notice what has been carefully avoided throughout: any claim about f(a). The limit at a can exist while f(a) is undefined, as in every difference quotient, or while f(a) is defined and equal to something else entirely, if the function is given a stray value at one point. Functions where nothing so perverse happens, where the limit is the value, are the ones on which the rest of the subject is built, and they have a name and a set of theorems of their own.

Continuity

A limit at a point is deliberately blind to the value of the function at that point, and the functions worth working with are precisely the ones where that blindness costs nothing.

The previous lesson built the limit as a promise about tolerances and showed that for polynomials and similar functions the limit is just the value, so the whole calculation is a substitution. That coincidence deserves a name and an investigation, because it is not automatic, and because the theorems that follow from it are what later lessons quietly rely on when they assert that a maximum exists or that an area is a number.

The definition, in three parts

A function f is continuous at a when

limxaf(x)=f(a)

and that single equation is really three demands stacked together. The right side must exist, so a must be in the domain of f. The left side must exist, so the function must approach some single value from both sides. And the two must be equal.

Any one of the three can fail on its own. The function (x2-9)/(x-3) has a perfectly good limit of 6 at x=3 and no value there at all. A function defined to be x2 everywhere except at x=1, where it is declared to be 7, has both a limit (1) and a value (7), and they disagree. A step function has a value at the step and no limit.

The picture everyone is taught, that a continuous function can be drawn without lifting the pen, is a decent guide and a poor definition. It fails to say anything useful about a function on the rationals, or about sin(1/x), which cannot be drawn at all near zero yet is continuous at every point where it is defined. The tolerance definition survives all such cases, which is why it is the one that is used.

A function is continuous on an interval when it is continuous at every point of it, with the endpoints requiring only the one-sided limit that stays inside.

Example. For which value of c is the function equal to x2 when x2 and to cx+1 when x>2 continuous everywhere?

Away from x=2 each piece is a polynomial and so is continuous. At x=2 the value and the limit from the left are both 4. The limit from the right is 2c+1. Continuity requires 2c+1=4, so c=1.5. With that choice the right-hand formula at x=2 gives 1.5×2+1=4, matching, and the graph has no step in it.

Now you. The function equals (x2-25)/(x-5) for x5 and equals k at x=5. What k makes it continuous?

Answer

For x5 the expression is x+5, so the limit at 5 is 10. Continuity requires the value to match the limit, so k=10.

The three ways it fails

Discontinuities come in a small number of shapes, and naming them is useful because the repair, if any, differs.

A removable discontinuity is a hole: the limit exists but the value is missing or wrong. It is removable in the literal sense that redefining the function at that one point fixes it, which is what the previous exercise did. Every cancelled factor in an indeterminate form leaves one of these behind.

A jump discontinuity is two one-sided limits that exist and disagree. These are not repairable by any single value, and they are common in real data rather than pathological: a postage rate as a function of weight, an income tax rate as a function of income, the density of water as a function of temperature at 0 degrees Celsius. Physical laws are usually written for continuous quantities, and a jump is where such a law needs separate treatment on each side.

An infinite discontinuity is a vertical asymptote, as in 1/x at zero, where no value assigned at the point can help because the function is unbounded nearby. Oscillation, as in sin(1/x) at zero, is the remaining case and is equally unrepairable.

Example. Classify the discontinuities of f(x)=x2-x-6x2-9.

The denominator vanishes at x=3 and x=-3, so those are the only candidates. Factoring gives (x-3)(x+2) over (x-3)(x+3), so for x3 the function equals (x+2)/(x+3). At x=3 that expression is 5/6=0.8333, a perfectly good limit with no value attached, so the discontinuity is removable. At x=-3 the reduced form still has a zero denominator with a non-zero numerator, so the function blows up: an infinite discontinuity, and no redefinition will fix it.

Now you. Classify the discontinuities of f(x)=x2-1x2-3x+2.

Answer

Factoring gives (x-1)(x+1) over (x-1)(x-2), so for x1 the function is (x+1)/(x-2). At x=1 the limit is 2/(-1)=-2, so that discontinuity is removable. At x=2 the function is unbounded, an infinite discontinuity.

Almost everything is continuous

The limit laws convert directly into a catalogue. Sums, differences, products and quotients of continuous functions are continuous wherever they are defined, and so is a composition of continuous functions. Polynomials are continuous everywhere. Rational functions are continuous except where the denominator vanishes. Roots, sines, cosines, exponentials and logarithms are continuous throughout their domains.

The practical consequence is that continuity is the default. Any function written down by combining the standard ones is continuous except at points you can find by inspection: division by zero, an even root of a negative number, a logarithm of something non-positive, or a definition given in pieces. Everything else is safe.

That fact is what makes the next two theorems worth having. They are hypotheses-and-conclusion statements whose hypothesis is almost always satisfied, so in practice they hand out conclusions for free.

A sign change guarantees a root

The Intermediate Value Theorem says that if f is continuous on the closed interval from a to b, then f takes every value between f(a) and f(b) somewhere in that interval. In particular, if f(a) and f(b) have opposite signs, there is a point where f is zero.

It sounds like a restatement of the pen-drawing picture, and it is much more than that: it is an existence theorem that converts a comparison of two numbers into a guarantee about the existence of a solution. It says nothing about where the root is or how many there are, and it needs no formula for solving anything.

Turned into a procedure, it gives bisection. Take f(x)=x3-x-1, which no factoring will crack since it has no rational roots. Then f(1)=-1 and f(2)=5, so a root exists between 1 and 2. Evaluate at the midpoint: f(1.5)=0.875, positive, so the sign change is now between 1 and 1.5. Then f(1.25)=-0.296875, so the root is between 1.25 and 1.5. Then f(1.375)=0.224609, then f(1.3125)=-0.051514, then f(1.34375)=0.082611, then f(1.328125)=0.014576. Six steps have trapped the root between 1.3125 and 1.328125, and each further step halves the interval. The root, to seven figures, is 1.324718.

Bisection is slow and utterly reliable: the error is guaranteed to fall by half per step, so twenty steps take an interval of width one down to below a millionth. Later in the course a much faster method appears, one that uses derivatives and can fail, and the comparison between them is the usual trade in numerical work.

Example. Show that cosx=x has a solution between 0 and 1, and bracket it in three bisection steps.

Apply the theorem to g(x)=cosx-x, which is continuous everywhere. Here g(0)=1 and g(1)=0.5403-1=-0.4597, opposite signs, so a solution exists. The midpoint gives g(0.5)=0.377583, so the root lies in [0.5,1]. Then g(0.75)=-0.018311, so it lies in [0.5,0.75]. Then g(0.625)=0.185963, so it lies in [0.625,0.75]. The true value is 0.739085.

Now you. Show that x3=10 has a solution between 2 and 3, and take two bisection steps.

Answer

With f(x)=x3-10, f(2)=-2 and f(3)=17, so a root exists. The midpoint gives f(2.5)=5.625, so the root is in [2,2.5]. Then f(2.25)=1.390625, so it is in [2,2.25]. The cube root of 10 is 2.154435.

Why the theorem needs the real numbers

The Intermediate Value Theorem is not a triviality, and the cleanest evidence is that it is false if the number system has gaps.

Work entirely within the rational numbers and consider f(x)=x2-2. It is continuous as a function of a rational variable, f(1)=-1, and f(2)=2. The signs are opposite, yet there is no rational number where f is zero, since the previous course proved by contradiction that 2 is irrational. Continuity and a sign change are not enough. What is also needed is that the line has no holes in it.

That property, called completeness, is the defining difference between the rationals and the reals, and every existence theorem in this course descends from it. Continuity is the hypothesis you check; completeness is the hypothesis that comes with the number system and is easy to forget. Cauchy, Weierstrass, Dedekind and Cantor spent the middle of the nineteenth century making it precise, and calculus was placed on solid ground only when they had.

A closed interval guarantees a maximum

The second existence theorem is the Extreme Value Theorem: a continuous function on a closed bounded interval attains a maximum and a minimum somewhere on it. Not approaches, attains, at actual points of the interval.

Both hypotheses are load-bearing, and dropping either kills the conclusion. The function 1/x on the half-open interval (0,1] is continuous there and has no maximum, since it exceeds any bound near zero. The function f(x)=x on the open interval (0,1) is continuous and bounded, and still has no maximum: it gets arbitrarily close to 1 and never attains it, and no point of the interval is the winner. Take the same function on the closed interval [0,1] and the maximum exists, at the endpoint. And a function with a jump can miss its own supremum even on a closed interval.

This theorem is the licence for the whole optimisation lesson later. When a problem asks for the shape that minimises cost, the answer is presumed to exist, and this is where that presumption comes from: continuous function, closed interval, therefore a minimum exists, and the derivative can then be used to find where it is. Without the theorem, the derivative would only be able to say that if a minimum exists then it is at one of these points.

Continuity is not enough for a tangent

Continuity guarantees no holes, no jumps and no blowups. It does not guarantee that a curve has a direction at each point, and that gap is what the next lesson has to close.

The function f(x)=|x| is continuous everywhere, including at zero, where the limit and the value are both zero. But it has a corner there. Approach the origin along the left branch and the slope is -1; approach along the right branch and it is +1. Any line through the origin is a bad fit to at least one side, and there is no sensible tangent. The secant slopes from the previous lesson do exist here, but the one-sided limits disagree, which is exactly the jump failure applied to the difference quotient rather than to the function.

How much worse this can get was settled by Weierstrass in 1872, when he exhibited a function continuous at every point of the real line and differentiable at none. It is built as an infinite sum of ever faster, ever smaller cosine waves, so that at every scale, no matter how far you zoom in, the graph is still wrinkled and never settles down to look like a line. Until then most mathematicians assumed a continuous function must have a tangent almost everywhere, and the example ended that assumption permanently. It also demonstrates that intuition about curves is not a reliable guide, which is a large part of why the tolerance definitions were adopted.

So a curve can be unbroken and still have no slope. Having a slope at a point is a strictly stronger condition, and defining it, computing it and using it is what the next several lessons are about.

The derivative

The slope of a curve at a single point can now be defined, because the limit supplies exactly the missing idea: the tangent slope is the number the secant slopes close in on.

Everything in this lesson comes from one formula, applied patiently. The earlier lessons supply the two things it needs: a definition of the limit as a promise about tolerances, and the warning from continuity that some curves have no slope at some points, so the definition must be allowed to fail rather than being assumed to work.

The definition

Fix a point a in the domain of f. A second point at horizontal distance h gives the secant slope

f(a+h)-f(a)h

which is an ordinary quotient of ordinary numbers for every h0, and is undefined at h=0. The derivative of f at a is the limit of that quotient as h approaches zero:

f(a)=limh0f(a+h)-f(a)h

When the limit exists, f is differentiable at a and f(a) is the slope of the tangent line there. When it does not, f has no derivative at a, and this happens often enough that the qualification matters.

An equivalent form replaces a+h by a variable point x, giving f(a)=limxa(f(x)-f(a))/(x-a). The two are the same statement with different bookkeeping, and both are used: the first is easier to compute with, the second easier to reason with.

Note where the difficulty went. The expression is 0/0 at h=0, which is why no algebraic evaluation is possible and why the limit is indispensable. Every derivative computed from the definition is an indeterminate form resolved by the techniques of the limits lesson, and in practice the resolution is nearly always the same: cancel an h that appears in every term of the numerator.

Three derivatives from first principles

Take f(x)=x2. The numerator is (x+h)2-x2=2xh+h2, so the quotient is (2xh+h2)/h, which for h0 equals 2x+h. That is a polynomial in h, so the limit is a substitution: f(x)=2x. At x=1 this gives 2, which is the number the secants of the first lesson were closing on.

Take f(x)=1/x, with x0. The numerator is 1x+h-1x=x-(x+h)x(x+h)=-hx(x+h). Dividing by h gives -1/[x(x+h)], and now substitution is legal: f(x)=-1/x2. At x=2 that is -0.25, matching the secant values of -0.238 and -0.2488 computed earlier for h=0.1 and h=0.01. The sign is negative everywhere, as it must be for a function that falls on both branches.

Take f(x)=x, with x>0. Here the trick is the conjugate. Multiplying the quotient above and below by x+h+x turns the numerator into (x+h)-x=h, so the quotient becomes 1/(x+h+x), and the limit is

f(x)=12x

At x=9 that is 1/6=0.16667, and the secant with h=0.001 gives 0.166662. Notice the behaviour near zero: as x shrinks the derivative grows without bound, which is the graph turning vertical at the origin.

Example. Differentiate f(x)=x2-5x from the definition and find the slope at x=1.

The numerator is [(x+h)2-5(x+h)]-[x2-5x]=2xh+h2-5h. Every term carries an h, so dividing gives 2x+h-5, and the limit as h0 is f(x)=2x-5. At x=1 the slope is -3: the curve is falling there, which is right, since the vertex of this parabola sits at x=2.5.

Now you. Differentiate f(x)=3x2+2 from the definition.

Answer

The numerator is 3(x+h)2+2-3x2-2=6xh+3h2, so the quotient is 6x+3h and the limit is f(x)=6x. The constant 2 contributes nothing, because it cancels in the difference: shifting a graph up does not change any slope on it.

A function, not a number

In each of those calculations the answer came out as a formula in x rather than a single value, which is the step that makes calculus a machine rather than a collection of measurements. The derivative function f assigns to each point where f is differentiable the slope of f there, and it has its own domain, its own graph, and its own derivative.

That last remark gives the second derivative f′′, the rate at which the slope itself is changing. For f(x)=x2 the derivative is 2x and the second derivative is the constant 2: the slope increases at a steady rate, which is exactly what a parabola opening upward looks like. Third and higher derivatives follow by repetition, and the notation f(4) takes over once primes become unreadable.

The physical reading is worth fixing now because the whole of mechanics uses it. If s(t) is position, then s(t) is velocity and s′′(t) is acceleration. Newton's second law, F=ma, is therefore a statement about a second derivative, which is why the equations of physics are differential equations and why this course is a prerequisite for reading them.

Two notations

Lagrange's notation, f(x), is compact and treats the derivative as an operation producing a new function. It is best when the functions are the objects of interest.

Leibniz's notation writes the same thing as

dydx

which records more. It names both variables, so in a problem with several it is unambiguous which is varying with respect to which. It carries the units correctly: if y is in metres and x in seconds, the symbol reads as metres per second without any further convention, and a derivative of position with respect to time therefore has units of m s⁻¹ while its own derivative has m s⁻². And it survives the chain rule in a form that looks like cancelling fractions, which is the main reason physicists use it and the main reason it must be handled with care: dy/dx is a single symbol, the limit of a ratio, not a ratio of two quantities called dy and dx. The nineteenth century spent considerable effort removing the implication that it is, and the notation kept the shape anyway because the shape is a good mnemonic.

A value at a specific point is written f(3) in one notation and, less gracefully, as dy/dx evaluated at x=3 in the other. Time derivatives in mechanics often use Newton's dot, x˙ and x¨, which is unbeatable for brevity when the independent variable is always time.

Example. A stone falls from rest, so its distance fallen is s=4.9t2 metres after t seconds. Find its velocity at t=2 from the definition.

The difference quotient is [4.9(2+h)2-4.9(4)]/h=[19.6h+4.9h2]/h=19.6+4.9h, so the limit is 19.6 metres per second. Numerically the quotient at h=0.1 is 20.09, at h=0.01 it is 19.649, and at h=0.001 it is 19.6049, closing on 19.6 exactly as the algebra says.

Now you. For the same stone, find the velocity at t=3, and the acceleration.

Answer

The same working with 2 replaced by 3 gives 29.4+4.9h, so the velocity is 29.4 metres per second. In general s(t)=9.8t, whose derivative is the constant 9.8, so the acceleration is 9.8 m s⁻², which is g, as it should be for a body in free fall.

Differentiable implies continuous

There is one implication between the two conditions, and it goes one way only.

Suppose f is differentiable at a. For xa write the identity

f(x)-f(a)=f(x)-f(a)x-a(x-a)

which is true because the fraction has been multiplied by what was just divided out. Take the limit as xa. The first factor tends to f(a), a finite number, by assumption. The second tends to zero. By the product law the whole right side tends to f(a)0=0, so f(x)f(a), which is the definition of continuity at a.

So differentiability is the stronger condition, and the intuition matches: a function with a jump has a difference quotient that blows up across the jump, since a non-zero numerator is divided by a vanishing denominator.

The converse fails, and the previous lesson has already met the counterexample. For f(x)=|x| at zero the difference quotient is |h|/h, which is +1 for positive h and -1 for negative h. Both one-sided limits exist and disagree, so there is no derivative, while the function is perfectly continuous. The graph has a corner.

Two other failures are worth recognising by their difference quotients. For f(x)=x1/3 at zero the quotient is h1/3/h=h-2/3, which grows without bound from both sides: the tangent is vertical, and a vertical line has no slope. For f(x)=x2/3 at zero the quotient is h-1/3, which goes to + from the right and - from the left: a cusp, where the curve comes to a point. In every case the diagnosis is the same, that the limit defining the derivative fails to exist, and the cases differ only in how it fails.

Reading a derivative

Once f is available as a function, three features of it describe f completely enough to sketch it.

The sign says direction. Where f>0 the tangent lines slope up and the function is increasing; where f<0 it is decreasing. This is the fact that makes derivatives useful for finding maxima, and it is stated here as a plausible reading rather than a theorem, because proving it needs the Mean Value Theorem, which arrives in a few lessons.

The magnitude says steepness, in the units of the problem. A derivative of -0.25 for 1/x at x=2 says that increasing x by a small amount Δx decreases y by about 0.25Δx. At x=0.5 the derivative is -4, sixteen times steeper, which is the same curve behaving very differently at a different place.

Example. For f(x)=1/x, find f(0.5) and use it to estimate f(0.51).

The derivative is -1/x2, so f(0.5)=-1/0.25=-4. A step of 0.01 in x should therefore change y by about -4×0.01=-0.04, predicting f(0.51)2-0.04=1.96. The true value is 1/0.51=1.960784, so the prediction is right to three decimal places, and it was made without evaluating the function at the new point.

Now you. For f(x)=x3, whose derivative is 3x2, estimate f(2.01) from the value and derivative at x=2.

Answer

The derivative at x=2 is 12, so the estimate is 8+12×0.01=8.12. The true value is 8.120601, high by 0.0006.

A zero says flat. At a point where f(a)=0 the tangent is horizontal, which happens at the top of a hill, the bottom of a valley, and also at neither, as at x=0 on y=x3, where the curve merely pauses on its way up. Distinguishing those cases is the business of a later lesson.

What this costs, and what comes next

Every derivative in this lesson was computed by expanding a difference, cancelling an h, and taking a limit, and each took a paragraph. That is unsustainable. There is no chance of differentiating (3x2+1)10/x2+4 this way, and even x7 requires the binomial expansion to be written out.

There is also a strong hint that no such labour should be necessary, because the answers are suspiciously tidy: x2 gives 2x, x3 gives 3x2, x1/2 gives 12x-1/2, and x-1 gives -x-2. In every case the exponent has come down as a multiplier and dropped by one. If that pattern is genuine, and if the derivative of a sum, a product and a composition can be expressed in terms of the derivatives of the parts, then differentiation becomes mechanical and the limit definition retires to the role of justifying the rules.

That is exactly what happens, and the next lesson derives each rule from the definition rather than quoting it, because a rule whose derivation you have seen is a rule you can repair when you misremember it.

The rules of differentiation

Differentiating from the definition costs a paragraph of algebra per function, and the answers are tidy enough to suggest that most of that work is repeated in the same way each time.

This lesson extracts the repetition into four rules. Each is proved from the difference quotient of the previous lesson, because a rule you have seen derived is one you can rebuild when memory garbles it, and because two of the four have plausible wrong versions that a derivation immediately kills. After this, the limit definition retires: it stays as the justification and stops being a method.

Linearity

Start with the two easiest. If f and g are differentiable, so is f+g, and (f+g)=f+g. The proof is one line of rearrangement: the difference quotient of f+g is

[f(x+h)+g(x+h)]-[f(x)+g(x)]h=f(x+h)-f(x)h+g(x+h)-g(x)h

and the limit of a sum is the sum of the limits, which is one of the limit laws. Similarly (cf)=cf for a constant c, since the constant factors out of the quotient and then out of the limit.

Together these say that differentiation is linear, which is the property that lets a polynomial be differentiated term by term. It is worth noticing what is not claimed, because the pattern does not continue: there is no rule saying the derivative of a product is the product of the derivatives, and the next section shows why in one line.

A constant function has derivative zero, since every difference in the numerator is zero before any limit is taken. Geometrically it is a horizontal line, and the consequence for later work is that adding a constant to a function never changes its derivative, so a derivative cannot possibly determine its function uniquely.

The power rule

The pattern noticed at the end of the previous lesson, that xn differentiates to nxn-1, can be proved for every positive integer n using a factorisation from the earlier course:

xn-an=(x-a)(xn-1+xn-2a++xan-2+an-1)

Use the second form of the definition, with the quotient (f(x)-f(a))/(x-a). The factor (x-a) cancels exactly, leaving the long bracket, which is a polynomial and so may be evaluated at x=a by substitution. Every one of its terms becomes an-1, and there are n of them, so the limit is nan-1. Since a was arbitrary, f(x)=nxn-1 everywhere.

That covers positive integers. The quotient rule below extends it to negative integers, and the lesson on implicit differentiation extends it to every rational exponent; the result is the same formula in all cases, and it holds for irrational exponents too. So x7 differentiates to 7x6, which at x=2 is 448, and x=x1/2 differentiates to 12x-1/2, agreeing with the conjugate calculation done from scratch earlier.

With linearity, every polynomial is now immediate. The derivative of 3x4-5x2+7x-2 is 12x3-10x+7, written down in one pass with no limits anywhere.

The product rule

The plausible guess is (fg)=fg, and it is wrong. Test it on f(x)=g(x)=x: the product is x2, whose derivative is 2x, while the product of the derivatives is 1. A rule that fails on the simplest possible case needs no further refutation. Leibniz himself conjectured the product of the differentials in his early notes in 1675 and corrected it within days, which is a good indication that the correct rule is not obvious.

Here is the derivation. The numerator of the difference quotient is f(x+h)g(x+h)-f(x)g(x), and the trick is to add and subtract a hybrid term, f(x+h)g(x), which changes nothing and splits the difference into two differences that each move only one factor:

f(x+h)g(x+h)-f(x+h)g(x)+f(x+h)g(x)-f(x)g(x)

Group the first pair and the second pair, divide by h, and the quotient becomes

f(x+h)g(x+h)-g(x)h+g(x)f(x+h)-f(x)h

Now take the limit. The two quotients tend to g(x) and f(x). The stray factor f(x+h) tends to f(x), and it does so because f is differentiable and therefore continuous, which is where that theorem from the previous lesson earns its place. The result is

(fg)=fg+fg

The rule is symmetric, which is a useful check, and it explains the failed guess: the true derivative has two terms because a product can change by either factor moving, and fg counts neither of them.

Example. Differentiate (x2+1)(x3-2x) and evaluate the derivative at x=2.

With f=x2+1 and g=x3-2x, the derivatives are f=2x and g=3x2-2. The rule gives 2x(x3-2x)+(x2+1)(3x2-2). At x=2 the first term is 4×4=16 and the second is 5×10=50, so the derivative is 66. Check by expanding first: the product is x5-x3-2x, whose derivative is 5x4-3x2-2, giving 80-12-2=66. The two routes agree, as they must.

Now you. Differentiate (2x-1)(x2+3) and evaluate at x=1.

Answer

The rule gives 2(x2+3)+(2x-1)(2x), which at x=1 is 2×4+1×2=10. Expanding first gives 2x3-x2+6x-3, with derivative 6x2-2x+6, again 10 at x=1.

The quotient rule

For a quotient the result is

(fg)=fg-fgg2

valid wherever g0. It can be derived from the definition by the same add-and-subtract manoeuvre, but the quicker route is to write q=f/g, so that f=qg, and apply the product rule: f=qg+qg. Solving for q gives q=(f-qg)/g, and substituting q=f/g and tidying over the common denominator produces the formula.

The minus sign and the order of the terms are the two things people get wrong, and the way to check them is a special case you already know. Take f=1 and g=x. The rule gives (0x-11)/x2=-1/x2, which matches the first-principles calculation of the derivative of 1/x done earlier. If a misremembered version gives +1/x2, that test catches it at once.

The same special case extends the power rule downward. For f=1 and g=xn the rule gives -nxn-1/x2n=-nx-n-1, which is the power rule with the exponent -n in place of n. So the formula holds for negative integers too.

Example. Differentiate xx2+1 and evaluate at x=2.

Here f=x, f=1, g=x2+1, g=2x. The rule gives [(1)(x2+1)-x(2x)]/(x2+1)2=(1-x2)/(x2+1)2. At x=2 that is (1-4)/25=-0.12. The sign is negative, and it should be: this function peaks at x=1 and declines thereafter, and the formula makes the peak visible, since the numerator 1-x2 vanishes exactly at x=1.

Now you. Differentiate 3x+1x-2 and evaluate at x=3.

Answer

The rule gives [3(x-2)-(3x+1)]/(x-2)2=-7/(x-2)2. At x=3 that is -7. The derivative is negative for every x2, so the function is decreasing on each side of its asymptote.

The chain rule

The last rule is the one that matters most, because almost every function met in practice is a composition. Its statement, in Lagrange notation, is that if y=f(u) and u=g(x) then

dydx=dydududx

or equivalently (fg)(x)=f(g(x))g(x): differentiate the outside function, leave the inside alone in it, and multiply by the derivative of the inside.

The reason it is a product is a statement about rates. If a car's fuel use rises by 3 litres for each extra hour driven, and the cost rises by 1.60 for each extra litre, then the cost rises by 4.80 per extra hour, and the two rates multiply. The Leibniz form makes this look like cancellation of du, which is exactly why the notation was designed that way and exactly why the appearance is dangerous: the honest proof multiplies and divides by Δu, which is illegitimate whenever Δu happens to be zero, and repairing that gap takes a page. The gap is real, the repair is standard, and the rule is true.

Example. Differentiate x2+9 and evaluate at x=4.

The outside function is u, with derivative 1/(2u); the inside is u=x2+9, with derivative 2x. Multiplying gives 2x/(2x2+9)=x/x2+9. At x=4 the square root is 25=5, so the derivative is 4/5=0.8. That number has a geometric meaning: this function is the distance from the origin to a point moving along a horizontal line nine units up, and 0.8 is the component of the motion along the line of sight.

Now you. Differentiate (x3+1)5 and evaluate at x=1.

Answer

The outside is u5 with derivative 5u4; the inside is x3+1 with derivative 3x2. So the derivative is 5(x3+1)43x2=15x2(x3+1)4, which at x=1 is 15×16=240.

Compositions can be nested, and the rule composes with itself: each layer contributes its own derivative as a factor, working from the outside in. Differentiating (3x2+1)10 gives 10(3x2+1)96x, and at x=1 that is 60×49=15{,}728{,}640. The size of that number is a reminder that a modest-looking function can have an enormous rate of change, which is why exponents are where numerical trouble usually starts.

Assembling them

Real functions need several rules at once, and the only skill involved is deciding which structure is outermost before touching anything.

Take y=x2(2x+1)3x-1. The outermost structure is a quotient, so the quotient rule applies with f=x2(2x+1)3 and g=x-1. Differentiating f needs the product rule, with the second factor needing the chain rule: f=2x(2x+1)3+6x2(2x+1)2. Assembling, y=[f(x-1)-f]/(x-1)2. At x=2 the pieces are f=4×125=500 and f=4×125+6×4×25=1100, so y=(1100×1-500)/1=600.

The habit worth building is to name the pieces before differentiating anything, write the rule with the names, and only then substitute. Skipping that step is where the sign errors and the missing chain factors come from, and they come from it reliably.

Where the rules stop

Everything above is closed under the operations of algebra. Any function built from powers by adding, multiplying, dividing and composing can now be differentiated mechanically, and that class is large: all polynomials, all rational functions, all algebraic combinations of roots.

It does not include sinx, and it does not include 2x. No amount of the power rule reaches them, because they are not built from powers by algebra: the sine is defined by a rotation and the exponential by repeated multiplication extended to the continuum. Their difference quotients lead to limits that no factoring or conjugate will resolve, in particular limh0(sinh)/h and limh0(ah-1)/h.

Those two limits are the subject of the next lesson, and the second of them turns out to select a particular number as the natural base for an exponential, which is where e actually comes from.

Sines, exponentials and their derivatives

The rules of the previous lesson differentiate anything built from powers by algebra, and neither the sine nor an exponential is built that way, so each has to be taken back to the difference quotient.

What comes out is more interesting than a pair of formulas. The sine calculation only works in radians, and shows why. The exponential calculation produces a constant that depends on the base, and asking which base makes that constant equal to 1 is where the number e comes from, definitionally rather than as a decimal to memorise. This lesson assumes the unit circle definitions of sine and cosine and the exponential and logarithm laws from the earlier course.

Where the difference quotient leads

Apply the definition to f(x)=sinx. The numerator is sin(x+h)-sinx, and the addition formula sin(x+h)=sinxcosh+cosxsinh turns it into sinx(cosh-1)+cosxsinh. Dividing by h and grouping:

sin(x+h)-sinxh=sinxcosh-1h+cosxsinhh

Both bracketed quotients are 0/0 at h=0, and neither factors or rationalises. Neither depends on x, though, which is the important structural fact: two numbers settle the derivative of the sine at every point at once.

Numerically the two limits are not hard to guess. For h=0.001, (sinh)/h=0.99999983 and (1-cosh)/h=0.0005. So the candidates are 1 and 0, giving cosx as the derivative of sinx. Guessing is not proving, and the first of the two needs a genuine argument.

The squeeze that settles sinh/h

Take h between 0 and π/2 and draw the unit circle. Mark the angle h at the centre, and compare three regions: the triangle with vertices at the centre, at the point (1,0) and at the point on the circle; the circular sector between the same two radii; and the triangle formed by extending the radius to meet the tangent line at (1,0).

Each region contains the previous one, so their areas are ordered. The first triangle has base 1 and height sinh, so its area is 12sinh. The sector is the fraction h/2π of the whole disc of area π, so its area is 12h: this is the step that requires h to be measured in radians, since it is the radian measure that makes the arc length and the angle the same number. The outer triangle has base 1 and height tanh, so its area is 12tanh. Therefore

sinh<h<tanh

Divide throughout by sinh, which is positive, to get 1<h/sinh<1/cosh, and invert to get cosh<(sinh)/h<1. As h0 the left bound tends to 1 because cosine is continuous, and the right bound is 1. The squeeze theorem from the limits lesson does the rest:

limh0sinhh=1

The same holds from the negative side, since both sinh and h change sign together and the quotient is unchanged.

The second limit now follows by the conjugate trick. Multiply (1-cosh)/h above and below by 1+cosh: the numerator becomes 1-cos2h=sin2h, so the quotient is sinhhsinh1+cosh. The first factor tends to 1 and the second to 0/2=0, so the limit is 0, confirming the numerical guess.

The radian requirement is not a formality. Measure angles in degrees and the sector area argument gives hπ/360 instead of h/2, so the limit becomes π/180=0.0174533 and the derivative of the sine becomes 0.0174533cosx. That constant would then infest every formula in physics and engineering that involves an oscillation. Radians are used in calculus because they are the units in which this constant is 1.

The derivatives of the trigonometric functions

Substituting the two limits into the grouped difference quotient gives, immediately,

ddxsinx=cosxddxcosx=-sinx

with the second obtained the same way from the addition formula for cosine, and the minus sign coming from cos(x+h)=cosxcosh-sinxsinh.

Differentiating repeatedly cycles with period four: sine goes to cosine, to minus sine, to minus cosine, and back. The consequence is that y=sinx satisfies

y′′=-y

and so does cosx, and so does any combination Asinx+Bcosx. That equation is the mathematical content of simple harmonic motion: a mass on a spring obeys F=-kx, so by Newton's second law its acceleration is proportional to minus its displacement, which is this equation with a constant attached. The reason pendulums, tuning forks, LC circuits and molecular vibrations all produce sinusoids is that they all satisfy it.

The other trigonometric functions follow from the quotient rule. For tanx=sinx/cosx,

ddxtanx=cosxcosx-sinx(-sinx)cos2x=1cos2x=sec2x

which at x=π/4 equals 2, since the cosine there is 1/2. The derivative is never less than 1, matching the graph of the tangent, which rises everywhere and steepens without bound at the asymptotes.

Example. Differentiate f(x)=x2sinx and evaluate at x=π/2.

The product rule gives f(x)=2xsinx+x2cosx. At x=π/2 the sine is 1 and the cosine is 0, so the second term vanishes and the derivative is 2×π/2=π=3.14159.

Now you. Differentiate f(x)=sin(3x2) and evaluate at x=1.

Answer

The chain rule gives f(x)=cos(3x2)6x, which at x=1 is 6cos3=6×(-0.98999)=-5.93995. The value is negative because 3 radians is past the first quarter turn, where the sine is falling.

Where e comes from

Now the exponential. For f(x)=ax with a>0, the difference quotient is

ax+h-axh=axah-1h

using only the index law ax+h=axah. The factor ax is the original function, and the remaining quotient does not involve x at all. So if that limit exists, it is some constant k(a) depending on the base alone, and

ddxax=k(a)ax

This is already a remarkable statement: an exponential is proportional to its own derivative, whatever the base. It is the reason exponentials describe every process whose rate of change is proportional to the amount present, from radioactive decay to compound interest to a population with unlimited food.

The constant is easy to estimate. For a=2, the quotient at h=10-6 is 0.693147; for a=3, it is 1.098612. Neither is 1, and they straddle it, so somewhere between 2 and 3 there is a base for which the constant is exactly 1. Define e to be that base. Then

ddxex=ex

and ex is, up to a constant multiple, the only function that is its own derivative. Its value is e=2.718282, and the earlier course reached the same number from compound interest as the limit of (1+1/n)n, which gives 2.716924 at n=1000 and 2.718280 at n=106. The two descriptions agree, and this one explains why the number keeps appearing: it is selected by a derivative condition, not chosen for convenience.

The constants for other bases are then identified by writing a=elna, so ax=exlna, and the chain rule gives

ddxax=axlna

Compare the numbers: ln2=0.693147 and ln3=1.098612, exactly the two quotients measured above. The mystery constant was the natural logarithm of the base all along.

The derivative of the logarithm

The logarithm can be done directly from the definition, using the limit that defines e. For f(x)=lnx with x>0,

ln(x+h)-lnxh=1hln(1+hx)=1xxhln(1+hx)

Write n=x/h, which grows without bound as h0. The last two factors are nln(1+1/n)=ln[(1+1/n)n], and the bracket tends to e, whose logarithm is 1. So

ddxlnx=1x

This fills a hole left by the power rule. Differentiating xn gives nxn-1, so the derivatives of powers produce every power except x-1: to get it you would need n=0, and that term differentiates to zero instead. The function whose derivative is 1/x is not a power at all, it is the logarithm, and that gap will reappear as the one exception in the integration rules later.

For other bases, logax=lnx/lna, so the derivative is 1/(xlna). Once again the natural base is the one with no stray constant.

Example. Differentiate f(x)=e-2x and evaluate at x=0.5.

The chain rule with inside u=-2x gives f(x)=-2e-2x. At x=0.5 that is -2e-1=-0.735759. The derivative is negative everywhere, as it must be for a decaying quantity, and its magnitude is proportional to the value, which is the defining property of decay.

Now you. Differentiate f(x)=xex and evaluate at x=1.

Answer

The product rule gives f(x)=ex+xex=ex(1+x), which at x=1 is 2e=5.43656.

Decay, and reading a rate off a curve

The formula ddte-λt=-λe-λt is the whole of radioactive dating, and the numbers are worth doing once.

Carbon-14 has a half-life of 5730 years, meaning e-λ×5730=12, so λ=ln2/5730=1.20968×10-4 per year. A sample containing 1012 atoms of carbon-14 therefore decays at an initial rate of λN=1.20968×108 atoms per year, which is about 3.83 decays per second. That rate is directly measurable in a counter, and since the rate is proportional to the amount remaining, counting decays measures the amount, which dates the sample. The derivative is not a theoretical adornment here: it is the quantity the instrument reads.

Example. Caffeine leaves the bloodstream with a half-life of about 5 hours. For a 100 mg dose, find the rate of elimination at t=0 and at t=5 hours.

The decay constant is λ=ln2/5=0.138629 per hour, and the amount is N(t)=100e-λt mg. The rate is N(t)=-λN(t). At t=0 that is -0.138629×100=-13.86 mg per hour. At t=5 hours the amount has halved to 50 mg, so the rate is -6.93 mg per hour, exactly half. The elimination slows in proportion to what is left, which is why the tail of such a curve is so long.

Now you. A drug has a half-life of 8 hours and an initial dose of 250 mg. What is the elimination rate at t=0, and how much remains after 24 hours?

Answer

Here λ=ln2/8=0.0866434 per hour, so the initial rate is -0.0866434×250=-21.66 mg per hour. After 24 hours, three half-lives have passed, so 250/8=31.25 mg remains.

The library, and what it still cannot do

Between the algebraic rules and this lesson, the standard functions are all differentiable by inspection: powers, roots, rational functions, sines and cosines and tangents, exponentials to any base, and logarithms to any base, in any combination assembled by sums, products, quotients and composition.

Two things are still out of reach, and they turn out to be the same thing. Inverse functions have no derivative formula yet: nothing above differentiates arcsinx or arctanx, and the derivative of lnx had to be extracted by a special argument rather than obtained from the exponential it inverts. And curves that are not graphs of functions, such as the circle x2+y2=25, cannot be handled at all, because every technique so far assumes an explicit y=f(x).

One idea fixes both, and it amounts to differentiating an equation rather than a function. That is the next lesson.

Extrema and optimisation

The reason most people want calculus is to find the best of something: the cheapest container, the strongest beam, the angle that carries a projectile furthest, and the derivative answers such questions because the best is usually where the curve stops rising.

The previous lessons built the machinery to compute a derivative of anything. This one uses it, and it is the first lesson where calculus does work that could not be done without it. It also has to be careful: the condition everyone remembers, that the derivative vanishes at a maximum, is neither sufficient on its own nor applicable at every kind of maximum.

Two kinds of extreme

A function has a global maximum at c if f(c)f(x) for every x in the domain under consideration, and a local maximum if that inequality holds only for x near c. Minima are defined the same way with the inequality reversed. The distinction matters because the derivative is a local instrument: it can only ever report on the immediate neighbourhood of a point, so it detects local extremes and says nothing directly about global ones.

The bridge between them is the Extreme Value Theorem from the continuity lesson: a continuous function on a closed bounded interval does attain a global maximum and minimum. That theorem provides existence, and the derivative then narrows down the location. Without the theorem there would be no guarantee that the search is for something that exists.

The candidates are few. A global extreme on a closed interval must occur either at an endpoint, or at an interior point where the function has no derivative, or at an interior point where the derivative is zero. There is no fourth possibility, and the reason is the next result.

Fermat's condition

Suppose f has a local maximum at an interior point c and is differentiable there. Look at the difference quotient (f(c+h)-f(c))/h. For small positive h the numerator is at most zero, since f(c) is the largest nearby value, so the quotient is at most zero and the right-hand limit is 0. For small negative h the numerator is still at most zero but the denominator is now negative, so the quotient is at least zero and the left-hand limit is 0. The derivative exists, so both one-sided limits equal it, and a number that is both 0 and 0 is zero:

f(c)=0

That is Fermat's theorem, stated by Pierre de Fermat around 1636, decades before Newton and Leibniz, in a method for maxima and minima that he never justified with limits.

Two warnings come attached. First, the converse is false. For f(x)=x3 the derivative at zero vanishes, and zero is neither a maximum nor a minimum: the curve is rising on both sides and merely pauses. A vanishing derivative is a necessary condition, not a sufficient one. Second, the theorem assumes differentiability. The function |x| has a genuine minimum at zero, where its derivative does not exist, so a search that only solves f=0 would miss it entirely.

A point where f(c)=0 or where f(c) fails to exist is called a critical point, and Fermat's theorem says the interior extremes are among them.

The closed interval method

For a continuous function on [a,b] the whole procedure is now mechanical: find every critical point in the interval, evaluate f there and at both endpoints, and compare the numbers. The largest is the global maximum and the smallest the global minimum. No test for the type of critical point is needed, because comparing values settles it directly.

Example. Find the global extremes of f(x)=x3-6x2+9x+2 on [0,5].

The derivative is f(x)=3x2-12x+9=3(x-1)(x-3), so the critical points are x=1 and x=3, both inside the interval. Evaluating: f(0)=2, f(1)=6, f(3)=2, f(5)=22. The global maximum is 22, at the right endpoint, and the global minimum is 2, attained twice, at x=0 and x=3. Notice that the largest value is at an endpoint where the derivative is not zero at all, which is exactly why endpoints must be checked.

Now you. Find the global extremes of f(x)=x4-8x2+3 on [-1,3].

Answer

The derivative is 4x3-16x=4x(x-2)(x+2), so the critical points are 0, 2 and -2, of which the first two lie in the interval. Evaluating: f(-1)=-4, f(0)=3, f(2)=-13, f(3)=12. The maximum is 12 at x=3 and the minimum is -13 at x=2.

Telling the critical points apart

When the domain is not a closed interval, or when the shape of the curve is wanted rather than one number, the critical points have to be classified.

The first derivative test reads the sign of f on each side. If f changes from positive to negative at c, the function rises then falls, so c is a local maximum; negative to positive gives a local minimum; no change of sign gives neither, which is the x3 case. For the cubic above, f=3(x-1)(x-3) is positive before 1, negative between 1 and 3, and positive after 3, so x=1 is a local maximum and x=3 a local minimum, matching the values computed.

The second derivative test is quicker when it works. The sign of f′′ measures concavity: where f′′>0 the slope is increasing and the curve bends upward like a bowl, and where f′′<0 it bends downward like a dome. So at a critical point with f′′(c)>0 there is a local minimum, and with f′′(c)<0 a local maximum. For the cubic, f′′=6x-12, which is -6 at x=1 and +6 at x=3, confirming the classification in two substitutions.

The test is silent when f′′(c)=0, and the silence is genuine rather than a defect in the statement: x4, -x4 and x3 all have vanishing first and second derivatives at the origin, and they have a minimum, a maximum and neither. When the second derivative test says nothing, fall back on the first.

A point where the concavity changes is an inflection point. For a cubic there is exactly one, at x=2 here, and it is where the curve is steepest between its two turning points. Inflections matter physically: on a graph of position against time, the inflection is where the acceleration reverses, and on a curve of a population against time, it is the moment growth stops accelerating and starts slowing, which is the peak of the epidemic rather than its end.

Optimising a real thing

A word problem becomes a calculus problem in four steps: name the quantity to be optimised, express it in terms of one variable using whatever constraint the problem supplies, differentiate and solve, and check that the critical point is the kind of extreme wanted.

Example. A cylindrical can is to hold 355 mL. What radius and height use the least metal?

Metal used is surface area, A=2πr2+2πrh, in two variables. The constraint is the volume, πr2h=355, so h=355/(πr2), and substituting removes h:

A(r)=2πr2+710r

Differentiate: A(r)=4πr-710/r2. Setting this to zero gives 4πr3=710, so r3=56.50 and r=3.837 cm. Then h=355/(π×14.724)=7.674 cm, which is exactly 2r. The optimal can is as tall as it is wide, and its surface area is 277.5 cm². The second derivative, A′′=4π+1420/r3, is positive for every positive r, so this is a minimum, and since A at both ends of the domain it is the global one.

Now you. An open-topped box is made from a 30 cm square sheet by cutting a square of side x from each corner and folding up the sides. What x maximises the volume?

Answer

The volume is V=x(30-2x)2 for 0<x<15. Differentiating with the product and chain rules gives V=(30-2x)2-4x(30-2x)=(30-2x)(30-6x), which vanishes at x=15, outside the useful range, and at x=5. So x=5 cm, giving a volume of 5×400=2000 cm³. Checking either side confirms it: x=4 gives 1936 and x=6 gives 1944.

The can result deserves an honest postscript, because real drink cans are nowhere near h=2r. A 330 mL can has a radius of about 3.3 cm and a height of about 9.6 cm, far taller than the optimum. The model is not wrong, it is incomplete: the ends of a can are thicker than the wall and are stamped from different stock, so they cost more per square centimetre; the rim requires a seam; and a can has to fit a hand and a vending machine slot. Minimising area subject to volume is one term of an objective function with several. What calculus supplies is the answer to the question actually asked, which is why stating the question carefully is most of the work.

Snell's law from a minimum

The most famous optimisation in physics is the one that derives the law of refraction, and it needs nothing beyond this lesson.

Light travels from a point in air to a point in water. Its speed is v1 above the surface and v2<v1 below. Pierre de Fermat proposed in 1662 that the path taken is the one of least time, which is a claim to be tested rather than assumed. Let the light cross the surface at horizontal position x, so that the two path lengths are a2+x2 and b2+(d-x)2, where a and b are the perpendicular distances of the two points from the surface and d is the horizontal separation. The total time is

T(x)=a2+x2v1+b2+(d-x)2v2

Differentiating with the chain rule gives

T(x)=xv1a2+x2-d-xv2b2+(d-x)2

Now read the two fractions geometrically. In the upper triangle, x is the side opposite the angle from the vertical and a2+x2 is the hypotenuse, so their ratio is sinθ1; likewise the other ratio is sinθ2. Setting T=0 gives

sinθ1v1=sinθ2v2

which is Snell's law, published by Willebrord Snellius in 1621 as an empirical regularity and derived here from a minimum principle. Since the refractive index is n=c/v, it takes the familiar form n1sinθ1=n2sinθ2.

Example. Light strikes water at 30 degrees from the normal. Water has n=1.333. Find the refraction angle.

Snell's law gives sinθ2=sin30/1.333=0.5/1.333=0.375, so θ2=22.03 degrees. The ray bends toward the normal on entering the slower medium, which is what the minimum-time principle predicts: light spends less of its path in the slow medium by turning.

Now you. A projectile launched at speed v and angle θ over level ground travels a distance R=v2sin(2θ)/g. Find the angle giving maximum range, and the range for v=20 m/s.

Answer

Differentiating with respect to θ gives R=2v2cos(2θ)/g, which vanishes when 2θ=π/2, so θ=45 degrees. There sin(2θ)=1 and the range is v2/g=400/9.8=40.8 m. The second derivative is negative there, confirming a maximum.

What is still owed

Every conclusion in this lesson rests on two claims that have not been proved: that a function is increasing wherever its derivative is positive, and that concavity is read off the sign of the second derivative. Both were used freely and both sound obvious.

They are not obvious, and they cannot be proved directly from the definition of the derivative, because the derivative is a local statement and "increasing on an interval" is a global one. Something is needed to carry information from one point to a whole interval, and that something is the Mean Value Theorem.

It also delivers a second result which matters more for the rest of the course: that two functions with the same derivative everywhere can differ only by a constant. That single fact is what makes it possible to run differentiation backwards at all, and running it backwards is the entire second half of this subject.

The Mean Value Theorem

A derivative is a statement about a single point, and almost everything anyone wants to conclude from it is a statement about an interval, so a theorem is needed to carry the information across.

The previous lesson used two such conclusions without proof: that a function rises wherever its derivative is positive, and that concavity follows the sign of the second derivative. Both are consequences of one theorem, which also delivers the result the second half of this course is built on, that two functions with equal derivatives differ by a constant. This lesson proves it and then spends the rest of its length collecting what falls out.

Rolle's theorem

Start with the special case. Suppose f is continuous on the closed interval [a,b], differentiable on the open interval between, and f(a)=f(b). Then there is at least one point c strictly between a and b with f(c)=0.

The proof uses two earlier theorems and nothing else. By the Extreme Value Theorem, f attains a maximum and a minimum on [a,b]. If both occur at the endpoints, then the largest and smallest values of f are equal, so f is constant and its derivative vanishes everywhere in between. Otherwise at least one of them occurs at an interior point c, and by Fermat's theorem, an interior extreme of a differentiable function has f(c)=0.

That is the whole argument, and its shape is worth noticing: continuity supplies existence, differentiability supplies the equation. Michel Rolle published the result in 1691, which is a mild historical joke, since Rolle spent the same decade denouncing the infinitesimal calculus as a collection of ingenious fallacies. He was right about the reasoning of the time and wrong about the conclusions.

The Mean Value Theorem

The general version drops the condition f(a)=f(b) and tilts the conclusion by the same amount. If f is continuous on [a,b] and differentiable in between, there is a point c with

f(c)=f(b)-f(a)b-a

In words: somewhere in the interval the instantaneous rate of change equals the average rate of change over the whole interval. Geometrically, some tangent is parallel to the chord joining the endpoints.

The proof is Rolle's theorem applied to a tilted copy of f. Let L(x) be the straight line through the two endpoints, and set g(x)=f(x)-L(x), the vertical gap between the curve and the chord. Then g is continuous and differentiable wherever f is, and g(a)=g(b)=0 because the chord meets the curve at both ends. Rolle gives a point c with g(c)=0, and since L is a line with slope (f(b)-f(a))/(b-a), that says precisely f(c)=(f(b)-f(a))/(b-a).

The theorem is an existence statement: it promises a c and gives no way to find one, and there may be several. That is enough for everything it is used for, which is a recurring pattern in analysis.

There is a legal application, which is the clearest illustration of what the theorem says. Average speed enforcement on motorways photographs a vehicle at two points and divides the distance by the time. If a car covers 180 km in two hours, its average speed was 90 km/h, and the Mean Value Theorem says that at some instant the speedometer read exactly 90. The camera never observed that instant and does not need to: the mathematics guarantees it happened.

Example. Find a point satisfying the Mean Value Theorem for f(x)=x3-x on [0,2].

The endpoint values are f(0)=0 and f(2)=6, so the average slope is 3. The derivative is f(x)=3x2-1, and setting it equal to 3 gives x2=4/3, so c=1.1547, which lies in the interval as promised. The negative root, -1.1547, also satisfies the equation but is outside the interval and is not what the theorem is about.

Now you. Find a point satisfying the theorem for f(x)=x on [1,4].

Answer

The average slope is (2-1)/(4-1)=1/3. The derivative is 1/(2x), so 1/(2c)=1/3 gives c=1.5 and c=2.25.

What a zero derivative means

The first corollary looks too small to be worth stating and is the most important result in the lesson.

If f(x)=0 at every point of an interval, then f is constant on that interval. Here is the proof: take any two points p<q in the interval and apply the Mean Value Theorem to [p,q]. It gives a c with f(q)-f(p)=f(c)(q-p)=0, so f(q)=f(p). Since the two points were arbitrary, every value is the same value.

The statement cannot be proved without a theorem of this kind. Knowing the derivative is zero at each point separately says only that the function is momentarily flat at each point, and it takes the Mean Value Theorem to rule out a function that is flat everywhere and still manages to move. The hypothesis that the domain is an interval is also load-bearing: the function equal to 0 for x<0 and 1 for x>0 has zero derivative throughout its domain and is not constant, because its domain is in two pieces.

The second corollary follows immediately. If f(x)=g(x) everywhere on an interval, apply the first corollary to f-g, whose derivative is zero. So

f(x)=g(x)+C

for some constant C. Two functions with the same derivative differ by a constant and by nothing else.

This is the fact that makes the second half of the subject possible. It says that a derivative determines its function completely except for one number, so the question "which function has derivative 2x" has the answer "x2, plus a constant, and nothing else". Without it, running differentiation backwards would be hopeless, since there would be no way to know whether a discovered answer was the only one.

Rising, falling, and bending

The remaining corollaries retire the debts of the previous lesson.

If f>0 throughout an interval, then f is increasing on it. Proof: for any p<q in the interval, the Mean Value Theorem gives f(q)-f(p)=f(c)(q-p), in which both factors are positive, so f(q)>f(p). If f<0 the same argument gives decreasing. That is the first derivative test justified, and with it every sign chart drawn in the optimisation lesson.

Applying the same result to f instead of f justifies the concavity reading. If f′′>0 on an interval then f is increasing there, so the tangent slopes get steeper as x increases, which is what it means for a curve to bend upward. The second derivative test follows: at a critical point with f′′>0, the slope is negative just before and positive just after, so the first derivative test gives a local minimum.

The theorem also produces inequalities, which is a use that is easy to overlook. Since |cosc|1 for every c, the Mean Value Theorem applied to the sine gives |sinq-sinp|=|cosc||q-p||q-p|. So the sine function never changes faster than its argument, which is a bound valid for all real numbers, obtained from one fact about the derivative. Bounds of exactly this kind are what numerical analysis runs on.

The tangent line as an approximation

Near a point where a function is differentiable, the tangent line is a good approximation to the curve, and the Mean Value Theorem says how good. Write the linearisation of f at a:

L(x)=f(a)+f(a)(x-a)

The theorem gives f(x)-f(a)=f(c)(x-a) for some c between a and x, so the error f(x)-L(x) equals [f(c)-f(a)](x-a). Whenever the derivative varies slowly, that product is small, and it shrinks faster than x-a does, since the bracket also shrinks as x approaches a.

Example. Estimate 4.1 using the tangent line at x=4, and compare with the true value.

With f(x)=x we have f(4)=2 and f(4)=1/(2×2)=0.25, so L(4.1)=2+0.25×0.1=2.025. The true value is 2.0248457, so the estimate is high by 0.00015, an error of about 0.008 per cent from arithmetic that can be done in the head.

Now you. Estimate (1.02)10 using the tangent line at x=1, and compare.

Answer

With f(x)=x10, f(1)=1 and f(1)=10, so L(1.02)=1+10×0.02=1.2. The true value is 1.218994, so the linear estimate is low by about 1.6 per cent. The error is much larger here than in the square root case because the second derivative, 90x8, is large: the curve pulls away from its tangent quickly.

The pattern in those two errors is that the accuracy depends on how fast the slope is changing, which suggests including the second derivative in the approximation and then the third, and that idea is carried through in the last lesson of the course.

L'Hôpital's rule

One more consequence of the Mean Value Theorem deserves its own name, because it disposes of indeterminate forms that no algebraic trick will touch.

If f(a)=g(a)=0, both are differentiable near a, and g0 nearby, then

limxaf(x)g(x)=limxaf(x)g(x)

whenever the right side exists. The same holds for the / form and for limits at infinity. The proof uses a two-function version of the Mean Value Theorem due to Cauchy, in which the ratio of the two average rates equals the ratio of the two derivatives at a common point; the argument is short but adds nothing to the picture, so it is quoted here rather than derived. The rule appeared in the first calculus textbook, published by the Marquis de l'Hôpital in 1696, and was in fact discovered by Johann Bernoulli, whom l'Hôpital paid for the material.

Two limits from earlier lessons fall out at once. For (sinx)/x at zero, differentiating top and bottom gives cosx/11, matching the geometric squeeze, though it would be circular to use this as the proof, since the derivative of the sine was obtained from that limit. For (ex-1)/x the rule gives ex/11.

Example. Evaluate limx01-cosxx2.

Substituting gives 0/0. One application gives lim(sinx)/(2x), still 0/0, so apply it again: lim(cosx)/2=1/2. Numerically, at x=0.001 the original expression is 0.49999996, confirming it. This limit is why a pendulum's period barely changes for small swings, and it will reappear in the Taylor lesson as the second term of the cosine series.

Now you. Evaluate limx0sinx-xx3.

Answer

Three applications are needed, since each stage is still 0/0: first (cosx-1)/(3x2), then -sinx/(6x), then -cosx/6, which tends to -1/6. At x=0.01 the original expression is -0.1666658.

The rule has one failure mode, and it is common. It applies only to indeterminate forms, and applying it elsewhere gives confident nonsense. Take limx1(x2+x)/(x+1): the limit is plainly 2/2=1 by substitution, but differentiating top and bottom gives (2x+1)/13. Nothing warns you. The check is to confirm the form is 0/0 or / before each application, including the second and third.

Backwards

The corollary about constants leaves an obvious question hanging. If a derivative determines its function up to one number, then the process ought to be reversible: given a rate of change, recover the quantity.

That question has an answer, and there is a second, apparently unrelated question with the same answer. The area problem from the first lesson has been left untouched since then, and it is about to be defined properly, as a limit of sums rather than a search for a function with a given derivative. That the two turn out to be the same operation is the central theorem of the subject, and the next two lessons build to it.

The integral

The area under a curve was one of the two problems that opened this course, and it has been left alone since, because defining it honestly requires the limit and the definition matters more than the answer.

The temptation is to say that the area is obviously there and calculus merely computes it. That will not do. Elementary geometry defines area for polygons and for a few special curved regions, and says nothing about the region under an arbitrary curve. What follows defines it, in a way that turns out to apply to far more than areas.

Rectangles, systematically

Take a function f on an interval [a,b], and assume for the moment that it is positive. Cut the interval into n pieces of equal width Δx=(b-a)/n, with division points x0=a, x1, up to xn=b. On each piece erect a rectangle whose height is the value of f at some chosen point of that piece. The total area of the rectangles is

Sn=k=1nf(xk*)Δx

where xk* is the chosen point in the k-th piece. A sum of this shape is a Riemann sum, after Bernhard Riemann, who gave the definition its modern form in his habilitation thesis of 1854.

Three choices of sample point are standard. Taking the right end of each piece gives the right sum, the left end gives the left sum, and the midpoint gives the midpoint sum, which is usually much more accurate. For a function that only rises, the left sum is an underestimate and the right sum an overestimate, which brackets the answer, and that bracketing is what made the numerical experiments of the first lesson convincing.

The definition to aim at is that the area is the common value all these sums approach as n grows, regardless of which sample points are used. That is a strong requirement, and part of the work below is checking that it is ever satisfied.

Computing one by hand

Take f(x)=x2 on [0,1], the case estimated numerically in the first lesson, and do it exactly.

With n strips the width is 1/n and the right-hand sample points are xk=k/n, so

Sn=k=1n(kn)21n=1n3k=1nk2

The sum of the first n squares has the closed form n(n+1)(2n+1)/6, proved by induction in the previous course. Substituting,

Sn=n(n+1)(2n+1)6n3=13(1+1n)(1+12n)

after dividing out the powers of n. Now the limit is easy: both brackets tend to 1, so Sn1/3.

The formula also reproduces the numerical estimates exactly. At n=10 it gives 0.385, at n=100 it gives 0.33835, and at n=1000 it gives 0.3338335, all matching the direct sums computed earlier. The convergence is slow, roughly one extra correct digit per tenfold increase in n, which is characteristic of a method whose error falls like 1/n.

Example. Compute 01x3dx from the definition, using k=1nk3=[n(n+1)/2]2.

The right sum is (1/n4)k3=n2(n+1)2/(4n4)=14(1+1/n)2. As n grows this tends to 1/4. At n=4 the formula gives 14(1.25)2=0.390625, which matches the direct sum 1256(1+8+27+64), and at n=100 it gives 0.255025, closing on 0.25 from above.

Now you. Compute 02xdx from the definition, using k=1nk=n(n+1)/2.

Answer

The width is 2/n and the sample points are 2k/n, so the sum is (4/n2)k=4n(n+1)/(2n2)=2(1+1/n), which tends to 2. The region is a triangle of base 2 and height 2, whose area is 2, so the machinery agrees with geometry on a case where geometry has an answer.

The definition, and which functions have one

The definite integral of f from a to b is written

abf(x)dx

and is defined to be the limit of the Riemann sums as the width of the widest strip tends to zero, provided that limit exists and is the same for every choice of sample points. When it does, f is integrable on [a,b].

Every part of the notation records a part of the construction. The sign is an elongated S for "sum", introduced by Leibniz in 1675. The f(x) is the height of a rectangle and the dx is its width, so the product under the sign is the area of one infinitely thin strip, and the sign totals them. The a and b record the range. The variable is a placeholder with no meaning outside the integral, so abf(x)dx and abf(t)dt are the same number.

The existence question is settled by two theorems worth knowing without their proofs. First, every continuous function on a closed bounded interval is integrable. Second, a bounded function with only finitely many discontinuities is integrable too, so a step function is fine. Since almost everything met in practice satisfies one of these, integrability is normally not something to worry about.

That it is not automatic can be shown with one example. Let f(x) be 1 at every rational number and 0 at every irrational, a function due to Dirichlet in 1829. Every strip, however thin, contains both kinds of number, so by choosing rational sample points every Riemann sum is b-a, and by choosing irrational ones every sum is 0. The sums do not converge to a common value, and this function has no Riemann integral at all. It is the standard demonstration that "area under the graph" is not a meaningful phrase for every function, which is exactly why the definition is stated in terms of sums rather than assumed from a picture.

Signed area

Nothing in the definition requires f to be positive. Where f is negative the rectangle heights are negative, and the sum counts that region as negative area. So the integral measures signed area: regions above the axis count positively and regions below count negatively.

This is a feature rather than a defect, because it is what the applications need. If v(t) is a velocity that changes sign, then vdt is the displacement, not the distance travelled, and the cancellation is correct: a body that goes out and comes back has zero displacement. To get the distance you integrate |v| instead, which is a different and usually harder problem.

The cleanest illustration is 02πsinxdx=0. The first half-wave is above the axis and the second below, and they are congruent, so the signed total vanishes while the total area enclosed is 4.

Properties that follow from the definition

Every rule below comes from the corresponding property of sums, since a limit of sums inherits whatever the sums have.

Integration is linear: (f+g)=f+g and cf=cf, because each Riemann sum splits that way. Integrals add over adjacent intervals, acf=abf+bcf, since cutting the interval at b and summing the pieces separately gives the same total. Reversing the limits reverses the sign, baf=-abf, which is a convention chosen precisely so that the additivity rule holds for any three points regardless of their order. And aaf=0, since the strips have zero width.

Comparison also survives: if fg throughout the interval then abfabg, and in particular if mfM then

m(b-a)abf(x)dxM(b-a)

which is often the fastest way to bound an integral you cannot compute.

Example. Given 03f=8 and 01f=3, find 13f and 30f.

Additivity gives 01f+13f=03f, so 13f=8-3=5. Reversing the limits changes the sign, so 30f=-8.

Now you. Given 14f=10 and 14g=-2, find 14(3f-2g).

Answer

Linearity gives 3×10-2×(-2)=30+4=34.

The average value of a function

The bounds above have a consequence that the next lesson needs. Divide the inequality by b-a: the quantity

1b-aabf(x)dx

lies between the smallest and largest values of f on the interval. If f is continuous, the Intermediate Value Theorem says f attains every value in between, so there is a point c in [a,b] with

f(c)=1b-aabf(x)dx

This is the Mean Value Theorem for integrals, and the quantity on the right is the average value of f over the interval. It generalises the ordinary average: adding n sample values and dividing by n is exactly a Riemann sum divided by the interval length, and letting n grow gives the integral form. Geometrically, the rectangle of height f(c) over the interval has the same area as the region under the curve.

Example. Estimate 121xdx with a midpoint sum using four strips, and compare it with the true value.

The strips have width 0.25 and midpoints 1.125, 1.375, 1.625 and 1.875. The corresponding heights are 0.888889, 0.727273, 0.615385 and 0.533333, summing to 2.764880, so the estimate is 0.25×2.764880=0.691220. The true value is ln2=0.693147, so four midpoint rectangles are already accurate to three decimal places, far better than the right sums used earlier. The average value of 1/x on this interval is therefore about 0.693, which is the height of the equivalent rectangle.

Now you. Estimate the same integral with a midpoint sum using two strips.

Answer

The midpoints are 1.25 and 1.75, with heights 0.8 and 0.571429. The estimate is 0.5×1.371429=0.685714, low by about 1.1 per cent. Halving the number of strips roughly quadrupled the error, which is the behaviour of the midpoint rule.

The cost of the definition

The definition works, and it is unusable as a method. Getting 01x2 required a closed form for the sum of squares, and 01x3 required the sum of cubes. For 01x4 there is a formula too, and it is worse. For 0πsinxdx the Riemann sum needs a closed form for a sum of sines in arithmetic progression, which exists but is an exercise in its own right. For a function assembled from several others, nothing helps at all.

So the area problem is now properly defined and no easier to compute than it was for Archimedes. What changes everything is a connection that has been visible since the first lesson without being proved: that accumulating a rate recovers the quantity, so the area under a velocity curve is a displacement. If the integral of f can be found by asking which function has f as its derivative, then every rule in the differentiation lessons becomes an integration rule read backwards, and the sums never have to be done.

That is the Fundamental Theorem of Calculus, and it is next.

The Fundamental Theorem

The area under a curve has been defined as a limit of sums, and computing even the simplest case took a closed form for the sum of squares, so the definition needs to be rescued by a theorem.

The rescue is the result that gives this course its shape: the two problems of the first lesson, the slope and the area, are inverse operations. Everything needed for the proof is already available, namely the Mean Value Theorem for integrals from the previous lesson and the corollary from the lesson before it that two functions with the same derivative differ by a constant.

The area so far

Fix a function f, continuous on [a,b], and define a new function by letting the upper limit vary:

A(x)=axf(t)dt

This is the area accumulated from the fixed left end a up to the movable point x. The variable of integration is written t rather than x deliberately, because x is now doing a different job as the endpoint; using the same letter for both is a common source of confusion and no more than that, since the variable of integration means nothing outside the integral.

A is a perfectly ordinary function. For f(t)=t2 and a=0, the calculation of the previous lesson generalises to give A(x)=x3/3: the same Riemann sum with x in place of 1 produces x3 times the same limit. Differentiate that and you get x2, which is f again. That is not a coincidence, and it is not special to this function.

The first half

Fundamental Theorem, part one. If f is continuous on [a,b], then A is differentiable and A(x)=f(x) for every x in the interval.

The proof takes four lines. The difference A(x+h)-A(x) is ax+hf-axf, which by additivity is xx+hf: the area of the thin sliver between x and x+h. So the difference quotient is

A(x+h)-A(x)h=1hxx+hf(t)dt

and the right side is exactly the average value of f over the sliver. By the Mean Value Theorem for integrals there is a point c between x and x+h where f(c) equals that average. As h0 the point c is squeezed toward x, and since f is continuous, f(c)f(x). Therefore A(x)=f(x).

Read as a sentence, it says the rate at which area accumulates is the height of the curve, which is obvious once heard: widen the region by a sliver of width h and you gain about f(x)h of area. Continuity is what makes "about" into "exactly in the limit".

The immediate consequence is an existence theorem that nothing else supplies: every continuous function has an antiderivative, namely its own area function. Whether that antiderivative can be written in terms of familiar functions is a separate question, and often the answer is no.

The second half

Fundamental Theorem, part two. If f is continuous on [a,b] and F is any function with F=f there, then

abf(x)dx=F(b)-F(a)

The proof is where the Mean Value Theorem pays for itself. By part one, A is an antiderivative of f. So F and A have the same derivative on the interval, and by the corollary proved two lessons ago they differ by a constant: F(x)=A(x)+C. Now evaluate at both ends and subtract. Since A(a)=0, we get F(b)-F(a)=A(b)-A(a)=A(b), which is abf.

The word any in the statement is what the corollary buys. There are infinitely many antiderivatives, differing by a constant, and every one of them gives the same answer because the constant cancels in the subtraction. Without the theorem that they differ only by a constant, there would be no reason to expect that.

A function with F=f is called an antiderivative of f, and the whole family is written with the indefinite integral sign,

f(x)dx=F(x)+C

The C is not decoration. Omitting it makes no difference in a definite integral, and it is the entire content of the answer in a differential equation, where the constant is fixed by an initial condition.

What this actually means

Two problems that look unrelated, the slope of a curve and the area under one, have turned out to be inverse operations. Differentiating an area function returns the integrand; integrating a derivative returns the original function up to a constant.

That is the discovery Newton and Leibniz are credited with, and it is worth being precise about the credit. Tangents had been drawn by Fermat and Descartes, and areas computed by Cavalieri, Wallis and others, before either of them was born. What neither predecessor had was the theorem connecting the two, which converts an intractable limit of sums into a search for an antiderivative, and it is the connection that turned a collection of clever special cases into a subject with an algorithm.

Practically, the theorem hands over a table of integrals for free: every differentiation rule, read backwards, is an antiderivative. From the power rule, xndx=xn+1/(n+1)+C for every n except -1, where the formula would divide by zero and where the answer is instead ln|x|+C, the gap in the power rule noticed in the transcendental lesson. From the trigonometric derivatives, sinxdx=-cosx+C and cosxdx=sinx+C. From the exponential, exdx=ex+C. From the inverse functions, dx/(1+x2)=arctanx+C and dx/1-x2=arcsinx+C.

Example. Evaluate 0πsinxdx and 12dxx.

An antiderivative of sinx is -cosx, so the first integral is [-cosx] evaluated from 0 to π, which is -cosπ+cos0=1+1=2. An antiderivative of 1/x is lnx, positive throughout [1,2], so the second is ln2-ln1=0.693147. Compare that with the previous lesson, where four midpoint rectangles gave 0.691220 after a paragraph of arithmetic: the theorem produces a better answer in one line.

Now you. Evaluate 02(3x2-2x)dx.

Answer

An antiderivative is x3-x2, so the value is (8-4)-(0-0)=4.

Net change

Part two, read in the other direction, is the statement that most applications actually use. If F is any quantity and F its rate of change, then

abF(t)dt=F(b)-F(a)

the total change in the quantity over the interval. Integrating a rate recovers the amount. That single sentence covers a velocity integrating to a displacement, a flow rate integrating to a volume, a power integrating to an energy, a current integrating to a charge, and a marginal cost integrating to a total cost.

Example. Water flows into a tank at r(t)=200+20t litres per minute. How much enters during the first ten minutes?

The amount is 010(200+20t)dt. An antiderivative is 200t+10t2, so the value is 2000+1000=3000 litres. The check is available because the rate is linear: it runs from 200 to 400 litres per minute, averaging 300, and 300×10=3000.

Now you. A particle has velocity v(t)=t2-4 metres per second. Find its displacement over the first three seconds, and the distance it travels.

Answer

The antiderivative is t3/3-4t, so the displacement is (9-12)-0=-3 metres: it ends up three metres behind where it started. For the distance, note that v<0 until t=2 and positive after. Over the first stretch the position falls by 5.333 metres, and the second contributes -3-(-5.333)=2.333 metres, so the distance travelled is 7.667 metres.

Where part two goes wrong

The hypothesis that f is continuous on the whole interval is not a formality, and skipping it produces answers that are visibly absurd.

Consider -11dxx2. An antiderivative of x-2 is -x-1, and evaluating gives -1-(+1)=-2. That is impossible: the integrand is positive everywhere it is defined, so any sensible notion of area cannot be negative. The error is that the integrand is unbounded at x=0, which is inside the interval, so it is not continuous there and the theorem does not apply. The integral is in fact divergent, in the sense made precise in a later lesson.

The lesson generalises. Before quoting an antiderivative across an interval, check that both the function and the antiderivative behave throughout it. Integrands with a vertical asymptote inside the range, and antiderivatives such as tanx that jump at a point of the range, are where confident nonsense comes from.

Part one with a chain rule

Part one is used less often for computing and more often for differentiating a function that is defined as an integral, which happens whenever an antiderivative cannot be written down.

If the upper limit is a function of x rather than x itself, the chain rule applies. Writing G(x)=au(x)f(t)dt as a composition of the area function with u, part one gives A=f and so

G(x)=f(u(x))u(x)

Example. Differentiate G(x)=1x3lntdt and evaluate at x=2.

Here f(t)=lnt and u=x3, so G(x)=ln(x3)3x2=9x2lnx. At x=2 that is 36ln2=24.953. No antiderivative of lnt was needed, and none was used.

Now you. Differentiate G(x)=0x21+tdt and evaluate at x=2.

Answer

With u=x2, the rule gives G(x)=1+x22x, which at x=2 is 45=8.944.

Functions defined this way are not exotic. The error function of statistics is erf(x), defined as a multiple of 0xe-t2dt, and the sine integral of optics is 0x(sint)/tdt. Neither integrand has an antiderivative expressible in elementary terms, so the integral is the definition, and part one is what says these functions are differentiable and gives their derivatives.

The new difficulty

The theorem has moved the problem rather than removing it. Every definite integral is now as easy as recognising the integrand as somebody's derivative, and that recognition is the hard part.

Differentiation is an algorithm: apply the rules from the outside in and an answer always comes out. Antidifferentiation is a search. There is no rule that inverts the product rule directly, no rule that inverts the chain rule directly, and no procedure guaranteed to terminate. What exists instead is a set of techniques that convert unfamiliar integrands into familiar ones, and a large body of integrals that no technique will ever crack because their antiderivatives are not elementary functions at all.

The next lesson covers the techniques, and is honest about where they stop.

Techniques of integration

Every definite integral is now a search for an antiderivative, and unlike differentiation, that search has no algorithm that always terminates.

The asymmetry is worth stating plainly at the start. Differentiating is mechanical: identify the outermost structure, apply the matching rule, recurse, and an answer always appears. Antidifferentiating is pattern recognition, assisted by a handful of transformations that convert an unfamiliar integrand into a familiar one. This lesson covers the transformations that do most of the work, and then says exactly where they stop, because a course that implies every integral can be done teaches a falsehood that the first real problem will expose.

Substitution

The chain rule says ddxF(u(x))=F(u(x))u(x). Read backwards, that is an integration rule: an integrand of the shape f(u(x))u(x) has antiderivative F(u(x)), where F is an antiderivative of f. In practice it is easier to run with the substitution written out:

f(u(x))u(x)dx=f(u)du

The mechanics are to choose u, compute du=u(x)dx, and check that everything left in the integrand can be written in terms of u. If something cannot, the substitution is the wrong one, and this is a genuine search rather than a procedure.

For a definite integral there are two options: convert back to x at the end, or, better, convert the limits when you convert the variable. The second is less error-prone and avoids re-expressing a possibly ugly antiderivative.

Example. Evaluate 02xex2dx.

The awkward part is ex2, and the rest of the integrand is xdx, which is nearly the derivative of the exponent. Take u=x2, so du=2xdx and xdx=12du. The limits convert too: x=0 gives u=0, and x=2 gives u=4. The integral becomes

1204eudu=12(e4-1)=26.799

The substitution worked because the derivative of the inside function was already sitting in the integrand, up to a constant. That is the pattern to look for.

Now you. Evaluate 0π/2sin3xcosxdx.

Answer

Take u=sinx, so du=cosxdx, and the limits become 0 and 1. The integral is 01u3du=1/4.

Substitution also runs in the less obvious direction, replacing x by a function of a new variable to exploit an identity. Putting x=sinθ into 1-x2dx turns the root into cosθ by the Pythagorean identity, and the integral becomes a trigonometric one. This is how the area of a circle is computed by calculus rather than assumed.

Integration by parts

The product rule, (uv)=uv+uv, rearranges into uv=(uv)-uv. Integrating both sides and using the Fundamental Theorem on the exact derivative gives

udv=uv-vdu

which is integration by parts. It does not evaluate an integral; it trades one integral for another, and the skill is choosing the split so that the trade is favourable.

The guidance is to let u be the factor that gets simpler when differentiated, and dv the factor you can integrate. A power of x becomes a lower power, and eventually a constant; a logarithm or an inverse trigonometric function becomes an algebraic fraction, which is a large improvement; a sine or an exponential stays the same size, so it usually belongs in dv.

Example. Evaluate 0πxsinxdx.

Take u=x and dv=sinxdx, so du=dx and v=-cosx. The formula gives

0πxsinxdx=[-xcosx]0π+0πcosxdx

The bracket is -πcosπ-0=π, and the remaining integral is [sinx]0π=0. So the answer is π=3.14159. Had the split been made the other way, with u=sinx, the new integral would have contained x2, which is worse than what we started with: the wrong choice tells you so immediately.

Now you. Evaluate 1elnxdx.

Answer

There is only one factor, so take u=lnx and dv=dx, giving du=dx/x and v=x. Then the integral is [xlnx]1e-1edx=(e-0)-(e-1)=1. This is the standard trick for integrating a function whose derivative is nicer than itself.

Sometimes parts is applied twice and the original integral reappears, at which point it can be solved for algebraically. That is how exsinxdx is done: two applications return -exsinxdx plus explicit terms, so moving it to the left side and dividing by two finishes the job.

Rational functions, always

For a quotient of polynomials there is a genuine algorithm, which is unusual enough to be worth stating. Any rational function can be decomposed into a polynomial plus a sum of terms of the form A/(x-r)k and terms with irreducible quadratic denominators, and every one of those pieces integrates to a logarithm, a power, or an arctangent. So every rational function has an elementary antiderivative.

Take 23dxx2-1. Factor the denominator as (x-1)(x+1) and write

1x2-1=12(1x-1-1x+1)

which is checked by recombining over the common denominator. Each piece is now a logarithm, so the integral is 12[ln|x-1|-ln|x+1|] evaluated from 2 to 3, which is 12[ln(2/4)-ln(1/3)]=12ln(3/2)=0.202733.

The same partial fraction decomposition is used constantly outside integration, in solving differential equations and in inverting transforms, so the algebra is worth having regardless.

Averages of squares, and why mains voltage is 230

Trigonometric integrands are handled with identities rather than ingenuity, and one case is worth doing because its answer is on the back of every appliance.

To integrate sin2x, use the identity sin2x=12(1-cos2x), which turns an impossible integrand into two easy ones: sin2xdx=x2-sin2x4+C. Over a full period from 0 to 2π the cosine term contributes nothing, so the integral is π, and the average value of sin2 over a cycle is π/(2π)=1/2.

That number is the whole of alternating current. A mains supply is V(t)=V0sin(ωt), and the power delivered to a resistance is proportional to V2, whose average over a cycle is therefore V02/2. The root mean square voltage, the constant voltage that would deliver the same power, is V0/2. European mains is quoted as 230 V RMS, so the actual peak is 2302=325 V, which is what the insulation has to withstand. The factor of 2 comes from an integral of sin2 and nowhere else.

Where the techniques stop

Now the honest part. Consider these four integrands:

e-x2sinxx1lnx1+x4

Each is continuous on a suitable interval, so by the first half of the Fundamental Theorem each has an antiderivative. None of those antiderivatives can be written using powers, roots, exponentials, logarithms and trigonometric functions, in any finite combination.

This is not a confession of ignorance. Joseph Liouville proved in the 1830s that such functions have no elementary antiderivative, and the modern form of the result, with an algorithm that decides the question for a large class of integrands, is due to Robert Risch in 1968. The statement is a theorem about what is impossible, in the same family as the impossibility of trisecting an angle with straightedge and compass.

The consequence is that most integrands met in physics and statistics cannot be done in closed form, which is why the first of them is given the name erf and tabulated, and why the second is called the sine integral and tabulated. Naming a function is what mathematics does when it cannot express one in older terms, and the logarithm itself was once such a case.

Doing it numerically

When there is no antiderivative, the integral is still a number and it can still be computed, by going back to the sums the definition was built from and choosing them cleverly.

The trapezium rule replaces each strip's flat top with a straight line joining the curve at both ends, which amounts to averaging the left and right sums. The Simpson rule fits a parabola through each consecutive triple of points, giving

abfh3[f0+4f1+2f2+4f3++fn]

with an even number of strips of width h, alternating coefficients of 4 and 2 between the two end values. The pattern comes from integrating the fitted parabolas exactly and adding the results.

The difference in accuracy is dramatic. The error of the trapezium rule falls like h2, so halving the strip width quarters it, while Simpson's falls like h4, so halving the width divides the error by sixteen.

Example. Estimate 01e-x2dx with Simpson's rule using four strips.

The width is h=0.25 and the five values of e-x2 are 1, 0.939413, 0.778801, 0.569783 and 0.367879. The weighted sum is 1+4(0.939413)+2(0.778801)+4(0.569783)+0.367879=8.962265, and multiplying by h/3=0.083333 gives 0.746855. The true value, to seven places, is 0.746824, so four parabolic strips give four correct digits.

Now you. Estimate the same integral with the trapezium rule using four strips, and compare the errors.

Answer

The trapezium rule takes half of each end value plus all the interior ones, times h: 0.25×[0.5(1)+0.939413+0.778801+0.569783+0.5(0.367879)]=0.742984. The error is 0.0038, more than a hundred times Simpson's error of 0.000031, from the same five function evaluations.

A working strategy

Faced with an integral, the order that wastes least time is: check whether it is already a standard form; look for an inside function whose derivative is present, which means substitution; look for a product of two unlike things, which means parts; check whether it is rational, which means partial fractions; try an identity if it is trigonometric. If none of that works within a few minutes, consider that it may have no elementary antiderivative, and reach for a numerical method or a table.

That is a strategy rather than an algorithm, and it should feel less satisfying than differentiation. It is the accurate picture of the subject, and it is why computer algebra systems, which implement the Risch algorithm, are genuinely useful here in a way they are not for differentiation.

With the techniques in hand, the remaining question is what integrals are for. Area was the motivating case and is close to the least of it: the next lesson shows the same limit of sums computing volumes, work, escape velocity, averages and centres of mass, and the pattern that makes all of them the same calculation.

What integrals compute

An integral was defined to compute an area, and area is close to the least interesting thing it does.

The pattern behind every application in this lesson is the same three-step move: cut the quantity into slices, approximate each slice by something elementary enough to write down, and recognise the total as a Riemann sum whose limit is an integral. Learning that move is worth more than memorising any of the formulas it produces, because the formulas are numerous and the move is one thing.

Area between two curves

If fg on [a,b], a vertical strip at position x has height f(x)-g(x) and width dx, so the area between the curves is

ab[f(x)-g(x)]dx

The subtraction handles signs automatically: the formula is correct even where both curves are below the axis, because only their difference enters.

Example. Find the area enclosed between y=x+2 and y=x2.

First find where they meet: x2=x+2 gives x2-x-2=0, so x=-1 and x=2. Between those points the line is above the parabola, checked at x=0 where the line gives 2 and the parabola gives 0. So the area is

-12(x+2-x2)dx=[x22+2x-x33]-12=3.3333-(-1.16667)=4.5

Now you. Find the area enclosed between y=2x and y=x2.

Answer

They meet where x2=2x, at x=0 and x=2, and the line is above in between. The area is 02(2x-x2)dx=[x2-x3/3]02=4-2.6667=1.3333.

Volumes by slicing

A solid can be cut into thin slabs perpendicular to an axis. If the slab at position x has cross-sectional area A(x) and thickness dx, its volume is A(x)dx, and the total is A(x)dx. When the solid is made by revolving a curve about the x-axis, each slab is a disc of radius f(x), so

V=abπ[f(x)]2dx

Example. Derive the volume of a sphere of radius R.

A sphere is the solid of revolution of the semicircle y=R2-x2 from -R to R. The disc at position x has radius y, so its area is π(R2-x2), and

V=-RRπ(R2-x2)dx=π[R2x-x33]-RR

Working the bracket out: at x=R it is R3-R3/3=2R3/3, and at x=-R it is -2R3/3, so the difference is 4R3/3 and V=43πR3. The formula that school geometry asserts without justification falls out of one integral. Archimedes obtained it by exhaustion around 225 BC and was proud enough of the result to have the figure carved on his tomb.

Now you. Find the volume generated by revolving y=x from x=0 to x=4 about the x-axis.

Answer

The disc radius is x, so the area is πx and the volume is 04πxdx=π[x2/2]04=8π=25.13.

The same slicing gives the cone. Revolving the line y=(R/h)x from 0 to h gives V=π(R/h)20hx2dx=π(R/h)2h3/3=13πR2h, which is where the mysterious one third comes from: it is the x3/3 of the power rule and nothing more.

Work against a varying force

Elementary mechanics defines work as force times distance, which is valid only when the force is constant. When it varies, cut the displacement into pieces small enough that the force is nearly constant on each, multiply, and sum:

W=abF(x)dx

For a spring obeying Hooke's law, F=kx, so stretching from 0 to d takes W=12kd2. That familiar formula is an integral, and its quadratic form is the reason a spring stretched twice as far stores four times the energy.

Example. A cylindrical tank of radius 2 m contains water to a depth of 3 m. How much work is needed to pump it all out over the rim, 5 m above the base?

Slice the water into horizontal layers. The layer at height y above the base has volume π(2)2dy=4πdy cubic metres, so its mass is 4000πdy kilograms and its weight is 4000πgdy newtons. That layer must be lifted a distance 5-y. So

W=034000πg(5-y)dy=39200π[5y-y22]03=39200π(15-4.5)

which is 411600π=1.293×106 J, using g=9.8 m s⁻². The check is that the total mass is 4π×3×1000=37700 kg and its centre of mass sits at y=1.5, needing a lift of 3.5 m, giving 37700×9.8×3.5=1.293×106 J. The integral and the centre-of-mass shortcut agree, as they must.

Now you. A spring with stiffness k=200 N/m is stretched from its natural length to 0.3 m. How much work is done?

Answer

W=00.3200xdx=100(0.09)=9 J.

Escape velocity, and integrals over infinite ranges

Gravity weakens with distance, so lifting a mass away from a planet is a work integral with a variable force, and the interesting case has no upper limit at all.

An improper integral is defined as a limit: 1f(x)dx means limb1bf(x)dx, and the integral converges if that limit exists. The behaviour depends delicately on the integrand. For 1/x2 the partial integral is 1-1/b, which converges to 1. For 1/x it is lnb, which grows without bound, so that integral diverges. The tail of 1/x is too fat to have a finite total, which is the same fact as the divergence of the harmonic series in the previous course.

Now the escape problem. The force on a mass m at distance r from a planet of mass M is GMm/r2, so the work needed to move it from the surface at R to infinity is

W=RGMmr2dr=GMm[-1r]R=GMmR

finite, because the inverse square law falls off fast enough. Escape is possible with a finite energy budget, and if gravity fell off like 1/r instead it would not be.

Setting the initial kinetic energy equal to that work gives 12mv2=GMm/R, so

v=2GMR

independent of the escaping mass. For Earth, with G=6.674×10-11 m³ kg⁻¹ s⁻², M=5.972×1024 kg and R=6.371×106 m, this gives 11186 m/s, the familiar 11.2 km/s. The number is a direct consequence of an improper integral converging.

Improper integrals also produce genuine curiosities. Revolving y=1/x for x1 about the axis gives a horn whose volume is π1dx/x2=π, finite, while its surface area involves 1dx/x and is infinite. The solid can be filled with a finite amount of paint and its surface cannot be painted, which is a statement about the definitions rather than about paint: a real coat of paint has a thickness, and the horn narrows below it.

Averages, and the difference between two of them

The average value of f over [a,b] was defined two lessons ago as 1b-aabf, and it settles a question that confuses people about alternating current.

The average of sinx over a half cycle from 0 to π is 1π0πsinxdx=2/π=0.6366. The root mean square value, computed in the previous lesson from the average of sin2, is 1/2=0.7071. Both are honest averages of the same wave and they differ by ten per cent, because one averages the voltage and the other averages the power. A meter reading the first and a meter reading the second will disagree, and which one is correct depends entirely on what the number is for.

Centre of mass

A rod along [a,b] with linear density ρ(x) has mass abρ(x)dx, since the piece at x has mass ρ(x)dx. Its centre of mass is the point where a support would balance it, and balancing means the total moment about that point vanishes:

x=abxρ(x)dxabρ(x)dx

which is a weighted average of position, weighted by mass. For a rod of length 2 m with density ρ(x)=1+x kg/m, the mass is 02(1+x)dx=2+2=4 kg and the moment is 02x(1+x)dx=2+8/3=4.667, so x=1.167 m, right of the geometric centre because the rod is denser at that end. The same construction in two and three dimensions gives centroids of plates and solids, and the same integral with x2 in place of x gives the moment of inertia, which is what rotational dynamics runs on.

Arc length, and a warning

The slicing pattern applies to length too. A short piece of curve is nearly straight, with horizontal run dx and rise f(x)dx, so by Pythagoras its length is 1+[f(x)]2dx and

L=ab1+[f(x)]2dx

The derivation is easy and the integrals are usually impossible. The integrand contains a square root of a sum of squares, which resists every technique of the previous lesson except in contrived cases. The perimeter of an ellipse is the standard example: it produces an integral that Legendre and others studied for decades and which has no elementary antiderivative at all. The functions invented to express it are called elliptic integrals, and they are named after this problem.

That is a fair summary of the state of the subject at this point. Setting up the integral is a skill that generalises, the answer exists whenever the integrand is continuous, and evaluating it in closed form is a matter of luck. Where luck runs out, either a numerical method is used, or the function is approximated by something easier before integrating.

That last option is more powerful than it sounds, and it is the subject of the final lesson: replacing a function by a polynomial that matches it to whatever accuracy is required, which is how physics gets usable answers out of expressions that cannot be evaluated at all.

Taylor series

A tangent line approximates a curve near a point by matching its value and its slope, and there is no reason to stop at the slope.

Matching the second derivative as well gives a parabola that also bends the right way; matching the third gives a cubic; and the sequence of approximations improves in a way that can be made precise, bounded, and used. This last lesson builds those polynomials, states how wrong they are, and applies them to the approximations that appear on nearly every page of a physics text. It needs the derivative rules, the Mean Value Theorem, and the geometric series from the previous course.

Matching more than the slope

The linearisation at a was L(x)=f(a)+f(a)(x-a), chosen so that L(a)=f(a) and L(a)=f(a). Ask for a quadratic P2 that also has P2′′(a)=f′′(a), and the coefficients are forced.

Write the polynomial in powers of (x-a), which is the form that makes the algebra trivial:

Pn(x)=c0+c1(x-a)+c2(x-a)2++cn(x-a)n

Setting x=a kills every term but the first, so c0=f(a). Differentiating once and setting x=a kills everything but the second, giving c1=f(a). Differentiating twice brings a factor of 2 down from the square, so c2=f′′(a)/2. In general the k-th derivative of (x-a)k is k!, so

ck=f(k)(a)k!

and the resulting Pn is the Taylor polynomial of degree n at a, named for Brook Taylor, who published the construction in 1715. When a=0 it is often called a Maclaurin polynomial, after Colin Maclaurin, who popularised that case.

The three most useful ones come from functions whose derivatives repeat. For ex every derivative is ex, worth 1 at the origin, so

ex1+x+x22!+x33!+

For sinx the derivatives cycle through cos,-sin,-cos,sin, which at zero are 1,0,-1,0, leaving only the odd powers with alternating signs:

sinxx-x33!+x55!-

and the same argument for the cosine leaves the even powers, 1-x2/2!+x4/4!-

Example. Estimate e0.5 with the first four terms, and compare.

The terms are 1+0.5+0.125+0.0208333=1.6458333. The true value is 1.6487213, so the estimate is low by 0.0028879, an error of 0.18 per cent. Adding the next term, x4/24=0.0026042, gives 1.6484375, low now by only 0.00028: one more term cut the error by a factor of ten.

Now you. Estimate cos(0.3) with the first three non-zero terms.

Answer

The terms are 1-0.32/2+0.34/24=1-0.045+0.0003375=0.9553375. The true value is 0.9553365, so the error is about 10-6.

How wrong the polynomial is

An approximation with no error bound is a guess, and Taylor's theorem supplies the bound. If f has n+1 derivatives on an interval containing a and x, then

f(x)=Pn(x)+f(n+1)(c)(n+1)!(x-a)n+1

for some c between a and x. The last term is the remainder in Lagrange's form, and it is exactly one more term of the same pattern, with the derivative evaluated at an unknown interior point rather than at a.

The case n=0 is worth reading twice: it says f(x)=f(a)+f(c)(x-a), which is the Mean Value Theorem. So Taylor's theorem is that theorem generalised to higher derivatives, and the proof is the same argument applied to a cleverer auxiliary function.

In practice c is unknown, so the remainder is bounded rather than computed: replace f(n+1)(c) by the largest value the derivative can take on the interval, and the result is a guaranteed limit on the error.

Example. Estimate sin(0.5) with two terms and bound the error.

Two non-zero terms give 0.5-0.53/6=0.4791667. The next derivative in the pattern is a sine or a cosine, so |f(5)(c)|1 whatever c is, and the remainder is at most 0.55/5!=0.00026. The true value is 0.4794255, so the actual error is 0.00025879, just inside the bound and very close to it. That closeness is typical of alternating series, where the first omitted term is nearly the whole error.

Now you. Bound the error in the four-term estimate of e0.5 above, and compare it with the actual error.

Answer

The remainder is ec(0.5)4/4! with 0<c<0.5, so ec<e0.5=1.6487 and the bound is 1.6487×0.0625/24=0.004294. The actual error was 0.002888, comfortably inside it. A bound is meant to be safe rather than sharp.

Small angles, and the pendulum

Almost every formula quoted as an approximation in a physics course is a truncated Taylor series, and the truncation is where its range of validity comes from.

The pendulum is the standard case. The equation of motion for a simple pendulum is θ¨=-(g/L)sinθ, which has no solution in elementary functions. Replacing sinθ by its first Taylor term, θ, turns it into θ¨=-(g/L)θ, which is the simple harmonic motion equation met in the transcendental lesson, with solution a sinusoid of period 2πL/g. That period, famously independent of amplitude, is a property of the approximation and not of the pendulum.

The error is quantifiable. At 10 degrees, θ=0.174533 radians and sinθ=0.173648, a difference of 0.51 per cent. At 30 degrees the difference is 4.7 per cent, and the true period exceeds the small-angle formula by about 1.7 per cent. So the small-angle approximation is not a licence: it is a claim with a size, and knowing the size is what tells you whether a clock built on it will keep time.

The same expansion explains a habit that looks like laziness. Where a potential energy U(x) has a minimum, the Taylor expansion about that minimum has no constant term worth keeping and no linear term at all, since the derivative vanishes there, so the leading behaviour is 12U′′(x0)(x-x0)2. That is the potential of a spring with stiffness U′′(x0). Every system sufficiently close to a stable equilibrium is therefore a harmonic oscillator, whatever it is made of, which is why the same sinusoid describes a pendulum, a bond between two atoms and a mass on a spring. The universality is a fact about second-order Taylor polynomials rather than about physics.

Expansions in physics

Example. Show that relativistic kinetic energy reduces to 12mv2 at ordinary speeds, and check it at v=0.1c.

The relativistic expression is K=(γ-1)mc2 with γ=(1-v2/c2)-1/2. The binomial series gives (1-u)-1/21+12u+38u2 for small u, so with u=v2/c2,

Kmc2(v22c2+3v48c4)=12mv2+3mv48c2

The first term is the Newtonian kinetic energy, which was therefore never a separate law but the leading term of the correct one. At v=0.1c, γ=1.0050378, so the exact kinetic energy per kilogram is 4.5278×1014 J while 12v2 gives 4.4938×1014 J, low by 0.76 per cent. The second term of the series accounts for almost all of that gap.

Now you. A quantity is given by 1/(1-x) where x is small. Give a two-term approximation and test it at x=0.02.

Answer

The geometric series gives 1/(1-x)=1+x+x2+, so the two-term approximation is 1+x=1.02. The true value is 1/0.98=1.020408, so the error is 0.0004, roughly x2 as the next term predicts.

When the series is the function

Letting n grow without bound turns the polynomial into an infinite Taylor series. It represents the function at a point x exactly when the remainder tends to zero there, which is a condition to be checked rather than assumed.

For ex, sinx and cosx it holds for every real x, because the derivatives are bounded on any interval while (n+1)! in the denominator eventually outgrows any power. The series converge everywhere, and they are how these functions are actually evaluated inside a calculator, after the argument has been reduced to a small range.

Other series converge only on a limited range, and the geometric series is the model: 1+x+x2+ sums to 1/(1-x) for |x|<1 and diverges outside, exactly as established for geometric series in the previous course. The half-width of the interval on which a power series converges is its radius of convergence.

The example that makes the topic honest is f(x)=1/(1+x2). This function is perfectly smooth on the whole real line, with no singularity anywhere and derivatives of every order. Its Maclaurin series is 1-x2+x4-, obtained by substituting -x2 into the geometric series, and it converges only for |x|<1. At x=2 the function is a harmless 0.2 and its series has terms that grow without bound. Nothing visible on the real line explains the failure. The explanation is that the function has singularities at x=±i in the complex plane, at distance 1 from the origin, and a power series cannot converge past the nearest singularity in any direction. Real analysis poses the question and complex analysis answers it, which is one of the better arguments for continuing.

There is a worse case. The function equal to e-1/x2 for x0 and to 0 at the origin has derivatives of every order there, and every one of them is zero. Its Maclaurin series is therefore identically zero, converging everywhere and agreeing with the function at exactly one point. A function is not always the sum of its Taylor series, and no amount of smoothness guarantees it.

What the course has bought

The subject began with two problems, the slope of a curve at a point and the area beneath it, and both were beyond algebra because both required a value that a process approaches without reaching.

The limit made that idea precise. The derivative followed as the limit of a difference quotient, then a set of rules that made differentiation mechanical for every function that can be written down, then the theorems that say what a derivative means for the shape of a function and what it fixes about the function itself. The integral was defined independently as a limit of sums, and the Fundamental Theorem identified the two constructions as inverse, which is what makes areas, volumes, work and accumulated change computable. The last two lessons were about the limits of that computation: most integrands have no elementary antiderivative, most functions are handled by approximation, and the approximations carry error bounds that say when they may be trusted.

What that supports is reading. A physics text that writes x¨=-ω2x, integrates a force to get an energy, expands a potential to second order about its minimum, or drops a term in v2/c2 is doing things this course has now derived rather than asserted.

Three directions continue from here. Differential equations take the observation that physical laws relate a quantity to its own derivatives and ask how to solve such relations rather than merely verify them. Multivariable calculus extends every idea here to functions of several variables, where a derivative becomes a set of partial derivatives and an integral runs over a region rather than an interval. And real analysis goes back to the beginning and proves the results this course has quoted, starting from the completeness of the real numbers that the continuity lesson leaned on. Each of them starts where this one stops.

Calculus, from libre.university