The mathematics of change: slopes, areas, and how one tells you the other.
From the question "how fast is it changing right now?" to Taylor series, differential equations and vector calculus. You learn limits and continuity, derivatives and their rules, how to use them to find maxima and approximate, then integrals, the fundamental theorem that links the two, techniques and applications, series, and the calculus of several variables. Graphs you can drag show every idea, and small programs compute derivatives, integrals and solutions numerically, the way computers really do it. Every module has problems to work on paper, with hints and worked solutions.
What you’ll be able to do
Explain limits and continuity, and compute limits algebraically, numerically and with L'Hôpital's rule.
Differentiate any elementary function with the rules, including the chain rule and implicit differentiation, and use derivatives to graph, optimise and approximate.
Integrate with antiderivatives, substitution, integration by parts and partial fractions, handle improper integrals, and use integrals for areas, volumes, averages and accumulated change.
Approximate derivatives, integrals and solutions to differential equations numerically, and judge their error.
Work with sequences, series and Taylor series, and decide when a series converges.
Use partial derivatives, gradients, multiple and line integrals and Green's theorem, and read the ε-δ definitions that make calculus rigorous.
Modules
Rates of change: the question calculus answers· 12 slides
Limits· 12 slides
Continuity· 11 slides
The derivative· 11 slides
Rules for derivatives· 13 slides
The chain rule and implicit differentiation· 13 slides
Graphs, extremes and optimisation· 13 slides
Linear approximation, related rates and Newton's method· 13 slides
Area and the definite integral· 12 slides
The fundamental theorem of calculus· 13 slides
Substitution and integration by parts· 11 slides
Areas, volumes and averages· 13 slides
Numerical integration· 10 slides
Infinity: L'Hôpital and improper integrals· 11 slides
Sequences and series· 11 slides
Taylor series· 11 slides
Differential equations· 11 slides
Functions of several variables· 11 slides
Multiple integrals and vector calculus· 12 slides
Rigour and the frontier· 13 slides
Interactive parts (exercises, code to run, walkthroughs, flashcards, checklists) are drawn still and marked “Interactive · disabled in the PDF”. Do them in the app; the answers are at the end.
Module 1: Rates of change: the question calculus answers
Calculus1 / 237
Module 1 · Rates of change: the question calculus answers
Calculus is the mathematics of change
Things change: a car’s position, the temperature of a cup of tea, the money in a savings account, the number of people with a cold. Calculus is the mathematics that measures how fast something changes, and how much it adds up to over time. You start with the simplest version of the first question: a car trip.
You drive 150 kilometres and it takes 2 hours. Your average speed is the distance divided by the time:
The car was almost never going exactly 75 km/h. It stopped at lights and sped up on the motorway. The average hides all of that. Calculus is what lets you talk about the speed at one exact moment, the number on the speedometer. That takes the whole of the next three modules to do properly, and this module shows why it’s hard.
Rate of change
How much one quantity changes for each unit of another: kilometres per hour, degrees per minute.
Average speed
Total distance divided by total time.
Calculus
The mathematics of rates of change (derivatives) and of adding up (integrals).
Calculus2 / 237
Module 1 · Rates of change: the question calculus answers
The average rate of change of a function
Speed is one rate of change. In general you have a function : a rule that turns an input into an output . When the input moves from to , the output moves from to . The average rate of change is the change in output divided by the change in input. The Greek letter (delta) means "change in".
A worked example with from to :
On average, the output grows by 4 for every 1 the input grows.
QuizInteractive · disabled in the PDF
What is the average rate of change of from to ?
What is the average rate of change of from to ?
ProblemInteractive · disabled in the PDF
Find the average rate of change of from to .
Calculus3 / 237
Module 1 · Rates of change: the question calculus answers
An average rate is the slope of a secant line
Draw the graph of and mark the two points and . The straight line through them is a secant line (from the Latin for "cutting"). Its slope, rise over run, is exactly the average rate of change. So averages are slopes, and you can see them.
f(x) = x²
Secant line
Slope of the secant4
Drag h. The secant from x = 1 to x = 1 + h gets less steep as h shrinks, and its slope is 2 + h.
Why ? The two points are and , and . Divide by the run, , and you get . Remember this: you will need it in a moment.
Slope in one sentence. Slope is how much goes up for each 1 that goes right. A positive slope rises, a negative one falls, and is flat.
Calculus4 / 237
Module 1 · Rates of change: the question calculus answers
The C++ in this course
From the next slide on, small programs compute what each module teaches: rates, limits, derivatives, integrals. They are in C++, which the Algebra course taught. Here is the C++ they use most, plus one thing calculus needs all the time: handing a function to a function, as when you give a derivative or an integral the to work on. Run it.
PlaygroundInteractive · disabled in the PDF
C++
1#include<cmath>2#include<functional>3#include<iostream>4#include<vector>56doublesquare(double x){ // returns a double, given a double7return x * x;8}910// f is any function from double to double: call it like one.11doubletwiceAt(std::function<double(double)> f,double x){12return2*f(x);13}1415intmain(){16 std::cout <<7/2<<" but "<<7.0/2<<"\n";17 std::cout << std::pow(2,10)<<" "<< std::sqrt(2.0)<<"\n";1819 std::vector<double> xs ={0.5,1,2};20for(double x : xs){21if(x >=1) std::cout <<square(x)<<"\n";22}2324auto cube =[](double x){return x * x * x;}; // a lambda25 std::cout <<twiceAt(cube,2)<<" "<<twiceAt(square,3)<<"\n";26}
Change cube to another function, or add a number to xs, and run it again.
A program starts in int main(), and std::cout << x prints x. A function names the type it returns and its parameters’ types: double square(double x).
int holds whole numbers, double numbers with a fraction. Two ints divide to a whole number, dropping the rest: 7 / 2 is 3 and 1 / 2 is 0. Write 7.0 / 2 when you mean .
<cmath> has std::sqrt, std::pow, std::exp, std::log, std::abs and std::sin (in radians). There is no power operator: is std::pow(x, 3) or x * x * x. ^ means something else entirely: 2 ^ 3 is 1 (bitwise XOR).
std::vector<double> is a list of numbers, and for (double x : xs) visits each one.
std::function<double(double)>, from <functional>, is the type "a function from double to double". [](double x) { return x * x * x; } is a lambda: a function written right where it is needed, and auto lets the compiler work out its type. Named functions and lambdas can both be passed.
Challenges and their tests. A challenge has no main: you write the function, and the tests (TEST) call it. They compare decimals with EXPECT_NEAR(actual, expected, within), never exactly, because a double is rounded: is not exactly .
Calculus5 / 237
Module 1 · Rates of change: the question calculus answers
Speed from a distance graph
Drop a ball from a tall tower. Ignoring air, the distance it has fallen after seconds is about metres. The average speed between two times is the average rate of change of , which is the slope of a secant on the distance–time graph.
Between 1 s and 2 s the ball falls 14.7 m, so it averages 14.7 metres per second.
ProblemInteractive · disabled in the PDF
The ball has fallen metres after seconds. What is its average speed between s and s?
m/s
Code challengeInteractive · disabled in the PDF
Write averageRate(f, a, b): the average rate of change of the function f from a to b, that is the change in f divided by the change in input.
C++
1#include<functional>23doubleaverageRate(std::function<double(double)> f,4double a,double b){5 // TODO: the change in f over the change in x6return0;7}
Calculus6 / 237
Module 1 · Rates of change: the question calculus answers
Speed right now is a puzzle
How fast is the ball going at exactly second? Average speed needs two times. If you use the same time twice, you get distance over time , and means nothing. This is the puzzle that took mathematicians centuries to settle.
The way out: take averages over shorter and shorter intervals starting at 1 s, and watch where they head. From to the average speed is m/s, by the same algebra as the secant of .
Interval
(s)
Average speed (m/s)
1 s to 2 s
1 s to 1.5 s
1 s to 1.1 s
1 s to 1.01 s
1 s to 1.001 s
The averages settle down as the interval shrinks.
QuizInteractive · disabled in the PDF
What speed do these averages approach, as gets closer and closer to ?
What speed do these averages approach, as gets closer and closer to ?
Calculus7 / 237
Module 1 · Rates of change: the question calculus answers
Shrink the interval yourself
Here is the table as a program. Change the time t0 or the function d, and run it again. Watch the averages settle on one number.
PlaygroundInteractive · disabled in the PDF
C++
1#include<iostream>23intmain(){4auto d =[](double t){return4.9* t * t;}; // metres fallen5double t0 =1; // the moment we care about67for(double h : {1.0,0.5,0.1,0.01,0.001,0.0001}){8double average =(d(t0 + h)-d(t0))/ h;9 std::cout <<"h = "<< h <<": "<< average <<" m/s\n";10}11}
Try t0 = 2: the averages head for 19.6 m/s, twice as fast.
Instantaneous rate. The number the averages approach is the instantaneous rate of change. Geometrically, it is the slope of the tangent line: the line that just touches the curve at that point. Module 4 makes this exact and calls it the derivative.
Calculus8 / 237
Module 1 · Rates of change: the question calculus answers
The area under a speed graph is the distance
Now turn the question around. Suppose you know the speed at every moment and want the distance. At a steady 20 m/s for 5 s you go m. On a speed–time graph that is a rectangle 5 wide and 20 tall: the distance is the area under the speed graph.
That stays true when the speed changes. A car that speeds up steadily has speed m/s. Under that line, from to , is a triangle with base and height , so the distance is metres.
v(t) = 2t
Distance (m)16
Drag T. The distance travelled is the shaded triangle under the speed line.
QuizInteractive · disabled in the PDF
A cyclist rides at m/s for s, then at m/s for s. How far does she go?
A cyclist rides at m/s for s, then at m/s for s. How far does she go?
Calculus9 / 237
Module 1 · Rates of change: the question calculus answers
Two questions, slopes and areas
Calculus has two halves, one for each question you just met. Both are about curves, and both need you to deal with "infinitely small" pieces.
Differential calculus
Asks: how fast is it changing right now?
Answer: the slope of the tangent line
Tool: the derivative
From distance, find speed
Integral calculus
Asks: how much does it add up to?
Answer: the area under the curve
Tool: the integral
From speed, find distance
Look at the last line of each side. Speed comes from distance, and distance comes from speed: the two questions undo each other. That fact is the fundamental theorem of calculus, the high point of the first half of this course (module 10).
QuizInteractive · disabled in the PDF
Which of these is a question for integral calculus? Choose all that apply.
Which of these is a question for integral calculus? Choose all that apply.
Calculus10 / 237
Module 1 · Rates of change: the question calculus answers
Where calculus came from
Parts of calculus are ancient. Archimedes (around 250 BC) found the area of a parabola’s segment by filling it with ever smaller triangles. In the 1630s Pierre de Fermat found tangents and highest points of curves. What was missing was a general method, and the link between the two questions.
Isaac Newton worked it out in England in 1665–66, calling derivatives "fluxions", but published little of it for decades. Gottfried Wilhelm Leibniz found it independently in Germany and published first, in 1684. The notation you will use, and , is Leibniz’s. A bitter argument over who came first followed. Both deserve the credit.
Their calculus worked but rested on vague "infinitely small" quantities. In the 1820s Augustin-Louis Cauchy built it on limits, and Karl Weierstrass, around 1860, gave the precise ε-δ definitions mathematicians use today (module 20).
Put in orderInteractive · disabled in the PDF
Put these in the order they happened.
1.Weierstrass gives the ε-δ definitions
2.Archimedes finds the area of a parabolic segment
3.Cauchy builds calculus on limits
4.Fermat finds tangents and maxima of curves
5.Leibniz publishes the first paper on differential calculus
6.Newton develops his method of fluxions
Calculus11 / 237
Module 1 · Rates of change: the question calculus answers
Practice problems
ProblemInteractive · disabled in the PDF
Let . Simplify the average rate of change of from to (for ). Then say what it approaches as gets closer and closer to .
ProblemInteractive · disabled in the PDF
A stone dropped from a cliff falls metres in seconds. Find its average speed from to as a formula in , and then its speed at exactly s.
m/s
m/s
ProblemInteractive · disabled in the PDF
A car drives at a steady m/s for s, then speeds up steadily from m/s to m/s over the next s. How far does it go in these s, and what is its average speed?
m
m/s
ProblemInteractive · disabled in the PDF
A tank drains so that minutes after the tap opens it holds litres. What is the average rate of change of from to minutes?
L/min
Calculus12 / 237
Module 1 · Rates of change: the question calculus answers
Recap
The average rate of change of from to is : the slope of the secant line.
Average speed is the average rate of change of distance.
The rate "right now" is what averages over shrinking intervals approach, not .
Distance is the area under the speed graph.
Slopes (derivatives) and areas (integrals) are the two halves of calculus, and they undo each other.
FlashcardsInteractive · disabled in the PDF
Average rate of change
, the change in output per unit change in input.
Secant line
The straight line through two points of a curve. Its slope is the average rate of change.
Tangent line
The line that just touches a curve at one point. Its slope is the instantaneous rate.
Why not just set the interval to 0?
You get , which has no value. You need what the averages approach: a limit.
Area under a speed–time graph
The distance travelled.
Who invented calculus?
Newton (1665–66) and Leibniz (published 1684), independently.
Module 2: Limits
Calculus13 / 237
Module 2 · Limits
A limit is where a function is heading
Take . At it is , so has no value. But for every other you can cancel: , so . The graph is the line with one point missing, a hole at .
f(x) = (x² − 1)/(x − 1)
The graph is a line with a hole at x = 1. As x gets close to 1 from either side, f(x) gets close to 2.
You say "the limit of as approaches is ", and write it like this. It is about the values near , never the value at : the function doesn’t even need to be defined there.
Limit
The value gets as close as you like to, by taking close enough to (but not equal to it).
$x \to a$
Read " approaches ": takes values nearer and nearer to , from either side.
Calculus14 / 237
Module 2 · Limits
Guessing a limit with a table
Before any algebra, you can estimate a limit by computing the function at inputs that close in on from both sides. For :
below 1
above 1
Tables can lie. A table is evidence, not proof. Too few rows can miss wild behaviour, and inputs too close to suffer rounding error in a computer. Use tables to guess, and algebra to be sure.
Code challengeInteractive · disabled in the PDF
Write valuesNear(f, a, n): a vector of f(a + 0.1), f(a + 0.01), … , , the values of f as the input closes in on a from above.
C++
1#include<cmath>2#include<functional>3#include<vector>45std::vector<double>valuesNear(std::function<double(double)> f,6double a,int n){7 std::vector<double> values;8 // TODO: one value for each k from 1 to n9return values;10}
Calculus15 / 237
Module 2 · Limits
Limits from the left and from the right
Sometimes a function heads for different values from each side. The left-hand limit uses only ; the right-hand limit uses only . The two-sided limit exists only when both exist and are equal.
x² (for x < 1)
x + 1 (for x ≥ 1)
A jump: from the left the graph arrives at height 1, from the right at height 2.
QuizInteractive · disabled in the PDF
For this , what is ?
For this , what is ?
Calculus16 / 237
Module 2 · Limits
Three ways a limit can fail to exist
A jump: the one-sided limits differ, as on the last slide.
Blowing up: grows without bound near . You write , but is not a number: it says how the limit fails to exist.
Oscillation: swings between and infinitely often as , never settling.
sin(1/x)
sin(1/x) between x = −w and x = w, stretched to fit. Drag w to zoom in on 0: however close you look, it keeps swinging.
QuizInteractive · disabled in the PDF
What happens to as ?
What happens to as ?
Calculus17 / 237
Module 2 · Limits
Limit laws let you split the work
If and both exist, limits behave the way you would hope:
Every limit here is as x → a. For an even root ( even), must be positive.
Together they give direct substitution: for a polynomial, or a fraction of polynomials whose bottom isn’t at , the limit is just the value at . So .
QuizInteractive · disabled in the PDF
What is ?
What is ?
Calculus18 / 237
Module 2 · Limits
When substitution gives zero over zero
is not an answer. It is a sign that something on top and bottom cancels. Two tricks find it: factor and cancel, or rationalise, multiplying top and bottom by the conjugate to clear a square root.
Rationalising: , which frees the to cancel.
Fill the blanksInteractive · disabled in the PDF
Find by factoring. Fill in the blanks.
Text
1x^2 - 9 = (x - 3)(x + )2(x^2 - 9) / (x - 3) = x + 3 when x is not 33limit as x -> 3 = 3 + 3 =
ProblemInteractive · disabled in the PDF
Find .
Calculus19 / 237
Module 2 · Limits
The squeeze theorem
Some limits can’t be simplified, but can be trapped. If near , and and have the same limit at , then has no room to go anywhere else: its limit is too.
Example: near . The sine is between and , so the function is between and . Both of those go to , so , even though alone has no limit.
x² sin(1/x)
x²
−x²
The wiggly curve is pinned between y = x² and y = −x², which both pinch to 0.
ProblemInteractive · disabled in the PDF
A function satisfies for every . Find .
Calculus20 / 237
Module 2 · Limits
The most important trig limit
With in radians, approaches as . You can’t substitute () or factor. It is proved with the squeeze theorem: a picture of the unit circle shows for small , and .
sin(x)/x
sin(x)/x has a hole at 0, at height exactly 1.
QuizInteractive · disabled in the PDF
What is ?
What is ?
Why radians. In degrees, . Radians are the unit that makes this limit , and that is why every derivative of and in this course assumes radians.
Calculus21 / 237
Module 2 · Limits
Limits at infinity and horizontal asymptotes
means gets as close as you like to once is large enough. The line is then a horizontal asymptote. For a fraction of polynomials, divide top and bottom by the highest power of on the bottom:
(kx² + 1)/(x² + 5)
Asymptote y = k
Drag k, the top’s leading coefficient: the curve levels off at y = k.
Degrees
Limit as
Example
Top < bottom
Top = bottom
ratio of leading coefficients
Top > bottom
no finite limit ()
Code challengeInteractive · disabled in the PDF
Write limitAtInfinity(top, bottom). Each argument is a polynomial’s coefficients, highest power first ({3, 0, 1} is ), and its first coefficient isn’t 0. Return the limit as : 0, the ratio of leading coefficients, or INFINITY / -INFINITY (from <cmath>).
Let for and for . Find the left-hand and right-hand limits at . Then suppose the right piece were instead: which would make exist?
ProblemInteractive · disabled in the PDF
Find (a) and (b) .
Calculus24 / 237
Module 2 · Limits
Recap
: gets as close as you like to for near , never looking at itself.
A two-sided limit exists only if both one-sided limits exist and agree.
Limits fail by jumping, blowing up or oscillating.
Try substitution first; on , factor or rationalise.
Squeeze a hard function between two easy ones with the same limit.
, in radians.
At infinity, the highest powers decide.
FlashcardsInteractive · disabled in the PDF
Does the limit at depend on ?
No. Only on values near . needn’t even exist.
One-sided limits
uses , uses .
What does from substitution mean?
Nothing yet: simplify (factor, rationalise) and try again.
Squeeze theorem
If and , , then .
, with in radians.
Horizontal asymptote
A line with as or .
Module 3: Continuity
Calculus25 / 237
Module 3 · Continuity
Continuous means no breaks
Informally, a function is continuous if you can draw its graph without lifting your pen: no holes, no jumps, no shooting off to infinity. Temperature through a day is continuous; the price of a parking ticket, which jumps at each hour, is not.
Limits make that precise. is continuous at when three things hold:
is defined (there’s a point on the graph at ),
exists (the graph heads for one height from both sides),
and the two are equal: .
The one-line version: near , the function heads exactly to its value at .
Continuous at a point
.
Continuous on an interval
Continuous at every point of it. At a closed end, only the one-sided limit from inside counts.
Discontinuity
A point where a function isn’t continuous.
Calculus26 / 237
Module 3 · Continuity
The kinds of discontinuity
Kind
What goes wrong
Example at the point
Removable
The limit exists but is missing or different: a hole
at
Jump
The one-sided limits exist but differ
a parking price at each hour
Infinite
The function blows up
at
Oscillating
It swings forever, never settling
at
A removable discontinuity is called that because you can remove it: define (or redefine) to be the limit, and the hole is filled. No choice of can fix the other three.
QuizInteractive · disabled in the PDF
What kind of discontinuity does have at ?
What kind of discontinuity does have at ?
ProblemInteractive · disabled in the PDF
is undefined at . What value should be given to make continuous there?
Calculus27 / 237
Module 3 · Continuity
Most formulas are continuous wherever they make sense
You rarely check the three conditions by hand. These are continuous at every point of their domain (the inputs where they’re defined):
polynomials, everywhere;
fractions of polynomials, except where the bottom is ;
for , everywhere, for ;
and everywhere, except at odd multiples of .
Sums, differences, products and compositions of continuous functions are continuous, and so are quotients where the bottom isn’t . So is continuous everywhere, with no work.
QuizInteractive · disabled in the PDF
Where is not continuous? Choose all that apply.
Where is not continuous? Choose all that apply.
Continuity lets you substitute. Continuity is exactly what makes direct substitution work: if is continuous at , then is . It also lets limits pass through functions: .
Calculus28 / 237
Module 3 · Continuity
Choosing a value to join two pieces
A function built from pieces is continuous where the pieces meet only if their heights match. Take for and for . At the left piece arrives at and the right piece is at . They meet when , so .
kx + 1 (x < 2)
x² (x ≥ 2)
Gap at x = 22
Drag k until the gap closes.
Fill the blanksInteractive · disabled in the PDF
Make (for ) and (for ) continuous.
Text
1left piece at x = 1: 3 - c2right piece at x = 1: 33 - c = 2, so c =
ProblemInteractive · disabled in the PDF
Find so that for and for is continuous at .
Calculus29 / 237
Module 3 · Continuity
The intermediate value theorem
If you walk up a hill from 200 m to 500 m above sea level without teleporting, at some moment you were at exactly 350 m. That is the intermediate value theorem (IVT):
f(x) = x²
y = N
c1.4142
f(x) = x² on [1, 2] goes from 1 to 4. Drag N: the curve always crosses the line y = N somewhere.
Its most useful form: if and have opposite signs, then has a root (a zero) between them. For example has and , so the equation has a solution in , though no formula gives it.
It promises, it doesn’t find. The theorem says a solution exists; it doesn’t say where, or how many. There might be several. Finding one is the job of the bisection method, two slides on.
Calculus30 / 237
Module 3 · Continuity
The theorem needs continuity
Drop the word "continuous" and the promise breaks. has and , opposite signs, yet is never . It jumps from to at instead of crossing.
QuizInteractive · disabled in the PDF
Which of these does the intermediate value theorem guarantee has a root in the given interval? Choose all that apply.
Which of these does the intermediate value theorem guarantee has a root in the given interval? Choose all that apply.
Calculus31 / 237
Module 3 · Continuity
Bisection: halve the interval until the root is trapped
The IVT gives an algorithm. Start with where changes sign. Look at the midpoint . Whichever half still has a sign change contains a root; keep that half. Each step halves the interval, so the root is trapped ever more tightly. Here it finds , the root of :
Step
Interval
Midpoint
Keep
1
left half
2
right half
3
right half
4
left half
5
right half
Put in orderInteractive · disabled in the PDF
Put one step of the bisection method in order.
1.If and have opposite signs, set ; otherwise set
2.Compute the midpoint
3.Stop if is smaller than the tolerance, else repeat
4.Check that and have opposite signs
5.Evaluate
Calculus32 / 237
Module 3 · Continuity
Bisection as code
Code challengeInteractive · disabled in the PDF
Write bisect(f, a, b, tol). f(a) and f(b) have opposite signs. Halve the interval, keeping the half where the sign changes, until b - a < tol, then return the midpoint.
C++
1#include<functional>23doublebisect(std::function<double(double)> f,4double a,double b,double tol){5 // TODO: halve [a, b] until it is shorter than tol6return(a + b)/2;7}
QuizInteractive · disabled in the PDF
Starting from an interval of width , about how many bisection steps make it narrower than ?
Starting from an interval of width , about how many bisection steps make it narrower than ?
Calculus33 / 237
Module 3 · Continuity
The extreme value theorem
The extreme value theorem: a function continuous on a closed interval has a highest value (a maximum) and a lowest value (a minimum) somewhere on it. This is what makes "find the best value" problems sure to have an answer (module 7).
f(x) = x³ − 3x
f(x) = x³ − 3x on [−1.5, 2.5]: the minimum is inside, at x = 1; the maximum is at the right end.
Both conditions matter. On the open interval , never reaches a maximum: , , keep getting bigger, but is not allowed. And on has no maximum because it isn’t continuous at .
QuizInteractive · disabled in the PDF
Which function is guaranteed a maximum by the extreme value theorem?
Which function is guaranteed a maximum by the extreme value theorem?
Going deeper
Why these theorems are true. Both rest on the completeness of the real numbers: there are no gaps on the number line. Over the rational numbers alone, goes from to on without ever being , because isn’t rational. Module 20 shows how completeness proves the IVT.
Calculus34 / 237
Module 3 · Continuity
Practice problems
ProblemInteractive · disabled in the PDF
Find and so that this function is continuous everywhere: for , for , and for .
ProblemInteractive · disabled in the PDF
is discontinuous at two points. Find the one that is removable, the value that fills its hole, and the one where blows up.
ProblemInteractive · disabled in the PDF
has a root in . Take three steps of the bisection method: which interval are you left with? And how many steps, starting from , make the interval narrower than ?
ProblemInteractive · disabled in the PDF
Let for , and . Which makes continuous at ?
Calculus35 / 237
Module 3 · Continuity
Recap
is continuous at when .
Discontinuities are removable (a hole), jumps, infinite, or oscillating.
Elementary functions are continuous on their domains, and so are their combinations.
IVT: a continuous function takes every value between and ; a sign change means a root.
Bisection traps a root by halving, one binary digit per step.
EVT: continuous on a closed interval means a maximum and a minimum exist.
FlashcardsInteractive · disabled in the PDF
The three conditions for continuity at
defined, the limit exists, and they are equal.
Removable discontinuity
A hole: the limit exists, but is missing or different. Redefining fixes it.
Intermediate value theorem
Continuous on , between and : some has .
Bisection
Keep the half with the sign change. The width halves each step.
Extreme value theorem
Continuous on a closed interval: a maximum and a minimum are reached.
Module 4: The derivative
Calculus36 / 237
Module 4 · The derivative
The derivative is the limit of secant slopes
In module 1 you found the speed of a falling ball "right now" by taking averages over shorter and shorter intervals. With limits you can now say exactly what that is. The slope of the secant from to is the difference quotient; its limit as is the derivative of at :
Read as "f prime of a". If the limit exists, is differentiable at .
f(x) = x²
Secant
Tangent
Secant slope2.2
Tangent slope1
Drag h toward 0: the secant through P and Q turns into the tangent at P. Drag a to move P.
Difference quotient
: the slope of a secant, an average rate.
Derivative at a
The limit of the difference quotient as : the instantaneous rate of change, the slope of the tangent.
Tangent line
The line through with slope .
Calculus37 / 237
Module 4 · The derivative
Working out a derivative from the definition
The recipe: write the difference quotient, simplify until the on the bottom cancels, then let . For :
And for , combining the fractions first:
Find the bugInteractive · disabled in the PDF
This works out the derivative of at . One line is wrong. Which?
Text
ProblemInteractive · disabled in the PDF
Use the definition of the derivative to find for . Then find .
Calculus38 / 237
Module 4 · The derivative
The equation of the tangent line
A line through the point with slope is . The tangent line uses :
Check: at the line gives , the curve’s height.
Fill the blanksInteractive · disabled in the PDF
Find the tangent line to at , using . Write decimals.
Text
1f(2) = 2f'(2) = 3tangent: y = 0.5 - 0.25(x - 2), which is y = -0.25x +
ProblemInteractive · disabled in the PDF
Find the tangent line to at , using . Give it as .
Calculus39 / 237
Module 4 · The derivative
The derivative is a function too
Doing the limit at a general point gives a new function, , whose value at each is the slope of there. For , using :
f(x) = x³
f′(x) = 3x²
Tangent at a
f′(a)3
Drag a. The height of the dashed curve f′ at a is the slope of the tangent to f at a.
QuizInteractive · disabled in the PDF
always rises. What is its slope at ?
always rises. What is its slope at ?
Calculus40 / 237
Module 4 · The derivative
Ways to write the derivative
The same idea has several notations, from different centuries. You will meet all of them.
Notation
Read as
From
"f prime of x"
Lagrange
"dee y dee x"
Leibniz
"the derivative of f(x)"
Leibniz
ẏ (a dot over y)
"y dot", a rate in time
Newton (physics)
"D f of x"
Euler
Leibniz’s is not a fraction, but it is a reminder of one: it came from , and its units are units of per unit of . If is in metres and in seconds, is in metres per second. The value at a point is written or .
QuizInteractive · disabled in the PDF
is the water in a tank, in litres, minutes after midnight. . What does that say?
is the water in a tank, in litres, minutes after midnight. . What does that say?
Calculus41 / 237
Module 4 · The derivative
Differentiable means smooth, not only unbroken
Zoom in on a smooth curve and it looks more and more like a straight line, its tangent. Zoom in on a corner and it stays a corner. at has secant slope from the right and from the left, so the limit of the difference quotient doesn’t exist: is continuous at but not differentiable there.
x², zoomed
|x|, zoomed
A window of width 2w around 0, stretched to fit. Drag w smaller: the parabola flattens into its tangent line, but |x| keeps its corner.
Differentiable implies continuous: if exists, can’t jump or have a hole at .
Continuous does not imply differentiable: corners (), cusps ( at ) and vertical tangents ( at ) are all unbroken but have no derivative.
QuizInteractive · disabled in the PDF
Which statement is true?
Which statement is true?
Going deeper
Continuous everywhere, smooth nowhere. In 1872 Weierstrass published a function continuous at every point and differentiable at none: with and ( an odd integer). It is all corners, at every scale. The paths of Brownian motion are like that too.
Calculus42 / 237
Module 4 · The derivative
Reading the derivative from a graph
You can sketch from a picture of alone, by looking at the slope as you move left to right: where rises, is positive; where it falls, negative; at the top of a hill or the bottom of a valley, where the tangent is flat, is . Steeper means bigger in size.
f
Tangent at a
Slope f′(a)6.72
Drag a along the curve and watch the slope readout change sign.
QuizInteractive · disabled in the PDF
From the graph alone, where is ?
From the graph alone, where is ?
Calculus43 / 237
Module 4 · The derivative
How a computer estimates a derivative
A computer can’t take a limit, but it can use a small . The forward difference is the difference quotient itself. The central difference uses points on both sides, and is far more accurate for the same :
and are the second and third derivatives (module 5). Halving halves the forward error but quarters the central one.The error estimating the slope of sin at x = 1 (true value cos 1 ≈ 0.5403).
Smaller isn’t always better. Below about (forward) or (central), the estimate gets worse: and agree in almost every digit, and subtracting them leaves mostly rounding error. This is called cancellation. Try it on the next slide.
Calculus44 / 237
Module 4 · The derivative
Finite differences as code
Code challengeInteractive · disabled in the PDF
Write forwardDiff(f, x, h) and centralDiff(f, x, h), the two estimates of from the last slide.
1#include<cmath>2#include<iomanip>3#include<iostream>45intmain(){6auto f =[](double x){return std::sin(x);};7double x =1;8double exact = std::cos(1.0);910 std::cout << std::scientific << std::setprecision(1);11for(int k =1; k <=14; k++){12double h = std::pow(10,-k);13double forward =(f(x + h)-f(x))/ h;14double central =(f(x + h)-f(x - h))/(2* h);15 std::cout <<"h = 1e-"<< k <<" "16<< std::abs(forward - exact)<<" "17<< std::abs(central - exact)<<"\n";18}19}
The errors shrink, then grow again as rounding takes over. Where is each one best?
Calculus45 / 237
Module 4 · The derivative
Practice problems
ProblemInteractive · disabled in the PDF
Use the definition of the derivative to find for . Then give the tangent line at as .
ProblemInteractive · disabled in the PDF
The tangent to at crosses the -axis at one point and meets the curve again at another. Find the of each. (.)
ProblemInteractive · disabled in the PDF
Estimate for with , first with the forward difference, then with the central difference. (The true value is .)
ProblemInteractive · disabled in the PDF
A stone thrown upward is metres high after seconds. From the definition of the derivative, find its velocity . How fast is it rising at s, and when does it stop rising?
m/s
m/s
s
Calculus46 / 237
Module 4 · The derivative
Recap
: the slope of the tangent, the instantaneous rate.
From the definition: , , .
Tangent line: .
is a function; its units are units of per unit of .
Differentiable implies continuous, but corners and cusps are continuous without a derivative.
Computers estimate with finite differences; central is , forward .
FlashcardsInteractive · disabled in the PDF
Definition of
Tangent line at
Leibniz’s notation for the derivative of with respect to .
Why is not differentiable at 0?
Slope from the right, from the left: no single limit.
Working every derivative out from the limit is slow. Instead, you prove a handful of rules once and combine them. The first two: a constant doesn’t change, so its derivative is ; and a power of follows the power rule, which you saw for and in module 4.
Bring the power down in front, then lower the power by one.
It works for any real power, not only whole numbers, once roots and fractions are written as powers:
QuizInteractive · disabled in the PDF
What is ?
What is ?
Calculus48 / 237
Module 5 · Rules for derivatives
Sums and constant multiples
The derivative of a sum is the sum of the derivatives, and a constant factor just comes along. Both follow from the limit laws. Together they let you differentiate any polynomial term by term.
A polynomial can be stored as its list of coefficients, lowest power first: is the std::vector<double>{-2, 7, -5, 4}. The term sits at index , and the power rule turns it into , at index .
Code challengeInteractive · disabled in the PDF
Write derivePoly(c), the coefficients of the derivative (lowest power first; {} for a constant), and evalPoly(c, x), the polynomial’s value at x.
The number e makes the exponential its own derivative
An exponential grows in proportion to itself: its derivative is times a constant, the slope of at . For that slope is about ; for , about . Somewhere between them is the base whose slope at is exactly . That base is .
y = aˣ
Tangent at 0
Slope 1
Slope at 0 (ln a)0.6931
Drag a. The tangent to aˣ at x = 0 has slope ln a, which is exactly 1 when a = e ≈ 2.718. is the natural logarithm, the logarithm to base . .
Why it matters. is the only function (up to a constant factor) equal to its own derivative. Anything that grows or decays at a rate proportional to its size, from money at continuous interest to a cooling cup, is described with (module 17).
Calculus51 / 237
Module 5 · Rules for derivatives
The derivative of ln x
The natural logarithm undoes : . Its derivative is surprisingly simple. You will prove it in module 6 from the derivative of ; for now, learn it:
It fills the one gap in the power rule. The power rule never gives , because the it would come from is a constant. The logarithm is the function whose derivative is . As grows, keeps rising but more and more slowly: its slope shrinks toward .
QuizInteractive · disabled in the PDF
What is ?
What is ?
Calculus52 / 237
Module 5 · Rules for derivatives
The derivatives of sine and cosine
With in radians, the slope of at each point is , and the slope of is . The proof uses the limit from module 2. Check it on the graph: at , climbs with slope ; at , its top, the slope is .
sin x
cos x
Tangent to sin at a
Slope of sin at a0.825
Drag a: the slope of sin at a, in the readout, is the height of cos at a.The derivative of comes from the quotient rule, two slides on.
Calculus53 / 237
Module 5 · Rules for derivatives
The product rule
The derivative of a product is not the product of the derivatives. Picture as the area of a rectangle with sides and . When both sides grow a little, the area gains a strip along one side, a strip along the other, and a tiny corner that vanishes in the limit:
Find the bugInteractive · disabled in the PDF
This differentiates . One line is wrong. Which?
Text
Calculus54 / 237
Module 5 · Rules for derivatives
The quotient rule
For a fraction, the rule is "bottom times derivative of top, minus top times derivative of bottom, over bottom squared". The order on top matters, because of the minus sign.
QuizInteractive · disabled in the PDF
What is ?
What is ?
ProblemInteractive · disabled in the PDF
Differentiate and simplify. What is the slope at ?
Calculus55 / 237
Module 5 · Rules for derivatives
Higher derivatives
The derivative of is the second derivative , written in Leibniz’s notation: the rate of change of the slope. Keep going for the third, , and the $n$th, .
Each derivative of a polynomial lowers its degree by one, so eventually you reach 0.
QuizInteractive · disabled in the PDF
What is the 4th derivative of ?
What is the 4th derivative of ?
Calculus56 / 237
Module 5 · Rules for derivatives
Position, velocity and acceleration
In physics, derivatives have names. If is position, the velocity is (metres per second) and the acceleration is (metres per second per second, m/s²). A ball thrown straight up at 20 m/s from 5 m above the ground, with gravity m/s²:
Height s(t)
Velocity v(t)
Height (m)20.1
Velocity (m/s)10.2
Drag t. The ball rises while v > 0, stops for an instant at the top, then falls.
QuizInteractive · disabled in the PDF
At what time is the ball highest, and how high is it?
At what time is the ball highest, and how high is it?
Calculus57 / 237
Module 5 · Rules for derivatives
Practice problems
ProblemInteractive · disabled in the PDF
Differentiate , and find the slope at .
ProblemInteractive · disabled in the PDF
Find the tangent line to at , as .
ProblemInteractive · disabled in the PDF
Let . Find and .
ProblemInteractive · disabled in the PDF
A particle moves along a line, at position metres after seconds (). At which two times is it at rest? What is its acceleration at the second of them?
s
s
m/s²
Calculus58 / 237
Module 5 · Rules for derivatives
More practice problems
ProblemInteractive · disabled in the PDF
Differentiate and simplify. At which is the tangent flat?
ProblemInteractive · disabled in the PDF
A culture of bacteria has cells after hours. How fast is it growing at hours?
cells per hour
Calculus59 / 237
Module 5 · Rules for derivatives
Recap
Function
Derivative
FlashcardsInteractive · disabled in the PDF
Power rule
, for any real .
Product rule
Quotient rule
Why is special?
is its own derivative: the slope of at is exactly .
Velocity and acceleration
, .
Module 6: The chain rule and implicit differentiation
Calculus60 / 237
Module 6 · The chain rule and implicit differentiation
Functions inside functions
Many functions are built by feeding one function into another. In you first square , then take the sine of the result. That is a composite function, , written . The function applied first, , is the inner function; the one applied last, , is the outer function.
Composite
Inner
Outer
QuizInteractive · disabled in the PDF
In , which is the inner function?
In , which is the inner function?
Calculus61 / 237
Module 6 · The chain rule and implicit differentiation
The chain rule: rates multiply
If changes 3 times as fast as , and changes 5 times as fast as , then changes times as fast as , like gears driving gears. That is the chain rule: the derivative of a composite is the outer derivative (at the inner function) times the inner derivative.
In Leibniz’s notation it looks like fractions cancelling. They aren’t fractions, but the notation is built to make this rule easy to remember.Expanding first would also work, but takes six terms. The chain rule takes one line.
Calculus62 / 237
Module 6 · The chain rule and implicit differentiation
The chain rule in practice
Differentiate the outer function, leaving the inside alone, then multiply by the derivative of the inside:
e^(−x²)
Its derivative
Tangent at a
Slope at a0.858
The bell curve e^(−x²) and its derivative −2x e^(−x²): positive while the bell rises, zero at its top, negative as it falls.
Fill the blanksInteractive · disabled in the PDF
Differentiate . Write the inner derivative as a number times a power.
Text
1inner u = 5x^3, du/dx = 2outer cos u, dy/du = 3dy/dx = -sin(5x^3) * 15x^2
ProblemInteractive · disabled in the PDF
Differentiate , and find the slope at .
Calculus63 / 237
Module 6 · The chain rule and implicit differentiation
The mistake everyone makes once
The most common slip is to differentiate the outer function and stop, forgetting to multiply by the derivative of the inside. A quick check: if the inside is just , the extra factor is , so nothing is lost; any other inside adds a factor.
Find the bugInteractive · disabled in the PDF
This differentiates . One line is wrong. Which?
Text
Layers. For a function nested three deep, like , peel one layer at a time from the outside: . One factor for each layer.
Calculus64 / 237
Module 6 · The chain rule and implicit differentiation
The chain rule as code
In code a function is a value, so you can build the derivative of a composite from its parts: given , and , return a new function of . In C++ that new function is a lambda, and it uses fPrime, g and gPrime, which belong to the function that makes it. A lambda lists what it takes from around it in its [ ]: [=] copies everything it uses, so the lambda still has them after chainDerivative has returned.
Code challengeInteractive · disabled in the PDF
Write chainDerivative(fPrime, g, gPrime). It returns a function of x giving the derivative of f(g(x)), by the chain rule.
Module 6 · The chain rule and implicit differentiation
Implicit differentiation
The circle isn’t the graph of one function: for most there are two $y$s. But near any point it has a tangent with a slope. Implicit differentiation finds it without solving for : differentiate both sides with respect to , treating as a function of , so the chain rule turns into .
At the slope is . At it is : same , different point, different slope.
x² + y² = 25
Tangent
x2.99
y4.01
Slope −x/y−0.746
Drag θ to move the point round the circle. The tangent’s slope is −x/y, and it is upright where y = 0.
ProblemInteractive · disabled in the PDF
The point is on the ellipse . Find the slope of the tangent there, and the tangent line as .
Calculus66 / 237
Module 6 · The chain rule and implicit differentiation
Implicit differentiation, step by step
A harder curve: the folium of Descartes, . The point is on it (). The term is a product, so it needs the product rule as well as the chain rule.
Put in orderInteractive · disabled in the PDF
Put the steps of implicit differentiation in order.
1.Differentiate both sides with respect to
2.Collect the terms with on one side
3.Wherever is differentiated, multiply by (the chain rule)
4.Substitute the point’s and
5.Factor out and divide to get alone
Calculus67 / 237
Module 6 · The chain rule and implicit differentiation
Derivatives of inverse functions
An inverse function undoes : if then . Its graph is ’s graph reflected in the line , which swaps rise and run, so the slopes are reciprocals:
This proves the derivative of that module 5 asked you to trust. If then . Differentiating implicitly, , so .
QuizInteractive · disabled in the PDF
has an inverse, and . What is ?
has an inverse, and . What is ?
Calculus68 / 237
Module 6 · The chain rule and implicit differentiation
Logarithmic differentiation
In the variable is in the base and the exponent, so neither the power rule nor the exponential rule applies. Take logarithms first: they turn powers into products, which are easy to differentiate. Then differentiate implicitly.
The same trick tames big products and quotients, like : the logarithm turns it into , a sum, before you differentiate.
QuizInteractive · disabled in the PDF
At what is the slope of equal to ?
At what is the slope of equal to ?
Calculus69 / 237
Module 6 · The chain rule and implicit differentiation
Derivatives of the inverse trig functions
is the angle in whose sine is ; is the angle in whose tangent is . Implicit differentiation gives their derivatives. For , , so and, since :
arctan x
1/(1 + x²)
π/2
arctan levels off at ±π/2, so its slope 1/(1 + x²) is largest at 0 and fades away on both sides.
QuizInteractive · disabled in the PDF
What is ?
What is ?
Calculus70 / 237
Module 6 · The chain rule and implicit differentiation
Practice problems
ProblemInteractive · disabled in the PDF
Differentiate (a) and (b) .
ProblemInteractive · disabled in the PDF
Differentiate and factor the result. At which is the tangent flat?
ProblemInteractive · disabled in the PDF
has an inverse. Find and .
ProblemInteractive · disabled in the PDF
Use logarithmic differentiation to differentiate (for ). What is the slope at ?
Calculus71 / 237
Module 6 · The chain rule and implicit differentiation
More practice problems
ProblemInteractive · disabled in the PDF
The point is on the curve . Find there, and the tangent line as .
ProblemInteractive · disabled in the PDF
Let . Find the slope of its graph at and at .
Calculus72 / 237
Module 6 · The chain rule and implicit differentiation
Recap
Chain rule: ; rates multiply.
Peel layers from the outside, one factor per layer, and never forget the inside.
Implicit differentiation: differentiate both sides, terms gain a , then solve for .
Inverse functions have reciprocal slopes at matching points.
Logarithms turn and messy products into sums before differentiating.
, .
FlashcardsInteractive · disabled in the PDF
Chain rule
Inner function
The one applied first: in , it is .
, with a function of
Derivative of an inverse
where .
Module 7: Graphs, extremes and optimisation
Calculus73 / 237
Module 7 · Graphs, extremes and optimisation
The sign of the derivative says rising or falling
Where , the tangent slopes up and is increasing; where , is decreasing. So to find where a function rises and falls, find where its derivative is positive and negative. The running example of this module is:
is at and , and can only change sign there. Test one number in each piece:
Interval
Test point
Sign of
is
increasing
decreasing
increasing
f(x)
f′(x)
f rises, falls, then rises again. Its derivative (dashed) is below the axis exactly where f falls.
Calculus74 / 237
Module 7 · Graphs, extremes and optimisation
Critical points are where the slope is zero or undefined
A local maximum is a point higher than every point near it, the top of a hill; a local minimum is the bottom of a valley. At a local maximum or minimum of a differentiable function, the tangent must be flat: (Fermat’s theorem). So you look for them among the critical points: the where or doesn’t exist.
Critical doesn’t mean extreme. Every local extreme (of a function defined around it) is a critical point, but not every critical point is an extreme. has and keeps rising straight through. And has its minimum at , a critical point where doesn’t exist.
QuizInteractive · disabled in the PDF
What are the critical points of ?
What are the critical points of ?
Calculus75 / 237
Module 7 · Graphs, extremes and optimisation
The first derivative test
Look at how changes sign as you pass through a critical point , left to right:
to (up, then down): a local maximum.
to (down, then up): a local minimum.
no change of sign: neither.
For the running example, goes to at and to at . So there is a local maximum and a local minimum .
QuizInteractive · disabled in the PDF
. What does have at ?
. What does have at ?
ProblemInteractive · disabled in the PDF
Find the local maximum and the local minimum of : where each one is, and its value.
Calculus76 / 237
Module 7 · Graphs, extremes and optimisation
The second derivative says which way it bends
is the rate of change of the slope. Where the slope is increasing and the curve bends upward like a cup: concave up. Where it bends downward like a cap: concave down. A point where the concavity changes is an inflection point.
For the running example : negative for , positive for . So is an inflection point, where the curve is steepest downhill.
f(x)
Tangent at a
f′(a)2.88
f″(a)−8.4
Drag a. Left of x = 2 the tangent lies above the curve (concave down); right of it, below (concave up).
Concave up
: the slope increases; the curve holds water.
Concave down
: the slope decreases; the curve sheds water.
Inflection point
Where the concavity changes from one to the other.
Calculus77 / 237
Module 7 · Graphs, extremes and optimisation
The second derivative test
At a critical point with , the bending tells you which kind it is, without a sign table. A cup has its bottom at a minimum; a cap has its top at a maximum.
: local minimum.
: local maximum.
: the test says nothing; go back to the first derivative test.
Running example: , a maximum; , a minimum. Same answers as before, as they must be.
QuizInteractive · disabled in the PDF
For , and . What is at ?
For , and . What is at ?
Calculus78 / 237
Module 7 · Graphs, extremes and optimisation
The mean value theorem
If you drive 120 km in one hour, at some moment your speedometer read exactly 120 km/h. That is the mean value theorem: if is continuous on and differentiable inside, then somewhere between, the instantaneous rate equals the average rate.
f(x) = x³
Secant from 0 to 2
Tangent at c
Tangent slope 3c²1.08
Secant slope4
f(x) = x³ on [0, 2]: the secant has slope 4. Drag c until the tangent is parallel to it, at c = 2/√3 ≈ 1.155.
QuizInteractive · disabled in the PDF
The mean value theorem implies which of these?
The mean value theorem implies which of these?
ProblemInteractive · disabled in the PDF
Find the number that the mean value theorem promises for on .
Calculus79 / 237
Module 7 · Graphs, extremes and optimisation
Sketching a curve from its derivatives
Put it all together and you can draw an accurate graph by hand, or check one a computer drew. For the running example: it crosses the -axis at , rises to a hilltop at , bends through , falls to a valley at , then climbs forever.
Put in orderInteractive · disabled in the PDF
Put the steps of sketching in a sensible order.
1.Check what happens as and near any asymptotes
2.Plot the key points and join them with the right shape
3.Compute and find the concavity and inflection points
4.Compute and find the critical points
5.Find the domain, and where the graph crosses the axes
6.Use the sign of to find where rises and falls, and classify the extremes
Calculus80 / 237
Module 7 · Graphs, extremes and optimisation
The biggest value on a closed interval
The extreme value theorem (module 3) promises a highest and a lowest value of a continuous on . Each is either at a critical point inside, or at an end. So the closed interval method is: list the critical points inside, evaluate there and at both ends, and pick the largest and smallest.
QuizInteractive · disabled in the PDF
What is the maximum of the running example on ?
What is the maximum of the running example on ?
Calculus81 / 237
Module 7 · Graphs, extremes and optimisation
Optimisation: finding the best design
Optimisation problems ask for the biggest or smallest of something real. The method: name the variable, write the quantity as a function of one variable (using the constraint), find its domain, then use the closed interval method. Example: with 100 m of fence, what rectangle encloses the most area? Sides and , so on .
The best rectangle is a 25 m square.
A(x) = x(50 − x)
Other side (m)40
Area (m²)400
A′(x)30
Drag x, one side of the rectangle. The area peaks where the slope of A is 0.
QuizInteractive · disabled in the PDF
From a 30 cm square of card, cut a square of side from each corner and fold up an open box: . Which gives the biggest volume?
From a 30 cm square of card, cut a square of side from each corner and fold up an open box: . Which gives the biggest volume?
Calculus82 / 237
Module 7 · Graphs, extremes and optimisation
Finding a maximum by computer
When is hard to solve, a computer can search. If rises to one peak and then falls on (it is unimodal), compare it at two inner points . If the peak can’t be left of , so drop ; otherwise drop . Taking and at the thirds shrinks the interval by a third each step: ternary search.
Code challengeInteractive · disabled in the PDF
Write findMax(f, a, b) for a unimodal f on [a, b]: repeat the ternary search step until b - a < 1e-9, then return the midpoint, the of the peak.
C++
1#include<functional>23doublefindMax(std::function<double(double)> f,double a,double b){4 // TODO: shrink [a, b] around the peak5return a;6}
Going deeper
Golden-section search. Ternary search evaluates twice per step. Placing the inner points at the golden ratio, , lets one of them be reused in the next step, so each step costs one evaluation and shrinks the interval by . That matters when each is an expensive simulation.
Calculus83 / 237
Module 7 · Graphs, extremes and optimisation
Practice problems
ProblemInteractive · disabled in the PDF
Find the inflection point of , and the slope of the curve there.
ProblemInteractive · disabled in the PDF
Find the largest and the smallest values of on .
ProblemInteractive · disabled in the PDF
A farmer has m of fence to make a rectangular field beside a straight river. The side along the river needs no fence. Which dimensions give the largest area, and what is that area?
m
m
m²
ProblemInteractive · disabled in the PDF
Which point of the curve is closest to the point ? Give its , and its distance from .
Calculus84 / 237
Module 7 · Graphs, extremes and optimisation
More practice problems
ProblemInteractive · disabled in the PDF
An open-topped box with a square base must hold cm³. Which base side and height use the least cardboard, and how much cardboard is that?
cm
cm
cm²
ProblemInteractive · disabled in the PDF
A closed cylindrical can must hold cm³. Which radius and height use the least metal? (Its volume is , and its surface is two discs and a side, .)
cm
cm
Calculus85 / 237
Module 7 · Graphs, extremes and optimisation
Recap
: increasing; : decreasing.
Critical points: or undefined. Local extremes are among them, but not every one is an extreme.
First derivative test: is a maximum, a minimum.
: concave up; : concave down; inflection where it changes.
Second derivative test: minimum, maximum, no information.
Mean value theorem: some instantaneous rate equals the average rate.
On , compare critical points and ends. Optimisation is that, applied to a real quantity.
FlashcardsInteractive · disabled in the PDF
Critical point
A in the domain with or undefined.
First derivative test
Sign of changes to : max; to : min; no change: neither.
Inflection point
Where the concavity (the sign of ) changes.
Second derivative test fails when…
: it could be a max, a min or neither.
Mean value theorem
for some in .
Closed interval method
Evaluate at critical points and at both ends; take the largest and smallest.
Module 8: Linear approximation, related rates and Newton's method
Calculus86 / 237
Module 8 · Linear approximation, related rates and Newton's method
Near a point, a curve is almost its tangent
Zoom in on a smooth curve and it looks straight (module 4). So near you can replace by its tangent line, which is much easier to compute. That line, used as an approximation, is the linearisation of at :
Estimate without a calculator. Use at , where you know the answer: and .
√x
L(x), the tangent at 4
Estimate L(x)2.025
True √x2.02485
Error1.54e−4
Drag x away from 4: the tangent stays close to the curve nearby and drifts away further out.
ProblemInteractive · disabled in the PDF
Linearise at , and use it to estimate .
Calculus87 / 237
Module 8 · Linear approximation, related rates and Newton's method
Approximations worth knowing by heart
Linearising at gives a few approximations that engineers and physicists use every day, valid when is small:
Function
Near
Used for
a pendulum’s small swings ( in radians)
small angles in optics and surveying
small growth rates
percentage changes
small corrections to a power
QuizInteractive · disabled in the PDF
Linearise at to estimate .
Linearise at to estimate .
Calculus88 / 237
Module 8 · Linear approximation, related rates and Newton's method
A linearisation as code
Code challengeInteractive · disabled in the PDF
Write linearise(f, fPrime, a). It returns the function .
Module 8 · Linear approximation, related rates and Newton's method
Differentials: small changes in, small changes out
The same idea, written as changes. If changes by a small amount , then changes by about . The quantities and are called differentials; is the change along the tangent, an estimate of the true change .
A 1 mm error in measuring a 10 cm radius makes about a 6.28 cm² error in the area. The true change is cm².
Fill the blanksInteractive · disabled in the PDF
A sphere has . Estimate the change in volume when goes from 5 cm to 5.02 cm. Leave as pi.
Text
1dV = 4 pi r^2 dr2 = 4 pi () ()3 = pi cm^3, about 6.28 cm^3
Calculus90 / 237
Module 8 · Linear approximation, related rates and Newton's method
How big is the error?
Measurement errors spread through formulas. The relative error is the error divided by the value. Dividing by often gives a neat rule: for , , so a power multiplies the relative error by .
QuizInteractive · disabled in the PDF
You measure a cube’s side with a possible error of 1%. About how large can the error in its volume be, relatively?
You measure a cube’s side with a possible error of 1%. About how large can the error in its volume be, relatively?
How wrong is the linearisation itself? The tangent is off by about half the second derivative times the distance squared. For : , so the error is about . The real error is .
Twice as far from means four times the error. Module 16 makes this exact with Taylor’s theorem.
Calculus91 / 237
Module 8 · Linear approximation, related rates and Newton's method
Related rates
When two quantities are linked by an equation and both change in time, their rates are linked too. Differentiate the equation with respect to time (implicitly, with the chain rule) to get an equation between the rates. Example: air is pumped into a spherical balloon at 100 cm³/s. How fast is the radius growing when it is 5 cm?
Substitute last. Plug in only after differentiating. If you set first, becomes a constant and its rate of change is : the equation must hold at all times for its derivative to mean anything.
ProblemInteractive · disabled in the PDF
A stone dropped in a pond makes a circular ripple whose radius grows at cm/s. How fast is the area inside the ripple growing when the radius is cm?
cm²/s
Calculus92 / 237
Module 8 · Linear approximation, related rates and Newton's method
The sliding ladder
A 5 m ladder leans on a wall. Its foot slides away at 0.5 m/s. How fast is the top sliding down when the foot is 3 m from the wall? Let be the foot’s distance and the top’s height. Pythagoras links them: .
Height y (m)4
dy/dt (m/s)−0.375
Drag the foot outward. The top falls slowly at first and faster and faster as the ladder flattens.
Put in orderInteractive · disabled in the PDF
Put the steps for solving a related rates problem in order.
1.Differentiate it with respect to time
2.Write the given rate and the wanted rate as derivatives
3.Substitute the values at the moment asked about, and solve
4.Draw a picture and name the changing quantities
5.Write an equation linking the quantities
Calculus93 / 237
Module 8 · Linear approximation, related rates and Newton's method
Newton’s method rides tangents to a root
To solve , start from a guess . Replace by its tangent there and solve that, which is easy: the tangent is at the next guess . Repeat. This is Newton’s method.
f(x) = x² − 2
Tangent at x₀
x₁1.833333
x₂1.462121
f(x) = x² − 2. Drag the guess: the tangent there crosses the axis at the next guess, much nearer √2 ≈ 1.414.
For the step simplifies to : the method the Babylonians used for square roots, nearly 4000 years ago.
Calculus94 / 237
Module 8 · Linear approximation, related rates and Newton's method
Newton’s method doubles the digits each step
Error
0
1
2
3
4
Roughly the number of correct digits, −log₁₀ of the error, after each step: it about doubles.
Each error is roughly a constant times the square of the one before: this is quadratic convergence. Compare bisection (module 3), which gains a digit only every 3.3 steps. Newton’s method is how computers and calculators find square roots, and the core of many solvers.
Code challengeInteractive · disabled in the PDF
Write newton(f, fPrime, x0, steps): start at x0, take steps Newton steps, and return the last .
C++
1#include<functional>23usingFn= std::function<double(double)>;45doublenewton(Fn f,Fn fPrime,double x0,int steps){6double x = x0;7 // TODO: take the steps8return x;9}
Calculus95 / 237
Module 8 · Linear approximation, related rates and Newton's method
When Newton’s method fails
Newton’s method is fast near a root but has no guarantee, unlike bisection. It goes wrong in three classic ways:
A flat tangent: if , the tangent never crosses the axis and the step divides by zero.
A cycle: for from , the guesses go for ever.
Running away: for , the step works out to , so each guess is twice as far from the root .
PlaygroundInteractive · disabled in the PDF
C++
1#include<iostream>23intmain(){4auto f =[](double x){return x * x * x -2* x +2;};5auto fPrime =[](double x){return3* x * x -2;};67double x =0;8for(int i =1; i <=8; i++){9 x = x -f(x)/fPrime(x);10 std::cout << i <<" "<< x <<"\n";11}12}
It cycles. Change the start to x = -2: now it finds the real root, about −1.7693.
QuizInteractive · disabled in the PDF
What is a robust way to combine the two root finders you know?
What is a robust way to combine the two root finders you know?
Calculus96 / 237
Module 8 · Linear approximation, related rates and Newton's method
Practice problems
ProblemInteractive · disabled in the PDF
A cube’s side is measured as cm, with a possible error of cm. Use a differential to estimate the possible error in its volume, then give that as a percentage of the volume.
cm³
%
ProblemInteractive · disabled in the PDF
A m ladder leans against a wall, and its foot is pulled away from the wall at m/s. How fast is the top moving when the foot is m from the wall? Give , where is the height of the top (it is negative, since the top falls).
m/s
ProblemInteractive · disabled in the PDF
Use Newton’s method on , starting from . Find and .
ProblemInteractive · disabled in the PDF
Water pours at m³/min into a tank shaped like a cone, point down, m deep with a top radius of m. How fast is the water level rising when the water is m deep? (A cone’s volume is .)
m/min
Calculus97 / 237
Module 8 · Linear approximation, related rates and Newton's method
More practice problems
ProblemInteractive · disabled in the PDF
Use the linearisation of at (that is, ) to estimate . Remember to work in radians.
ProblemInteractive · disabled in the PDF
A ball’s radius is measured with a possible error of . (a) About how large can the relative error in its volume be? (b) To know the volume to within , how precisely must the radius be measured?
%
%
Calculus98 / 237
Module 8 · Linear approximation, related rates and Newton's method
Recap
Linearisation: near .
Differentials: estimates the change in .
For , relative errors are multiplied by .
The linearisation’s error is about .
Related rates: link the quantities, differentiate in , then substitute.
Newton’s method: , quadratically fast near a root, but it can cycle or run away.
FlashcardsInteractive · disabled in the PDF
Linearisation of at
for small
, in radians.
Differential
: the change along the tangent.
Related rates, the rule
Differentiate the equation first, substitute the moment’s values after.
Newton’s step
Quadratic convergence
Each error is about a constant times the previous one squared: the digits double.
Module 9: Area and the definite integral
Calculus99 / 237
Module 9 · Area and the definite integral
The area problem
Module 1 showed that distance is the area under a speed graph. For rectangles and triangles that area is easy. But what is the area under the curve , between and ? No school formula gives it, because the top edge is curved.
y = x²
y = x
The region under y = x² from 0 to 1. Its area is less than the triangle under y = x, which is 1/2.
The idea, which goes back to Archimedes: cut the region into thin vertical strips, treat each strip as a rectangle, and add up the rectangles. Thinner strips fit the curve better. In the limit of infinitely many infinitely thin strips, the sum becomes the exact area. That limit is the definite integral.
Calculus100 / 237
Module 9 · Area and the definite integral
Approximating with rectangles
Split into strips of width . Each rectangle needs a height: the curve’s height at the strip’s left end, its right end, or its midpoint. The total area of the rectangles is a Riemann sum (after Bernhard Riemann, 1854).
Rectangles
y = x²
Sum of the rectangles0.21875
Exact area0.33333
Drag n for more strips, and r to choose where each height is taken: 0 left, 0.5 midpoint, 1 right. Every choice closes in on 1/3.
Left sums sit under this rising curve and right sums above it, so the true area is trapped between them. With : left , right . With : left , right . Both head for .
Calculus101 / 237
Module 9 · Area and the definite integral
Sigma notation for long sums
Riemann sums have many terms, so they are written with , the Greek capital sigma, for "sum". Below the sigma is the counter and where it starts; above it, where it stops; to the right, the term for each value of the counter.
Two formulas make Riemann sums of and exact, which is how the was proved before calculus:
QuizInteractive · disabled in the PDF
What is ?
What is ?
ProblemInteractive · disabled in the PDF
Use the sum formulas to find (a) and (b) .
Calculus102 / 237
Module 9 · Area and the definite integral
Riemann sums in general
For any on with strips: the width is , and the strips’ edges are for . Then:
Code challengeInteractive · disabled in the PDF
Write riemann(f, a, b, n, rule), the left, right or midpoint Riemann sum of f on [a, b] with n strips. Rule is an enum class: a type whose only values are the ones it lists, Rule::left, Rule::right and Rule::midpoint.
C++
1#include<functional>23enumclassRule{left,right,midpoint};45doubleriemann(std::function<double(double)> f,6double a,double b,int n,Rule rule){7double dx =(b - a)/ n;8double sum =0;9 // TODO: add up n rectangles10return sum;11}
ProblemInteractive · disabled in the PDF
Work out the left, right and midpoint sums for on with strips.
Calculus103 / 237
Module 9 · Area and the definite integral
The definite integral is the limit of the sums
As the strips get infinitely thin. For a continuous , all the Riemann sums (left, right, midpoint, any point in each strip) approach the same number. That number is the definite integral of from to :
Leibniz’s is a stretched S, for "sum"; is the infinitely thin width that becomes.The exact area under , from the sum formula and a limit at infinity (module 2).
Integrand
The function being integrated, .
Limits of integration
(lower) and (upper): where the area starts and stops.
$dx$
Says that is the variable you are summing along.
Integrable
A function whose Riemann sums have a limit. Every continuous function on is.
Calculus104 / 237
Module 9 · Area and the definite integral
Area below the axis counts as negative
Where , the rectangles are negative. So the integral is a signed area: area above the -axis minus area below it. That is not a flaw; it is exactly what you need for things like displacement, where moving backwards cancels moving forwards.
sin x
Running integral
Integral from 0 to b1.2108
Drag b. The integral of sin from 0 to b grows while sin is above the axis, then shrinks; at b = 2π the two halves cancel.
QuizInteractive · disabled in the PDF
What is ?
What is ?
Calculus105 / 237
Module 9 · Area and the definite integral
Properties of the integral
Because integrals are limits of sums, they inherit the rules of sums. And splitting the interval splits the area.
One more: if on , then . A bigger function has a bigger integral.
QuizInteractive · disabled in the PDF
Given and , what is ?
Given and , what is ?
Calculus106 / 237
Module 9 · Area and the definite integral
Displacement and distance from velocity
A cart moves along a track with velocity m/s for s: forward until , then backward. The integral of is the displacement, how far it ends from where it started. The integral of is the total distance it travelled, counting backward as distance too.
v(t) = 10 − 2t
Displacement (m)16
Drag T. Area above the axis is forward motion, below is backward. The readout is the signed total.
QuizInteractive · disabled in the PDF
Over the 8 seconds, the displacement is m. What is the total distance travelled?
Over the 8 seconds, the displacement is m. What is the total distance travelled?
Code challengeInteractive · disabled in the PDF
Write displacement(v, a, b, n) and distance(v, a, b, n): midpoint Riemann sums with n strips of v and of its absolute value.
For the same number of strips, the midpoint sum is usually far better than the left or right sums. On a strip where the curve is nearly straight, the midpoint rectangle’s overshoot on one half cancels its undershoot on the other.
Error of each sum for the area under x² on [0, 1], with 4 strips.
Doubling roughly halves the left and right errors but quarters the midpoint error: the same pattern as forward and central differences in module 4. Module 13 builds better rules still (trapezoids, Simpson’s rule) and measures their errors properly.
Calculus108 / 237
Module 9 · Area and the definite integral
Practice problems
ProblemInteractive · disabled in the PDF
Write the right sum for as a formula in . Then find the integral as its limit.
ProblemInteractive · disabled in the PDF
Find these integrals from areas you know: (a) and (b) .
ProblemInteractive · disabled in the PDF
You know , and . Find (a) , (b) and (c) .
ProblemInteractive · disabled in the PDF
A lift moves with velocity m/s for s, with up counted as positive. Find its displacement, and the total distance it travels.
m
m
Calculus109 / 237
Module 9 · Area and the definite integral
More practice problems
ProblemInteractive · disabled in the PDF
The area under from to is exactly . Work out the midpoint sums and for it.
ProblemInteractive · disabled in the PDF
Find without any sums.
Calculus110 / 237
Module 9 · Area and the definite integral
Recap
Cut the region into strips of width and add up rectangles: a Riemann sum.
Left, right and midpoint sums take the height at different points; midpoint is the most accurate.
is the limit of the Riemann sums as .
The integral is a signed area: below the axis counts as negative.
Integrals add over intervals, and flip sign when the limits are swapped.
is displacement; is total distance.
FlashcardsInteractive · disabled in the PDF
Riemann sum
: the total area of rectangles under a curve.
for strips on
Definite integral
The limit of Riemann sums: .
Displacement vs distance
vs
Module 10: The fundamental theorem of calculus
Calculus111 / 237
Module 10 · The fundamental theorem of calculus
An area that grows as you move the end
Fix the left end of an area at and let the right end move. The area so far is then a function of where the right end is, . It is called an accumulation function: it accumulates as moves along. The letter inside changes to so that can be the end.
f(t) = cos t
A(x), the area so far
A(x)0.932
f(x), the height at the end0.3624
f(t) = cos t from 0 to x. Drag x: the shaded area A(x) traces out the dashed curve, which is sin x. Where f is big, A climbs fast; where f is negative, A falls.
Watch the readouts as you drag: the rate at which the area grows always equals the height of at the moving end. That observation is the first half of the fundamental theorem.
Calculus112 / 237
Module 10 · The fundamental theorem of calculus
Part 1: the area’s rate of growth is the height
Nudge the end from to . The area gains a thin strip of width and height about , so . Divide by and let ; for continuous the approximation becomes exact:
The fundamental theorem of calculus, part 1. It holds for every continuous , and the starting point doesn’t matter.
In words: differentiating an accumulated area gives back the function you accumulated. Integration, then differentiation, brings you back where you started. Speed and distance from module 1 are the everyday case: the rate at which distance builds up is the speed.
QuizInteractive · disabled in the PDF
Let . What are and ?
Let . What are and ?
Calculus113 / 237
Module 10 · The fundamental theorem of calculus
Part 1 with the chain rule
When the upper limit is itself a function of , say , the accumulation is , a composite. The chain rule (module 6) adds the factor :
An antiderivative of is any function with . is an antiderivative of . So are and , because a constant has derivative . And those are all of them: two functions with the same derivative differ by a constant (a consequence of the mean value theorem, module 7).
x³/3
x³/3 + C
Tangent
Slope at x1.44
Drag C. Every curve x³/3 + C is the same shape shifted up or down, so all have the same slope x² at each x.
QuizInteractive · disabled in the PDF
Which function is an antiderivative of ?
Which function is an antiderivative of ?
Calculus115 / 237
Module 10 · The fundamental theorem of calculus
A table of antiderivatives
Each derivative rule from modules 5 and 6, read backwards, is an antiderivative. The indefinite integral , with no limits, means the whole family of antiderivatives, so it carries .
()
Why ln |x|. only exists for , but exists for negative too. For , . The absolute value covers both sides at once.
QuizInteractive · disabled in the PDF
What is ?
What is ?
Calculus116 / 237
Module 10 · The fundamental theorem of calculus
Part 2: evaluate an integral with any antiderivative
Part 1 says is an antiderivative of . Any other antiderivative differs from it by a constant: . So , which is the integral. The constant cancels:
The fundamental theorem of calculus, part 2. An area becomes two evaluations of an antiderivative.The that took a page of Riemann sums in module 9 is now one line.
Why it’s fundamental. Before Newton and Leibniz, each area was a clever one-off, like Archimedes’ parabola. The theorem turns every area problem into the search for an antiderivative, and every rate problem into a derivative. It also explains why derivatives and integrals, defined by completely different limits, are inverse operations.
Calculus117 / 237
Module 10 · The fundamental theorem of calculus
Working with indefinite integrals
Integrals are linear, like derivatives: integrate term by term and pull constants out. Add one at the end.
Fill the blanksInteractive · disabled in the PDF
Find . Write powers with ^.
Text
1integral of 6x^5 = 2integral of 2/x = 2 ln|x|3integral of -e^x = 4so the answer is x^6 + 2 ln|x| - e^x +
Calculus118 / 237
Module 10 · The fundamental theorem of calculus
Evaluating a definite integral without slips
Find the bugInteractive · disabled in the PDF
This computes . One line is wrong. Which?
Text
The function must be continuous. Part 2 needs continuous on all of . Blindly, : a negative area for a function that is never negative. The trouble is , where blows up. Integrals like that are improper (module 14).
QuizInteractive · disabled in the PDF
What is ?
What is ?
ProblemInteractive · disabled in the PDF
Evaluate .
Calculus119 / 237
Module 10 · The fundamental theorem of calculus
The net change theorem
Part 2, read with as a rate, says: integrating a rate of change gives the total change. That is the net change theorem, and it is how integrals are used everywhere:
Water flows into a tank at litres per minute for minutes. The water gained is litres. The same reasoning turns a population’s growth rate into the people added, or a power in watts into energy in joules.
r(t) = 20 − 4t
Water added (L)37.5
Drag T. The shaded area under the flow rate is the water added so far.
QuizInteractive · disabled in the PDF
A town grows at people per year. How many people does it gain from to years?
A town grows at people per year. How many people does it gain from to years?
Calculus120 / 237
Module 10 · The fundamental theorem of calculus
Both parts of the theorem, in code
Code challengeInteractive · disabled in the PDF
Write accumulate(f, a, n). It returns the function , worked out with a midpoint sum of n strips each time it is called. The last test checks part 1: the slope of is .
Polynomials are vectors of coefficients, lowest power first, as in module 5. Write integratePoly(c), the antiderivative with constant 0, and definite(c, a, b), the integral from a to b by part 2.
Water flows out of a tank at litres per minute, minutes after a valve opens. The tank holds litres when it opens. How much flows out in the first minutes, and how much is left then?
L
L
ProblemInteractive · disabled in the PDF
A particle moves with velocity m/s. Over s, find its displacement and the total distance it travels.
m
m
Calculus122 / 237
Module 10 · The fundamental theorem of calculus
More practice problems
ProblemInteractive · disabled in the PDF
Find in each: (a) , and (b) , with .
ProblemInteractive · disabled in the PDF
Let . Where does have a local minimum, and what is its value there?
Calculus123 / 237
Module 10 · The fundamental theorem of calculus
Recap
An accumulation function is the area so far.
Part 1: ; with an upper limit , multiply by .
Antiderivatives of form a family ; the indefinite integral names it.
Part 2: for any antiderivative , if is continuous on .
Net change: integrating a rate gives the total change.
Differentiation and integration undo each other.
FlashcardsInteractive · disabled in the PDF
FTC part 1
FTC part 2
, where .
Antiderivative
Any with . All of them differ by a constant.
, for .
Net change theorem
: the integral of a rate is the total change.
Module 11: Substitution and integration by parts
Calculus124 / 237
Module 11 · Substitution and integration by parts
Every derivative rule runs backwards
The fundamental theorem turns a definite integral into a search: find an antiderivative , a function with , and then . Differentiating is mechanical: the rules always work. Integrating is not: you have to recognise which rule produced the function you are looking at, and run it backwards.
Derivative rule
Run backwards, it becomes
Power rule:
, for
Chain rule:
Substitution
Product rule:
Integration by parts
Always check by differentiating. An antiderivative is easy to check even when it was hard to find: differentiate your answer and see whether you get the integrand back. Do this every time; it catches almost every slip.
QuizInteractive · disabled in the PDF
Which function is an antiderivative of ?
Which function is an antiderivative of ?
Calculus125 / 237
Module 11 · Substitution and integration by parts
Substitution undoes the chain rule
Look for an inner function whose derivative also appears, as a factor, in the integrand. Write , replace everything in terms of , integrate in , then put back.
The integrand had , not : a constant factor is fine, because you can move it out of the integral.
QuizInteractive · disabled in the PDF
What is ?
What is ?
ProblemInteractive · disabled in the PDF
Find the antiderivative of with . Then use it to work out .
Going deeper
Writing looks like treating as a fraction. It is shorthand for the chain rule, and it is safe here because the result can always be checked by differentiating. Leibniz chose the notation precisely because it makes this bookkeeping come out right.
Calculus126 / 237
Module 11 · Substitution and integration by parts
With a definite integral, change the limits too
In a definite integral the limits are values of . When you switch to , change them into values of as well. Then you never need to go back to .
2x(x²+1)³ on [0, 1]
u³ on [1, 2]
Two curves over two intervals, one area: and are both . Substitution stretches and squashes the strip without changing its area.
QuizInteractive · disabled in the PDF
Someone substitutes in but keeps the limits 0 and 1. What do they get?
Someone substitutes in but keeps the limits 0 and 1. What do they get?
ProblemInteractive · disabled in the PDF
Evaluate exactly, changing the limits as you substitute.
Calculus127 / 237
Module 11 · Substitution and integration by parts
Integration by parts undoes the product rule
The product rule says . Integrate both sides and rearrange, and you get a way to trade one integral for another. You choose (to differentiate) and (to integrate) so that the new integral, , is simpler than the one you started with.
Check: . Differentiating made it disappear; that is why it was the right .
Choosing u. Pick for whatever gets simpler when differentiated, roughly in this order: Logarithms, Inverse trig, Algebraic (powers of ), Trig, Exponentials (LIATE). The part must be something you can integrate.
QuizInteractive · disabled in the PDF
What is ?
What is ?
ProblemInteractive · disabled in the PDF
Evaluate by parts.
Going deeper
With nothing to multiply, take and .
Sometimes parts comes back to where it started. For , parts twice gives , so : you solve for the integral as an unknown.
Calculus128 / 237
Module 11 · Substitution and integration by parts
Trig identities turn powers into things you can integrate
For powers of and , an identity usually opens the door. Even powers: halve the angle with and . Odd powers: split off one factor and use , then substitute.
sin² x
Its average, ½
Over a whole number of half-periods, averages exactly : the bumps above the dashed line fill the dips below it. So the area over is .
QuizInteractive · disabled in the PDF
Which are antiderivatives of ? Choose every one.
Which are antiderivatives of ? Choose every one.
Going deeper
An odd power: keep one for and turn the rest into cosines, then .
Calculus129 / 237
Module 11 · Substitution and integration by parts
Partial fractions split a fraction into easy pieces
A rational function is one polynomial divided by another. When the bottom factors into distinct linear pieces, the fraction splits into a sum of simple fractions, each of which integrates to a logarithm. To find each numerator, the cover-up trick: for , cover the factor in the original and put into what is left.
Check by adding back: .
QuizInteractive · disabled in the PDF
Split . What are and ?
Split . What are and ?
Before you split. The top must have a lower degree than the bottom; if not, divide the polynomials first. A factor that will not split, like , gives an arctangent instead of a log: . A repeated factor needs two terms, .
Calculus130 / 237
Module 11 · Substitution and integration by parts
Try it: cover-up and checking by differentiating
Two small programs. The first does the cover-up trick for any fraction . The second checks a proposed antiderivative the way you should by hand: differentiate it, numerically, and compare with the integrand at some points.
Code challengeInteractive · disabled in the PDF
Write coverUp(p, q, a, b): it returns the pair {A, B} with , for . A std::pair<double, double> holds two numbers; auto [A, B] = coverUp(…) unpacks them.
Write isAntiderivative(F, f, xs): it returns true when, at every point in xs, the central difference (F(x + h) - F(x - h)) / (2 * h) with h = 1e-5 is within 1e-6 of f(x).
There is no single recipe, but a good order to try saves time. Most integrals in practice give way at one of these steps.
You see
Try
A sum, or something you can expand or simplify
Split it and use the basic table
A function of times
Substitution,
A product of unlike kinds: , ,
Integration by parts
Powers of and
A trig identity, then substitution
A polynomial over a polynomial
Divide, then partial fractions
None of these work
A table, a computer algebra system, or a numerical method
QuizInteractive · disabled in the PDF
Which method suits , and with which ?
Which method suits , and with which ?
Put in orderInteractive · disabled in the PDF
Put the steps of integrating by parts in order.
1.Choose and
2.Write
3.Work out and
4.Differentiate the answer to check it gives
5.Integrate what is left:
Calculus132 / 237
Module 11 · Substitution and integration by parts
Some integrals have no formula at all
Every continuous function has an antiderivative (the fundamental theorem builds one: ). But often that antiderivative cannot be written with the usual functions: powers, roots, exponentials, logs, trig and their combinations, the elementary functions. , , and are all like that. No amount of cleverness will find a formula: it has been proved there is none.
e^(−x²)
x·e^(−x²): this one has a formula
The bell curve : a perfectly smooth function with a definite area under it, in total, but no elementary antiderivative.So mathematicians name the integral and treat it as a new function: the error function, which is everywhere in statistics.
QuizInteractive · disabled in the PDF
Which of these has an elementary antiderivative?
Which of these has an elementary antiderivative?
How computers decide. Liouville's theorem (1830s) gives a test for when an elementary antiderivative exists, and the Risch algorithm (1969) turns it into a procedure: computer algebra systems use versions of it to either find the antiderivative or prove there is none.
Calculus133 / 237
Module 11 · Substitution and integration by parts
Practice problems
ProblemInteractive · disabled in the PDF
Evaluate : factor the bottom, split the fraction into , and integrate.
ProblemInteractive · disabled in the PDF
Evaluate .
ProblemInteractive · disabled in the PDF
Find the function with for and .
ProblemInteractive · disabled in the PDF
Water flows into a tank at litres per minute, minutes after a tap is opened. How much water flows in during the first 4 minutes? Give it exactly or to 3 significant figures.
L
Calculus134 / 237
Module 11 · Substitution and integration by parts
Recap
Integration means recognising a derivative rule and running it backwards; check every answer by differentiating.
Substitution undoes the chain rule: , . In a definite integral, change the limits too.
By parts undoes the product rule: . Choose to get simpler when differentiated.
Even powers of and : halve the angle. Odd powers: split one off and substitute.
Partial fractions split a rational function into logs (and arctangents); cover-up finds the numerators.
Some integrals, like , have no elementary formula: name them, or compute them numerically.
FlashcardsInteractive · disabled in the PDF
Antiderivative of
A function with ; all of them are .
Substitution
with .
Integration by parts
.
LIATE
The order for choosing : logs, inverse trig, algebraic, trig, exponential.
, which integrates to .
Cover-up
For : cover in the fraction and set .
Elementary function
Built from powers, roots, exp, log and trig. Not every integral is one.
Module 12: Areas, volumes and averages
Calculus135 / 237
Module 12 · Areas, volumes and averages
Slice it thin, then add the slices
Every application in this module follows one pattern. Cut the thing you want (an area, a volume, a length, an amount of work) into thin slices of width . Find the size of one slice, which is approximately simple because the slice is thin. Add up all the slices: in the limit, that sum is an integral.
Slice
A thin piece of width : a strip, a disk, a shell, a short bit of curve.
Element
The size of one slice written with , such as .
Solid of revolution
The solid swept out when a flat region spins around an axis.
Calculus136 / 237
Module 12 · Areas, volumes and averages
The area between two curves is top minus bottom
A vertical strip between a top curve and a bottom curve has height and width . Add the strips from where the curves meet at the left to where they meet at the right. The -axis does not matter: only which curve is on top.
Top: y = x
Bottom: y = x²
Strip height x − x²0.24
Drag the strip across the region: its height is top minus bottom, largest at . Adding all the strips gives .
QuizInteractive · disabled in the PDF
What is the area between and the -axis?
What is the area between and the -axis?
ProblemInteractive · disabled in the PDF
Find the area of the region between the parabola and the line . First find where they meet.
Calculus137 / 237
Module 12 · Areas, volumes and averages
When the curves cross, split the integral
An integral of counts area as negative wherever is on top. If the curves swap places, the positive and negative parts can cancel. For an area, find where they cross and integrate top minus bottom on each piece, or integrate .
cos x
sin x
On , is on top until , then is. The two pieces have equal area.
QuizInteractive · disabled in the PDF
What is , without splitting?
What is , without splitting?
Going deeper
Sometimes horizontal strips are easier. For the region between and , the right curve minus the left curve, integrated in from to , gives , in one piece. In the bottom boundary changes formula at (from to ), and you would need two integrals.
Calculus138 / 237
Module 12 · Areas, volumes and averages
Volumes by slicing: disks
If you know the area of every cross-section of a solid, its volume is : a stack of thin slabs, each of volume . Spin the region under around the -axis and each slab is a disk of radius .
The formula for the volume of a sphere, which you may have memorised, is one integral.
y = √x
Its mirror, as it spins
Disk area π·c6.283
Spin around the -axis: a bowl. The disk at has radius and area .
QuizInteractive · disabled in the PDF
What is the volume of that bowl, for , spun around the -axis?
What is the volume of that bowl, for , spun around the -axis?
ProblemInteractive · disabled in the PDF
The arch of , for , spins around the -axis. Find the volume of the solid it sweeps out.
Calculus139 / 237
Module 12 · Areas, volumes and averages
Washers have a hole in the middle
Spin the region between two curves and each slice is a washer: a disk of outer radius with a hole of inner radius . Its area is the big disk minus the hole.
QuizInteractive · disabled in the PDF
Which integral gives the volume when the region between and , for , spins around the -axis?
Which integral gives the volume when the region between and , for , spins around the -axis?
Calculus140 / 237
Module 12 · Areas, volumes and averages
Shells: slicing parallel to the axis
Spinning around the -axis, take vertical strips instead. Each strip at distance from the axis sweeps out a thin cylindrical shell: unrolled, it is a rectangle of length (the circumference), height and thickness .
Check with disks in : , so . Two methods, one volume.
QuizInteractive · disabled in the PDF
The region under for spins around the -axis. What is its volume, by shells?
The region under for spins around the -axis. What is its volume, by shells?
Calculus141 / 237
Module 12 · Areas, volumes and averages
The average value of a function
The average of numbers is their sum divided by . The average of a function over is the continuous version: its integral divided by the length of the interval. It is the height of the rectangle with the same base and the same area as the region under the curve.
sin x
Average, 2/π
The dashed rectangle of height has the same area, 2, as the arch of . The mean value theorem for integrals says a continuous actually reaches its average somewhere.
QuizInteractive · disabled in the PDF
What is the average value of on ?
What is the average value of on ?
Code challengeInteractive · disabled in the PDF
Write average(f, a, b, n): the average value of f on [a, b], from a Riemann sum with n equal strips, each measured at its midpoint.
Over a short step , a curve rises by about , so the piece of curve is the hypotenuse of a tiny right triangle. By Pythagoras its length is . Factor out and add up the pieces.
Note. The square root makes arc length integrals hard: most have no elementary antiderivative. Even the length of a parabola needs a logarithm, and an ellipse needs a new kind of function (elliptic integrals). In practice you compute them numerically, as the challenge does.
Code challengeInteractive · disabled in the PDF
Write arcLength(f, a, b, n): split [a, b] into n equal steps and add the straight-line distances between consecutive points on the curve (use std::hypot(dx, dy), from <cmath>, which is ).
C++
1#include<cmath>2#include<functional>34doublearcLength(std::function<double(double)> f,5double a,double b,int n){6return b - a;7}
Calculus143 / 237
Module 12 · Areas, volumes and averages
Work done by a varying force
Work is force times distance, measured in joules (J): one newton (N) pushing through one metre. When the force changes along the way, each short step takes work , and the total is the integral. A spring is the classic case: Hooke's law says stretching it by metres takes a force , where is the spring constant in N/m.
F = 400x (k = 400 N/m)
Work ½kd² (J)8
The work is the area under the force: a triangle, so . Doubling the stretch quadruples the work.
QuizInteractive · disabled in the PDF
A spring with N/m is stretched from m to m. How much work does that take?
A spring with N/m is stretched from m to m. How much work does that take?
Calculus144 / 237
Module 12 · Areas, volumes and averages
A preview: probability as area
A probability density describes a random quantity that can take any value, like a waiting time. It is never negative and its total area is 1. The probability of landing between and is the area under there, and the mean is the average of weighted by .
p(x) = λe^(−λx)
P(X ≤ b)0.8647
The exponential density , for waiting times. The readout is the area up to : . A bigger rate means shorter waits.
QuizInteractive · disabled in the PDF
For the density on , what is ?
For the density on , what is ?
Calculus145 / 237
Module 12 · Areas, volumes and averages
Practice problems
ProblemInteractive · disabled in the PDF
The region between and spins around the -axis. Find the volume of the solid.
ProblemInteractive · disabled in the PDF
The region under and above the -axis spins around the -axis. Find its volume by shells.
ProblemInteractive · disabled in the PDF
Over a 12-hour day the temperature is degrees Celsius, hours after 6 am. What is the average temperature from to ?
°C
Calculus146 / 237
Module 12 · Areas, volumes and averages
More practice problems
ProblemInteractive · disabled in the PDF
Find the length of the curve from to .
ProblemInteractive · disabled in the PDF
A force of holds a spring stretched beyond its natural length. Find its spring constant, and the work needed to stretch it from to beyond its natural length.
N/m
J
ProblemInteractive · disabled in the PDF
A random quantity has density on , and 0 elsewhere. Find , the probability , and the mean .
Calculus147 / 237
Module 12 · Areas, volumes and averages
Recap
Slice, find one slice, add: every application is an integral of an element like , or .
Area between curves: , split wherever they cross.
Disks , washers , shells .
Average value: .
Arc length: , usually computed numerically.
Work: ; for a spring . Probability: area under a density.
FlashcardsInteractive · disabled in the PDF
Area between curves
with on top.
Disk method
, spinning around the -axis.
Washer method
.
Shell method
, spinning around the -axis.
Average value
.
Arc length
.
Hooke's law
; the work to stretch by is .
Module 13: Numerical integration
Calculus148 / 237
Module 13 · Numerical integration
Computers integrate by sampling
Many integrals have no formula (), and many functions are not formulas at all: a speed logged once a second, a sensor reading, the output of another program. A computer integrates by sampling: it evaluates at some points and adds the values with weights. Every method in this module is a choice of points and weights.
is the step: the width of each piece when is cut into equal parts.
Quadrature
The old name for computing an area numerically; a quadrature rule is a choice of points and weights.
Step $h$
The width of one piece, .
Error
The approximation minus the true value. Its sign says whether the rule overshoots.
Order
How fast the error shrinks: order means the error is roughly proportional to .
QuizInteractive · disabled in the PDF
When do you need to integrate numerically? Choose every one.
When do you need to integrate numerically? Choose every one.
Calculus149 / 237
Module 13 · Numerical integration
The trapezoid rule joins the samples with straight lines
Join neighbouring samples with straight lines and add the areas of the trapezoids underneath. Each trapezoid has area . Inside points belong to two trapezoids, so they count fully; the two end points count half.
f(x) = sin x + 1
The straight pieces
Error bound 2.25/n²0.25
Drag : the straight pieces hug more closely. The error bound shrinks like : double , quarter the error.
Code challengeInteractive · disabled in the PDF
Write trapezoid(f, a, b, n): the trapezoid rule with n equal pieces.
Use the trapezoid rule with to estimate , and find its error: the estimate minus the exact value, 4.
Calculus150 / 237
Module 13 · Numerical integration
The midpoint rule samples the middle of each piece
Instead of the ends, sample each piece at its centre and use a rectangle of that height. It sounds cruder than a trapezoid, but it is about twice as accurate, and its error has the opposite sign: where the trapezoid overshoots, the midpoint rule undershoots by about half as much.
Fill the blanksInteractive · disabled in the PDF
Complete the midpoint rule.
C++
1doublemidpoint(std::function<double(double)> f,2double a,double b,int n){3double h =(b - a)/;4double sum =0;5for(int i =0; i < n; i++){6 sum +=f(a +(i +)* h);7}8return sum *;9}
QuizInteractive · disabled in the PDF
For some integral, is too big. About what would you expect to be off by?
For some integral, is too big. About what would you expect to be off by?
ProblemInteractive · disabled in the PDF
Now use the midpoint rule with on the same integral, . What is , and what is its error?
Calculus151 / 237
Module 13 · Numerical integration
Simpson's rule fits parabolas
Since the midpoint error is about of the trapezoid's, the blend cancels the leading error. Done on pairs of pieces, the same blend is Simpson's rule: it fits a parabola through each three consecutive samples and integrates the parabolas exactly. must be even, and the weights go .
Only three samples, and already within 5%. A surprise: Simpson is exact not only for parabolas but for cubics too, because the cubic part of the error cancels by symmetry.
Find the bugInteractive · disabled in the PDF
This Simpson's rule gives wrong answers even for . Which line is wrong?
C++
Code challengeInteractive · disabled in the PDF
Write simpson(f, a, b, n): Simpson's rule with n pieces. It returns a std::optional<double>: the estimate, or std::nullopt (no answer) when n is odd.
Estimate , which is exactly 2, with (so ): by the trapezoid rule, and by Simpson's rule. Give exactly or to 4 decimal places.
Calculus152 / 237
Module 13 · Numerical integration
Error and order: what halving the step buys
For a smooth , the error of each rule is a constant times a power of . That power, the order, is what matters: halving divides the error by . The trapezoid and midpoint rules are order 2, Simpson is order 4. The table shows both errors for .
Each error is the approximation minus the true value, and each is some point in . Bounding or there turns these into guarantees.
n
Trapezoid error
Simpson error
2
4
8
16
Correct digits for with , by rule. Each doubling of adds about digits to the trapezoid and to Simpson.
QuizInteractive · disabled in the PDF
Simpson's rule with has an error of . About what is the error with ?
Simpson's rule with has an error of . About what is the error with ?
Going deeper
Richardson extrapolation turns a known order into extra accuracy. Since , the combination cancels the term, and it is exactly . Repeating the trick on Simpson gives Romberg integration. Order is only promised for smooth : a kink or a at an end slows every rule down.
Calculus153 / 237
Module 13 · Numerical integration
Watch the errors shrink
Run this to see order in action. Each row doubles ; the ratio column is how much the error shrank. Try other functions: on breaks the pattern, because its derivatives blow up at 0.
PlaygroundInteractive · disabled in the PDF
C++
1#include<cmath>2#include<functional>3#include<iostream>45usingFn= std::function<double(double)>;6doubletrapezoid(Fn f,double a,double b,int n){7double h =(b - a)/ n, sum =(f(a)+f(b))/2;8for(int i =1; i < n; i++) sum +=f(a + i * h);9return sum * h;10}11doublesimpson(Fn f,double a,double b,int n){12double h =(b - a)/ n, sum =f(a)+f(b);13for(int i =1; i < n; i++) sum +=(i %2?4:2)*f(a + i * h);14return sum * h /3;15}1617intmain(){18Fn f =[](double x){return std::exp(x);};19double exact = std::exp(1.0)-1, lastT =0, lastS =0;20for(int n =2; n <=64; n *=2){21double errT = std::abs(trapezoid(f,0,1, n)- exact);22double errS = std::abs(simpson(f,0,1, n)- exact);23 std::cout << n <<" "<< errT <<" "<< errS <<" ratios "24<< lastT / errT <<" "<< lastS / errS <<"\n";25 lastT = errT;26 lastS = errS;27}28}
The ratios settle near 4 and 16. Push into the thousands and Simpson stops improving near : that is the rounding of floating-point numbers, not the rule.
Calculus154 / 237
Module 13 · Numerical integration
Adaptive methods spend samples where they are needed
Equal steps waste effort: a function that is flat almost everywhere but has one sharp bump needs small steps only near the bump. An adaptive method estimates its own error on each piece and splits only the pieces that are not yet good enough. Comparing Simpson on a piece with Simpson on its two halves gives the estimate: their difference is about 15 times the error of the halves.
PlaygroundInteractive · disabled in the PDF
C++
1#include<cmath>2#include<functional>3#include<iostream>45usingFn= std::function<double(double)>;6int calls =0;7doublef(double x){ calls++;return std::sqrt(x);}89doublesimpson1(Fn f,double a,double b){10double m =(a + b)/2;11return(b - a)/6*(f(a)+4*f(m)+f(b));12}1314doubleadaptive(Fn f,double a,double b,double tol){15double m =(a + b)/2;16double whole =simpson1(f, a, b);17double halves =simpson1(f, a, m)+simpson1(f, m, b);18if(std::abs(halves - whole)<15* tol){19return halves +(halves - whole)/15;20}21returnadaptive(f, a, m, tol /2)+adaptive(f, m, b, tol /2);22}2324intmain(){25double value =adaptive(f,0,1,1e-8);26 std::cout << value <<" error "<< std::abs(value -2.0/3)27<<" calls "<< calls <<"\n";28}
It splits again and again near 0, where is steep, and hardly at all near 1. Change the tolerance and watch the number of calls.
QuizInteractive · disabled in the PDF
Why does adaptive Simpson split the pieces near 0 more often for on ?
Why does adaptive Simpson split the pieces near 0 more often for on ?
Going deeper
Gaussian quadrature goes further: instead of equal steps it chooses both the points and the weights to be optimal. With cleverly placed points it is exact for every polynomial of degree up to , twice what equal spacing achieves, and it is the core of most adaptive library routines.
Calculus155 / 237
Module 13 · Numerical integration
Monte Carlo: integrate by random sampling
Pick random points uniformly in and average there. By the definition of average value, times that average estimates the integral. The error shrinks only like , far slower than Simpson, but it does not depend on the dimension. For an integral over 100 variables, where any grid would need more points than there are atoms, random sampling still works.
are independent uniform random points; measures how much varies.
PlaygroundInteractive · disabled in the PDF
C++
1#include<cmath>2#include<iostream>3#include<numbers>4#include<random>56std::mt19937gen(42); // random numbers, from a fixed seed7std::uniform_real_distribution<double>uniform(0.0,1.0);89// pi is 4 times the area of a quarter of the unit circle.10doubleestimatePi(int samples){11int inside =0;12for(int i =0; i < samples; i++){13double x =uniform(gen);14double y =uniform(gen);15if(x * x + y * y <1) inside++;16}17return4.0* inside / samples; // 4.0: int / int drops the fraction18}1920intmain(){21for(int n : {100,10'000,1'000'000}){22double value =estimatePi(n);23 std::cout << n <<" "<< value <<" error "24<< std::abs(value - std::numbers::pi)<<"\n";25}26}
Change the seed, 42, and run it again: the answers change, and each 100 times more samples gives about one more digit.
QuizInteractive · disabled in the PDF
A Monte Carlo estimate with samples has an error of about . How many samples for ?
A Monte Carlo estimate with samples has an error of about . How many samples for ?
Calculus156 / 237
Module 13 · Numerical integration
Practice problems
ProblemInteractive · disabled in the PDF
For one smooth integral, has an error of . For another, (Simpson's rule) has an error of . Estimate the error of for the first, and of for the second.
ProblemInteractive · disabled in the PDF
How many trapezoids guarantee that is within of ? Use the bound , with on , and give the smallest whole .
ProblemInteractive · disabled in the PDF
A car starts from rest, and its speed is logged every 10 seconds: m/s at s. Estimate how far it travels in those 40 seconds, by the trapezoid rule and by Simpson's rule.
m
m
ProblemInteractive · disabled in the PDF
A Monte Carlo estimate with random samples has an error of about . About how many samples bring the error down to ?
Calculus157 / 237
Module 13 · Numerical integration
Recap
Numerical integration samples and adds weighted values: .
Trapezoid: straight lines, ends weighted . Midpoint: centres of each piece. Both are order 2.
Simpson: parabolas, weights times , even. Order 4, exact for cubics.
Order : halving divides the error by . Check it by measuring.
Adaptive methods split only where their error estimate is large.
Monte Carlo: error in any dimension.
FlashcardsInteractive · disabled in the PDF
Trapezoid rule
; error .
Midpoint rule
; about half the trapezoid error, opposite sign.
Simpson's rule
; error .
Order of a method
The power in error .
Adaptive quadrature
Split a piece only if its error estimate is too big.
Monte Carlo error
About , whatever the dimension.
Module 14: Infinity: L'Hôpital and improper integrals
Calculus158 / 237
Module 14 · Infinity: L'Hôpital and improper integrals
Some limits cannot be read off
Plugging in works for most limits. But when the top and the bottom of a fraction both go to 0, the answer depends on how fast each one does. , and are all "" at , yet their limits are , and no limit at all. A form like this is called indeterminate: its shape alone does not tell you the answer.
Form
Example
Limit
, ,
QuizInteractive · disabled in the PDF
Which of these forms is not indeterminate?
Which of these forms is not indeterminate?
Calculus159 / 237
Module 14 · Infinity: L'Hôpital and improper integrals
L'Hôpital's rule compares the speeds
Near the point, top and bottom are close to their tangent lines, so their ratio is close to the ratio of their slopes. L'Hôpital's rule: if and both go to 0 (or both to ), and the limit of exists, then the limit of is the same. Differentiate the top and the bottom separately; this is not the quotient rule.
You may apply the rule again as long as the form is still indeterminate.
(eˣ − 1 − x)/x²
The limit, ½
The function has no value at , but it heads to from both sides.
QuizInteractive · disabled in the PDF
What is ?
What is ?
QuizInteractive · disabled in the PDF
Someone computes with L'Hôpital: . What is the real limit?
Someone computes with L'Hôpital: . What is the real limit?
ProblemInteractive · disabled in the PDF
Find .
Calculus160 / 237
Module 14 · Infinity: L'Hôpital and improper integrals
Rewrite the other forms as a fraction
L'Hôpital only takes fractions, so turn the other forms into one. For , move one factor into the denominator. For powers like or , take the logarithm first: means , which is a product, and at the end .
This is where comes from in compound interest.
QuizInteractive · disabled in the PDF
What is ?
What is ?
ProblemInteractive · disabled in the PDF
Find .
Calculus161 / 237
Module 14 · Infinity: L'Hôpital and improper integrals
Logs are slow, powers are steady, exponentials win
As , every logarithm grows more slowly than every positive power, and every power more slowly than every exponential with base above 1. L'Hôpital proves it: needs applications, each one lowering the power, until it is .
10
2.3
3.2
100
100
4.6
10
1000
6.9
31.6
xᵖ/eˣ, scaled so its peak is 1
Even loses: rises to a peak at , then falls to 0. Drag and the peak moves, but it always comes down.
QuizInteractive · disabled in the PDF
What is ?
What is ?
Calculus162 / 237
Module 14 · Infinity: L'Hôpital and improper integrals
An integral over an infinite interval is a limit
You cannot add strips all the way to infinity directly. Instead, integrate up to a finite and let grow. If the limit is a finite number, the improper integralconverges to it; otherwise it diverges.
1/x
1/x²
Area under 1/x², 1 to R0.8333
Area under 1/x, 1 to R1.7918
Drag far to the right. The area under creeps up to 1 and stops; the area under keeps growing, slowly but forever. The curves look alike; the areas do not.
QuizInteractive · disabled in the PDF
What is ?
What is ?
ProblemInteractive · disabled in the PDF
Evaluate .
Calculus163 / 237
Module 14 · Infinity: L'Hôpital and improper integrals
The p-integrals: the yardstick for convergence
The family is the standard to compare everything else with. Out to infinity, it must fall faster than ; near 0, it must blow up more slowly than . fails both ways.
Code challengeInteractive · disabled in the PDF
Write pIntegral(p): the value of the integral of from 1 to infinity, or INFINITY (from <cmath>) when it diverges.
Module 14 · Infinity: L'Hôpital and improper integrals
Integrands that blow up are improper too
If goes to infinity at a point of the interval, stop a little short of it, at , and let shrink. An infinitely tall spike can still have a finite area, if it is thin enough.
1/√x
Area from ε to 11.3675
Slide toward 0: the shaded area approaches 2, though the curve goes up forever.
QuizInteractive · disabled in the PDF
Someone writes . What is wrong?
Someone writes . What is wrong?
ProblemInteractive · disabled in the PDF
Evaluate . The integrand goes to at .
Calculus165 / 237
Module 14 · Infinity: L'Hôpital and improper integrals
Compare with something you know
Often you only need to know whether an improper integral converges. If , the area under is at most the area under . So: if converges, so does ; if diverges, so does . A smaller function proves nothing about a bigger one, and vice versa.
QuizInteractive · disabled in the PDF
Which of these converge? Choose every one.
Which of these converge? Choose every one.
Code challengeInteractive · disabled in the PDF
Write improper(f, a, n): approximate the integral of f from a to infinity by substituting , which maps t in [0, 1) onto [a, ∞), then using the midpoint rule with n pieces on .
Module 14 · Infinity: L'Hôpital and improper integrals
Gabriel's horn: finite volume, infinite surface
Spin , for , around the -axis. The horn goes on forever. Its volume, by disks, is . Its surface area is at least , which diverges. So it holds a finite amount of paint but you could never paint its inside wall. The paradox fades once you remember that real paint has a thickness: far enough out, the horn is thinner than any coat of paint.
y = 1/x
Its mirror
The horn, in cross-section. It narrows fast enough to have finite volume, but not finite area.Comparison again: the surface integrand is bigger than one that already diverges.
QuizInteractive · disabled in the PDF
Why is the horn's volume finite while its surface is not?
Why is the horn's volume finite while its surface is not?
Calculus167 / 237
Module 14 · Infinity: L'Hôpital and improper integrals
Practice problems
ProblemInteractive · disabled in the PDF
Evaluate .
ProblemInteractive · disabled in the PDF
A drug is absorbed into the blood at a rate of milligrams per hour, hours after a dose. How much is absorbed in the first 5 hours, and how much in total, if absorption goes on forever?
mg
mg
ProblemInteractive · disabled in the PDF
The region under , for , spins around the -axis: a solid that goes on forever. Find its volume.
Calculus168 / 237
Module 14 · Infinity: L'Hôpital and improper integrals
Recap
Indeterminate forms (, , , , , , ) need work, not plugging in.
L'Hôpital: for or , . Check the form first.
Other forms: rewrite as a fraction, or take logs for powers.
Growth: .
Improper integrals are limits; converges exactly when , when .
Compare with a known integral to decide convergence; watch for blow-ups inside the interval.
FlashcardsInteractive · disabled in the PDF
Indeterminate form
A limit whose shape, like , does not determine its value.
L'Hôpital's rule
For or : , if the second exists.
Improper integral
An integral over an infinite interval, or of an unbounded function, defined as a limit.
Converges
The limit exists and is a finite number.
for ; diverges for .
Comparison test
: finite finite; infinite infinite.
Module 15: Sequences and series
Calculus169 / 237
Module 15 · Sequences and series
A sequence is a list that goes on forever
A sequence is an infinite list of numbers , usually given by a rule such as . It converges to a limit if its terms get and stay as close to as you like, from some point on; otherwise it diverges. Limits of sequences work like limits of functions as , so the tools you know (algebra, growth rates, L'Hôpital) apply.
Sequence
First terms
Limit
None: it diverges
The first ten terms of : increasing, and slowing down as they close in on .
QuizInteractive · disabled in the PDF
What is the limit of ?
What is the limit of ?
Calculus170 / 237
Module 15 · Sequences and series
A series is the limit of its partial sums
A series adds the terms of a sequence: . You cannot do infinitely many additions, so the sum is defined as a limit: add the first terms, the partial sum , and see what does as . If it has a limit, the series converges to it.
A telescoping series: after partial fractions, each term cancels part of the next, and only the ends survive.Partial sums of : each one closes half the remaining gap to 1.
QuizInteractive · disabled in the PDF
A series has partial sums . What is its sum, and what is its first term?
A series has partial sums . What is its sum, and what is its first term?
ProblemInteractive · disabled in the PDF
Using , find the partial sum of , and the sum of the series.
Calculus171 / 237
Module 15 · Sequences and series
Geometric series: the one you can always sum
In a geometric series each term is the previous one times a fixed ratio . Its partial sums have a closed form, found by a trick: multiply by and subtract, and almost everything cancels.
If the terms do not shrink, and the series diverges.
S_N
Limit 1/(1 − r)
1/(1 − r)3.333
The partial sums of as steps, with the limit dashed. Drag toward 1: convergence slows; past 1 the steps climb forever.
QuizInteractive · disabled in the PDF
What is ?
What is ?
ProblemInteractive · disabled in the PDF
Find . Then write the repeating decimal as a fraction, by treating it as a geometric series.
Going deeper
is the geometric series with and , whose sum is . It is not "a little less than 1": an infinite decimal means the limit of its partial sums, and that limit is exactly 1.
Calculus172 / 237
Module 15 · Sequences and series
If the terms do not shrink to zero, the series diverges
Since , a convergent series must have . So if the terms do not go to 0, the series diverges: the divergence test. The converse is false, and this is the most important warning in the module: terms going to 0 does not mean the series converges.
The harmonic series : its terms go to 0, but grouping them shows it beats any number of halves. Its partial sums grow like .
QuizInteractive · disabled in the PDF
What does the divergence test say about and about ?
What does the divergence test say about and about ?
Calculus173 / 237
Module 15 · Sequences and series
The integral test, and the p-series
When the terms come from a positive, decreasing function, , a sum and an integral bound each other: the rectangles of height and width 1 sit just above the curve. So and either both converge or both diverge. Applied to , it gives the p-series test, the yardstick for series.
Terms 1/nᵖ as rectangles
1/xᵖ
Rectangles of height (the terms) over the curve . All the rectangles together hold more than the area under the curve from 1 on; leave out the first, slide the rest one step left, and they fit under it. So both are finite or both infinite. Drag across 1.
QuizInteractive · disabled in the PDF
Which of these converge? Choose every one.
Which of these converge? Choose every one.
Code challengeInteractive · disabled in the PDF
Write partialSum(term, N): the sum of term(n) for n from 1 to N. term takes n as a double, so a term like 1 / n divides with decimals.
For positive terms, the comparison idea from improper integrals carries over. Direct comparison: if and converges, so does ; if diverges, so does . Limit comparison is easier to use: if with , the two series do the same thing.
QuizInteractive · disabled in the PDF
Using limit comparison, what does do?
Using limit comparison, what does do?
Calculus175 / 237
Module 15 · Sequences and series
Ratio and root tests: is it eventually geometric?
If the ratio of consecutive terms settles to a number , the series eventually behaves like a geometric one with ratio . That gives the ratio test. The root test asks the same with . Both are made for factorials and powers ; both say nothing when .
QuizInteractive · disabled in the PDF
What does the ratio test say about ?
What does the ratio test say about ?
Calculus176 / 237
Module 15 · Sequences and series
Alternating series converge if the terms shrink
When the signs alternate, the partial sums zig-zag: up, down, up, each swing smaller than the last. If the sizes decrease to 0, the zig-zag closes in on a limit (the alternating series test). Better still, the error of stopping after terms is at most the first term left out.
Partial sums of , swinging around .
Code challengeInteractive · disabled in the PDF
Write alternating(N): it returns an Estimate holding sum, the partial sum of 1 - 1/2 + 1/3 - ... up to the term , and bound, the most it can be off by, .
How many terms of does the alternating series bound say you need, for an error below ?
Calculus177 / 237
Module 15 · Sequences and series
Absolute and conditional convergence
A series converges absolutely if converges; then converges too, whatever the signs. It converges conditionally if converges but does not: it relies on its signs cancelling. is conditional, since without the signs it is the harmonic series.
Rearranging changes the sum.Riemann's rearrangement theorem: the terms of a conditionally convergent series can be reordered to add up to any number you choose, or to diverge. Take positive terms until you pass your target, then negative ones until you drop below it, and repeat. Absolutely convergent series are safe: every order gives the same sum. So infinite sums are not ordinary addition, and order matters exactly when convergence is conditional.
QuizInteractive · disabled in the PDF
Classify and .
Classify and .
Put in orderInteractive · disabled in the PDF
Put these in a sensible order to try on a series you do not recognise.
1.Is it geometric, telescoping or a -series?
2.Alternating series test, if the signs alternate
3.Divergence test: do the terms go to 0?
4.Compare with one of those (direct or limit comparison)
5.Ratio or root test, for factorials and powers
Calculus178 / 237
Module 15 · Sequences and series
Practice problems
ProblemInteractive · disabled in the PDF
Find the limit of the ratio test for , and for .
ProblemInteractive · disabled in the PDF
A ball is dropped from a height of 2 m. Each bounce takes it back up to of the height it last fell from. If it bounces forever, what total distance does it travel, up and down?
m
ProblemInteractive · disabled in the PDF
To test , compare it with . What is , with and ?
ProblemInteractive · disabled in the PDF
Find .
Calculus179 / 237
Module 15 · Sequences and series
Recap
A series is the limit of its partial sums .
Geometric: for .
Terms not going to 0 means divergence; terms going to 0 proves nothing (harmonic series).
converges exactly when (integral test).
Comparison and limit comparison against known series; ratio and root tests for factorials and powers, silent at .
Alternating with shrinking terms converges, with error at most the next term. Absolute convergence is the robust kind.
FlashcardsInteractive · disabled in the PDF
Partial sum
; the series is .
Geometric series
when .
Harmonic series
: terms go to 0, yet it diverges, like .
p-series
converges if and only if .
Ratio test
: converges, diverges, unknown.
Alternating series error
At most the first term left out.
Conditional convergence
Converges, but not absolutely; rearranging can change the sum.
Module 16: Taylor series
Calculus180 / 237
Module 16 · Taylor series
A power series is a polynomial that never ends
A power series centred at is . For each it is a series of numbers, which may converge or not; where it converges, it defines a function. The geometric series is the first example: for , .
1/(1 − x)
1 + x + … + x^N
The partial sum (accent) against . Raise : inside the polynomial hugs the curve; outside, it flies away however many terms you take.
QuizInteractive · disabled in the PDF
For which does converge, and to what?
For which does converge, and to what?
Calculus181 / 237
Module 16 · Taylor series
Every power series has a radius of convergence
A power series always converges on an interval centred at : absolutely for and not at all for . is the radius of convergence, and it can be or . The ratio test usually finds it. At the two endpoints anything can happen, so test them separately; the result is the interval of convergence.
Series
Radius
Interval
Every
Only
QuizInteractive · disabled in the PDF
What is the interval of convergence of ?
What is the interval of convergence of ?
Calculus182 / 237
Module 16 · Taylor series
Taylor series: match every derivative
Which power series equals a given function near ? If , differentiate times and put : every term vanishes except one, and it gives . So the coefficients are forced. The tangent line from earlier is the first two terms; the Taylor series keeps going, matching the curvature and every higher derivative too.
Centred at it is called a Maclaurin series. Cut off after degree , it is the Taylor polynomial .
QuizInteractive · disabled in the PDF
In the Maclaurin series of , the coefficient of is . What is ?
In the Maclaurin series of , the coefficient of is . What is ?
ProblemInteractive · disabled in the PDF
Find the Taylor polynomial of centred at , and use it to estimate to 4 decimal places.
Calculus183 / 237
Module 16 · Taylor series
Five series worth knowing by heart
sin x
Taylor polynomial of degree N
Taylor polynomials of at 0. Each extra term hugs the curve over a wider stretch; the series converges for every , but far out you need many terms.
QuizInteractive · disabled in the PDF
Differentiate the series for term by term. What do you get?
Differentiate the series for term by term. What do you get?
Calculus184 / 237
Module 16 · Taylor series
Build new series from old ones
You rarely compute derivatives to get a series. Instead, substitute into a known one, multiply by a power of , differentiate or integrate term by term. This also integrates functions with no elementary antiderivative, like from module 11.
An alternating series: five terms already give an error below , the next term.
QuizInteractive · disabled in the PDF
Start from , whose integral is . What is the Maclaurin series of ?
Start from , whose integral is . What is the Maclaurin series of ?
Code challengeInteractive · disabled in the PDF
Write expSeries(x, N): the Taylor polynomial of at 0 up to the term . Build each term from the one before (multiply by x / n) instead of computing powers and factorials.
C++
1doubleexpSeries(double x,int N){2return1;3}
ProblemInteractive · disabled in the PDF
Substitute into the series for to get the Maclaurin series of . What is the coefficient of , and what is ?
Calculus185 / 237
Module 16 · Taylor series
Taylor's remainder: how much to trust a polynomial
Stopping at degree leaves an error, the remainder . Taylor's theorem gives it a form like the next term, with the derivative taken at some unknown point between and . You do not know , but bounding the derivative between and bounds the error.
The true error of as an estimate of : each extra term divides it by roughly .
QuizInteractive · disabled in the PDF
On , every derivative of is at most . What is the smallest that guarantees by the bound ?
On , every derivative of is at most . What is the smallest that guarantees by the bound ?
ProblemInteractive · disabled in the PDF
Estimate with the Maclaurin polynomial (exactly, or to 4 decimal places), and bound its error with the remainder formula for , using .
Calculus186 / 237
Module 16 · Taylor series
How a calculator computes sin
A naive idea is to sum the sine series directly. For large it fails: at the terms reach about before they shrink, and adding and subtracting numbers that large wipes out every digit of an answer below 1. Real libraries first use the function's symmetries to reduce the argument: subtract a multiple of , then use identities to bring it within , where a polynomial of degree about 13 is accurate to every digit a double holds.
PlaygroundInteractive · disabled in the PDF
C++
1#include<cmath>2#include<iomanip>3#include<iostream>45doublenaiveSin(double x,int terms =80){6double term = x;7double sum = x;8for(int k =1; k < terms; k++){9 term *=(-x * x)/(2* k *(2* k +1));10 sum += term;11}12return sum;13}1415intmain(){16 std::cout << std::setprecision(16);17for(double x : {1,10,20,40}){18 std::cout << x <<" "<<naiveSin(x)<<" "<< std::sin(x)<<"\n";19}20}
Small agrees to every digit; by the answer is nonsense. Nothing is wrong with the maths: it is rounding, magnified by huge cancelling terms.
Code challengeInteractive · disabled in the PDF
The starter sums the series directly. Fix sinTaylor(x) by first reducing x to r = x - 2π · round(x / 2π), which lies in and has the same sine, and summing the series at r. std::round and std::numbers::pi will help.
C++
1#include<cmath>2#include<numbers>34doublesinTaylor(double x){5double term = x;6double sum = x;7for(int k =1; k <40; k++){8 term *=(-x * x)/(2* k *(2* k +1));9 sum += term;10}11return sum;12}
Calculus187 / 237
Module 16 · Taylor series
Euler's formula: e to an imaginary power
The series for makes sense for any number you can multiply, including the imaginary unit , with . Put in : the powers of cycle , and the series splits into exactly the series of and .
At : , linking , , , 1 and 0.
Unit circle
Real part cos θ0.54
Imaginary part sin θ0.841
drawn as the point : it walks round the unit circle as grows. Multiplying by is rotation by .
QuizInteractive · disabled in the PDF
What is ?
What is ?
ProblemInteractive · disabled in the PDF
Write as , with and real.
Calculus188 / 237
Module 16 · Taylor series
When a Taylor series lets you down
Two surprises for experts. First, a Taylor series can converge to the wrong function. Second, a function that is perfectly smooth on the whole real line can still have a series with a small radius.
Every derivative at 0 is 0, so the Taylor series is , which equals only at . Functions that do equal their Taylor series nearby are called analytic.
QuizInteractive · disabled in the PDF
is smooth for every real , yet its Maclaurin series only converges for . Why?
is smooth for every real , yet its Maclaurin series only converges for . Why?
Expert note. An asymptotic series may diverge for every and still be useful: its first few terms approximate the function very well, and adding more eventually makes things worse. Stirling's formula for is one, and so are many expansions in physics. Taylor series are the well-behaved special case.
Calculus189 / 237
Module 16 · Taylor series
Practice problems
ProblemInteractive · disabled in the PDF
Find the radius of convergence of . The series converges at exactly one of the two endpoints: which ?
ProblemInteractive · disabled in the PDF
Use the Maclaurin series of to find .
ProblemInteractive · disabled in the PDF
has no elementary antiderivative. Estimate to 5 decimal places from the first three nonzero terms of its Maclaurin series, and give the alternating series bound on the error.
Calculus190 / 237
Module 16 · Taylor series
Recap
A power series converges inside a radius ; check the endpoints separately.
Taylor coefficients are forced: .
Know , , , and , and build others by substituting, differentiating and integrating.
The remainder bounds the error of a Taylor polynomial.
Computers reduce the argument first, then use a short polynomial.
Euler's formula: .
FlashcardsInteractive · disabled in the PDF
Radius of convergence
The with convergence for and divergence for .
Taylor series of at
.
Maclaurin series
A Taylor series centred at 0.
, for every .
, for .
Lagrange remainder
for some between and .
Euler's formula
.
Module 17: Differential equations
Calculus191 / 237
Module 17 · Differential equations
An equation whose unknown is a function
Most laws of nature are about rates: how fast a population grows, how fast coffee cools, how a force changes velocity. A differential equation says how a function's derivative depends on the function itself (and on the time or position). A solution is a function that makes the equation true for every . Usually there is a whole family of them; an initial condition, such as the value at , picks one out.
Check: , and at it is .
Differential equation (DE)
An equation linking an unknown function and its derivatives.
Order
The highest derivative in it: is first order, second.
Initial value problem
A DE together with the starting value(s) that pick one solution.
General solution
The whole family, with a constant for each order: .
QuizInteractive · disabled in the PDF
Which function solves with ?
Which function solves with ?
Calculus192 / 237
Module 17 · Differential equations
A slope field shows every solution at once
A first-order equation tells you the slope of the solution through every point. Draw a short segment with that slope at each point of a grid: a slope field. A solution is a curve that follows the segments everywhere, like a leaf on a stream. You can see the behaviour of all solutions before solving anything.
y = x − 1 + Ce^(−x)
y = x − 1
The slope field of , with the solution . Drag : every solution follows the segments, and they all funnel into the line .
QuizInteractive · disabled in the PDF
For , along which line are the segments flat?
For , along which line are the segments flat?
Calculus193 / 237
Module 17 · Differential equations
Separable equations: split the variables and integrate
If the right side is a function of times a function of , put everything with on one side and everything with on the other, and integrate both. One constant of integration is enough. Watch for the solutions you divided away, such as .
QuizInteractive · disabled in the PDF
Solve with . What happens?
Solve with . What happens?
ProblemInteractive · disabled in the PDF
Solve with , for .
Calculus194 / 237
Module 17 · Differential equations
Exponential growth and decay
When the rate of change is proportional to the amount, , the solution is exponential. With it grows, doubling every ; with it decays, halving every , the half-life. Radioactive atoms, money at continuous interest and early epidemics all follow it.
y = e^(kt), y(0) = 1
Doubling time or half-life1.733
Drag across 0: growth turns into decay. The readout is the doubling time or half-life.Radiocarbon dating runs this backwards: measure the fraction left, solve for the time.
QuizInteractive · disabled in the PDF
A substance has a half-life of 8 days. What fraction is left after 24 days?
A substance has a half-life of 8 days. What fraction is left after 24 days?
ProblemInteractive · disabled in the PDF
A bacteria culture doubles every 3 hours, starting from 500 cells. How many cells are there after 10 hours, and when does the culture reach cells?
cells
h
Calculus195 / 237
Module 17 · Differential equations
Logistic growth levels off
Nothing grows exponentially forever. The logistic equation slows growth as a population approaches the carrying capacity , the most the environment supports. When is small it is nearly exponential; when is near the factor is near 0 and growth stops.
Solved by separation and partial fractions, from two modules on integration.
P(t)
K = 100
K/2
The S-shaped logistic curve with . Whatever the start, it settles at ; it rises fastest when it crosses . Start above and it falls to .
QuizInteractive · disabled in the PDF
At what population does a logistic population grow fastest?
At what population does a logistic population grow fastest?
Calculus196 / 237
Module 17 · Differential equations
Newton's law of cooling
An object cools at a rate proportional to how much hotter it is than its surroundings. With the surrounding temperature, the difference decays exponentially, so the temperature approaches ever more slowly.
QuizInteractive · disabled in the PDF
In that example, how long until the coffee reaches 50 °C?
In that example, how long until the coffee reaches 50 °C?
ProblemInteractive · disabled in the PDF
Soup at 85 °C is left in a room at 25 °C. After 10 minutes it is at 65 °C. Find the cooling constant , and the temperature after 30 minutes.
per minute
°C
Calculus197 / 237
Module 17 · Differential equations
Euler's method: follow the slope a step at a time
Most differential equations cannot be solved with formulas. Euler's method solves them numerically: from the current point, the equation gives the slope; walk a small step along it; repeat. It is the tangent-line approximation used over and over.
True solution eᵗ
Euler's steps
Error at t = 22.327
Euler's method for , (accent), against the true . Its steps lag behind the curving solution. Halve and the error at roughly halves: order 1.
Code challengeInteractive · disabled in the PDF
Write euler(f, t0, y0, h, steps): take steps Euler steps of size h for y' = f(t, y) from (t0, y0), and return the final y. f is a function of two numbers, a std::function<double(double, double)>.
The classic fourth-order Runge–Kutta method (RK4) takes four slopes per step (at the start, twice at the middle, at the end) and averages them with weights , like Simpson's rule. Its error is proportional to . Library solvers go further, choosing adaptively from an error estimate, as adaptive integration does.
Calculus198 / 237
Module 17 · Differential equations
Second order: a mass on a spring
Newton's second law, , is a second-order equation: acceleration is the second derivative of position. For a mass (kg) on a spring of constant (N/m), the force is , so . The solutions are oscillations with angular frequency (rad/s). Friction adds a force that damps them.
Two constants, and , because the equation is second order: they come from the starting position and the starting velocity. The damped formula is for light damping, .
x(t)
Envelope
Period 2π/ω_d (s)3.157
A damped spring with rad/s, starting at (, ). Drag the damping : the swings die away faster, and slow down slightly, inside the dashed envelope .
QuizInteractive · disabled in the PDF
A 0.5 kg mass hangs on a spring with N/m, no damping. What is its period?
A 0.5 kg mass hangs on a spring with N/m, no damping. What is its period?
Calculus199 / 237
Module 17 · Differential equations
Systems: several quantities changing together
Many problems have several unknowns that drive each other. Any higher-order equation becomes a first-order system too: for the spring, track position and velocity, and . Euler's method works the same way, stepping every quantity at once. The classic example is predators and prey (the Lotka–Volterra equations): rabbits grow, foxes eat them, foxes starve when rabbits are scarce.
PlaygroundInteractive · disabled in the PDF
C++
1#include<iomanip>2#include<iostream>34// Rabbits R and foxes F, stepped with Euler's method.5intmain(){6double a =1, b =0.1, c =1.5, d =0.075;7double R =10, F =5;8double h =0.001;910 std::cout << std::fixed << std::setprecision(1);11for(int step =0; step <=20000; step++){12if(step %1000==0){13 std::cout <<"t = "<< step * h <<": rabbits "<< R14<<", foxes "<< F <<"\n";15}16double dR = a * R - b * R * F;17double dF =-c * F + d * R * F;18 R += h * dR;19 F += h * dF;20}21}
The populations cycle: rabbits boom, then foxes, then rabbits crash, then foxes. Both derivatives are computed from the old values before either changes.
Code challengeInteractive · disabled in the PDF
The starter steps a spring (, ) with plain Euler, and its energy grows without limit. Change it to semi-implicit Euler: update v first, then update x using the newv. Return the State, x and v, after steps steps of size h.
C++
1structState{2double x;3double v;4};56Statespring(double x0,double h,int steps){7double x = x0;8double v =0;9for(int i =0; i < steps; i++){10double a =-x;11 x += h * v;12 v += h * a;13}14return{x, v};15}
Calculus200 / 237
Module 17 · Differential equations
Practice problems
ProblemInteractive · disabled in the PDF
Take two Euler steps of size for , , to estimate . The exact solution is : how big is Euler's error at ?
ProblemInteractive · disabled in the PDF
A population follows , with and in years. When does it reach 500, and what is its fastest rate of growth?
years
per year
ProblemInteractive · disabled in the PDF
A mass on a spring with , without damping, is pulled from its rest position and let go. Find its angular frequency, its period, and its greatest speed.
rad/s
s
m/s
ProblemInteractive · disabled in the PDF
A piece of charcoal has 20% of the carbon-14 that living wood has. Carbon-14 has a half-life of 5730 years. How old is the charcoal?
years
Calculus201 / 237
Module 17 · Differential equations
Recap
A differential equation relates a function to its derivatives; an initial condition picks one solution.
Slope fields show all solutions at once. Separable equations: split and integrate.
: exponential, doubling or halving every . Logistic growth levels off at .
Newton's cooling: decays exponentially.
Euler's method: , error proportional to .
Springs: oscillates with ; higher-order equations become first-order systems.
FlashcardsInteractive · disabled in the PDF
Initial value problem
A DE plus starting values, which together pick a single solution.
Slope field
Segments with slope at grid points; solutions follow them.
Half-life
for with .
Logistic equation
; fastest growth at .
Euler's method
.
Angular frequency of a spring
, period .
Semi-implicit Euler
Update velocity, then position with the new velocity: energy stays bounded.
Module 18: Functions of several variables
Calculus202 / 237
Module 18 · Functions of several variables
A function of two variables is a surface
Most quantities depend on more than one thing: the temperature on a map depends on where you are, ; the cost of a box depends on its length, width and height. A function of two variables gives a height above each point of the plane, so its graph is a surface. You cannot draw all of it on flat paper, but you can slice it: fix , and is an ordinary curve.
Slice at y = 0
z = x² + b²
Slices of the bowl along lines . Drag : each slice is a parabola, lifted by . Stacking all the slices builds the surface.
QuizInteractive · disabled in the PDF
For , what is ?
For , what is ?
Calculus203 / 237
Module 18 · Functions of several variables
Level curves: the contour map of a surface
Instead of slicing upright, slice horizontally: the points where form a level curve. Draw several, for evenly spaced , and you have a contour map, like the height lines on a hiking map. Where the curves crowd together, the surface is steep.
c = 1, 2, 3, 4
f = c
Level curves of for : circles of radius . Equal steps in height give circles closer and closer together: the bowl gets steeper as you go out.
QuizInteractive · disabled in the PDF
What do the level curves of look like?
What do the level curves of look like?
Calculus204 / 237
Module 18 · Functions of several variables
A partial derivative changes one variable at a time
The partial derivative (also written ) is the slope of the surface in the direction: differentiate with respect to , treating as a constant. It is the slope of the slice . does the same the other way.
Second partials: , and the mixed . For smooth , Clairaut's theorem says : the order does not matter.
Slice z = f(x, b)
Tangent, slope f_x
f_x(a, b) = 2ab2
The slice of at is . Its tangent at has slope . Drag both.
QuizInteractive · disabled in the PDF
For , what is ?
For , what is ?
ProblemInteractive · disabled in the PDF
Let . Find and , and the mixed partial at .
Calculus205 / 237
Module 18 · Functions of several variables
The gradient points straight uphill
Put the partial derivatives together into a vector: the gradient, (read "del f"). At each point it points in the direction in which increases fastest, its length is that fastest rate, and it is perpendicular to the level curve through the point.
f = 2
|∇f|3.481
Level curves of (ellipses) and at a point on the level , drawn a quarter of its length. Move the point: the gradient always crosses the curve at a right angle, and is longest where the curves are closest.
Code challengeInteractive · disabled in the PDF
Write gradient(f, x, y): the gradient at (x, y), as a std::pair{fx, fy}, each by a central difference with h = 1e-5.
Directional derivatives: the slope in any direction
Walking from a point in the direction of a unit vector (length 1), the rate at which changes is the directional derivative: the dot product of the gradient with . Since , it is largest when points along , zero along the level curve, and most negative straight downhill.
QuizInteractive · disabled in the PDF
For at , someone uses the direction as it is and gets . What went wrong?
For at , someone uses the direction as it is and gets . What went wrong?
ProblemInteractive · disabled in the PDF
Let . At the point , find the rate of change of in the direction towards the point , and the fastest rate of change there.
Calculus207 / 237
Module 18 · Functions of several variables
The tangent plane is the best flat approximation
Zoom in on a smooth surface and it looks flat: like the tangent line in one variable, there is a tangent plane. It uses both partial derivatives, and gives the linear approximation: the change in is about .
QuizInteractive · disabled in the PDF
A box's volume is . At , , (metres), about how much does change if grows by m and the rest stay fixed?
A box's volume is . At , , (metres), about how much does change if grows by m and the rest stay fixed?
ProblemInteractive · disabled in the PDF
Find the tangent plane to at , and use it to estimate .
Calculus208 / 237
Module 18 · Functions of several variables
Critical points: minima, maxima and saddles
At the top of a hill or the bottom of a valley the tangent plane is flat: . Such a point is critical. Unlike in one variable there is a third kind: a saddle, which curves up in one direction and down in another, like a mountain pass. The second derivative test tells them apart using .
At a critical point
It is
and
A local minimum
and
A local maximum
A saddle point
The test cannot tell
QuizInteractive · disabled in the PDF
Classify the critical point of at the origin.
Classify the critical point of at the origin.
Calculus209 / 237
Module 18 · Functions of several variables
Lagrange multipliers: the best point on a constraint
Often you must stay on a curve: the best rectangle with a fixed perimeter, the cheapest design with a fixed volume. To find the extreme values of on , walk along the constraint. At the best point the level curve of just touches the constraint, so their gradients are parallel.
is the Lagrange multiplier. It measures how much the best value would improve if were raised a little.
Constraint x + y = 10
xy = c
The constraint and the level curve . Raise : below 25 the curve crosses the line twice, above 25 it misses. At they touch, at .
QuizInteractive · disabled in the PDF
What is the largest value of on the circle ?
What is the largest value of on the circle ?
Calculus210 / 237
Module 18 · Functions of several variables
Gradient descent: walk downhill
Setting and solving is hopeless when has millions of variables, as when training a machine learning model. Gradient descent just walks downhill: take a small step against the gradient, recompute, repeat. The step size (the learning rate) matters: too small and it crawls, too big and it overshoots and diverges.
f(x) = x²
Factor per step 1 − 2η0.7
Gradient descent on from . Each step multiplies by . Drag : small steps creep down; near it jumps straight to the bottom; above it zig-zags; above 1 it climbs out.
Code challengeInteractive · disabled in the PDF
Write descend(grad, start, eta, steps): run gradient descent from start for steps steps, where grad({x, y}) returns the gradient as {gx, gy}, and return the final point. A point is a Vec, a std::pair<double, double>.
Find the critical point of , classify it with the second derivative test, and give the value of there.
ProblemInteractive · disabled in the PDF
A farmer has 400 m of fence for a rectangular field along a straight river; the side on the river needs no fence. With the two sides at right angles to the river and the side parallel to it, maximise the area subject to .
m
m
m²
ProblemInteractive · disabled in the PDF
Take two steps of gradient descent on from , with learning rate . Where are you after two steps?
Calculus212 / 237
Module 18 · Functions of several variables
Recap
is a surface; slices and level curves show it on paper.
Partial derivatives hold every other variable constant; .
The gradient points uphill fastest, has length equal to that rate, and is perpendicular to level curves.
for a unit vector .
Tangent plane: .
Critical points () are classified by ; on a constraint use ; for big problems, descend the gradient.
FlashcardsInteractive · disabled in the PDF
Level curve
The points where .
Partial derivative
The derivative in with every other variable held fixed.
Gradient
: steepest uphill direction, perpendicular to level curves.
Directional derivative
with .
Saddle point
A critical point that is a minimum one way and a maximum another; .
Lagrange condition
on .
Gradient descent
; is the learning rate.
Module 19: Multiple integrals and vector calculus
Calculus213 / 237
Module 19 · Multiple integrals and vector calculus
A double integral adds up over a region
A single integral adds over an interval. A double integral adds over a region of the plane, where is the area of a tiny rectangle. If is a height, it is the volume under the surface; if is a density (kg per m²), it is a mass. You compute it as an iterated integral: integrate in one variable with the other held fixed, then in the other.
Fubini's theorem: for a continuous on a rectangle, either order gives the same answer.
QuizInteractive · disabled in the PDF
What is ?
What is ?
ProblemInteractive · disabled in the PDF
Evaluate over the rectangle where and .
Calculus214 / 237
Module 19 · Multiple integrals and vector calculus
Over a curved region, the inner limits are functions
For a region between two curves, fix and let run from the bottom curve to the top one; then let run across. Or the other way: fix and run from the left curve to the right. Swapping the order changes the limits, never the answer, and sometimes turns an impossible integral into an easy one.
Top: y = x
Bottom: y = x²
The region between and . For each , the inner integral runs from up to .
QuizInteractive · disabled in the PDF
Written with inside instead, . What are the inner limits?
Written with inside instead, . What are the inner limits?
ProblemInteractive · disabled in the PDF
has no elementary antiderivative, so cannot be done in this order. Swap the order of integration and evaluate it exactly.
Calculus215 / 237
Module 19 · Multiple integrals and vector calculus
Triple integrals add up over a solid
The same idea one dimension up: adds times tiny volumes over a solid . With it is the volume; with a density in kg/m³, the mass. Three nested integrals, innermost limits depending on the outer variables.
QuizInteractive · disabled in the PDF
A unit cube has density kg/m³. What is its mass?
A unit cube has density kg/m³. What is its mass?
Calculus216 / 237
Module 19 · Multiple integrals and vector calculus
Polar coordinates: dA becomes r dr dθ
For discs, rings and anything round, describe points by distance and angle : , . A small step and sweeps a patch that is deep but wide, because arcs further out are longer. So the area element is , and forgetting the is the most common mistake in the subject.
Exact area (r + 0.15)·0.3·0.30.103
A polar patch with . Drag outwards: the patch widens, and its area, about , grows with .The second line is the famous trick: the integral of has no antiderivative, but its square is a double integral that polar coordinates make easy, thanks to the extra .
Code challengeInteractive · disabled in the PDF
Write polarIntegral(f, R, n): the integral of f(x, y) over the disc of radius R, using an n by n grid of midpoints in r (from 0 to R) and θ (from 0 to 2π), each weighted by r · Δr · Δθ.
A circular plate of radius 3 m has density kg/m², where is the distance from its centre in metres. Find its mass.
kg
Calculus217 / 237
Module 19 · Multiple integrals and vector calculus
The Jacobian: how a change of variables stretches area
Polar coordinates are one change of variables among many. For any smooth map , a tiny rectangle becomes a tiny parallelogram whose area is , where is the Jacobian determinant of the map. It plays the role of in substitution.
In three dimensions, spherical coordinates give , by the same determinant.
QuizInteractive · disabled in the PDF
The map , stretches the plane. What is its Jacobian, and what does it mean?
The map , stretches the plane. What is its Jacobian, and what does it mean?
Calculus218 / 237
Module 19 · Multiple integrals and vector calculus
A vector field puts an arrow at every point
A vector field attaches a vector to each point: the velocity of a fluid, the force of gravity, an electric field. The gradient of any function is one. A field that is the gradient of some function is called conservative, and is its potential.
A circle the flow follows
The rotation field , a fluid swirling anticlockwise, faster further out. The arrows are scaled down to fit.
QuizInteractive · disabled in the PDF
Which field is the gradient of ?
Which field is the gradient of ?
Calculus219 / 237
Module 19 · Multiple integrals and vector calculus
Line integrals add up a field along a path
Moving along a curve through a force field, each short step takes work : only the part of the force along the path counts. Describe the path by for and the line integral becomes an ordinary integral in .
For a conservative field , the line integral is , whatever the path; round a closed loop it is 0. The rotation field gives , so it cannot be conservative.
Code challengeInteractive · disabled in the PDF
Write lineIntegral(F, r, a, b, n): split [a, b] into n steps; for each, take the step dr = r(t1) - r(t0) and add F(midpoint) · dr, where the midpoint is halfway between r(t0) and r(t1). A point or a vector is a Vec, a std::pair<double, double>.
Two derivatives of a vector field describe what it does near a point. Divergence is how much the flow spreads out (a source) or gathers in (a sink). Curl is how much it spins: put a tiny paddle wheel in the flow and see how fast it turns. In the plane, curl is a single number; in space, it is a vector along the paddle wheel's axis.
Field
Picture
Divergence
Curl
Swirls round the origin
Streams out from the origin
Flows in along one diagonal, out along the other
The source field : divergence 2 everywhere, and no swirl at all.
QuizInteractive · disabled in the PDF
For , what are the divergence and the curl?
For , what are the divergence and the curl?
Calculus221 / 237
Module 19 · Multiple integrals and vector calculus
Green's theorem: the boundary knows what is inside
Add up the curl over a region, and all the little spins cancel against their neighbours except along the edge. Green's theorem says so precisely: the circulation round a closed curve (taken anticlockwise) equals the integral of the curl over the region inside. It is the fundamental theorem of calculus in two dimensions: a derivative inside, the original function on the boundary.
Check with the rotation field on the unit disc: curl 2, area , so , exactly the line integral you computed.With and , the curl is 1, so the integral is the area. A planimeter, a mechanical device that measures the area of a shape on a map by tracing its edge, works on this principle.
QuizInteractive · disabled in the PDF
Using Green's theorem, what is anticlockwise round the unit circle? (Hint: in polar, over the unit disc is .)
Using Green's theorem, what is anticlockwise round the unit circle? (Hint: in polar, over the unit disc is .)
Calculus222 / 237
Module 19 · Multiple integrals and vector calculus
Stokes' and the divergence theorem: one idea in every dimension
In three dimensions the same pattern gives two theorems. Stokes' theorem: the circulation round the edge of a surface equals the flux of the curl through it. The divergence theorem (Gauss's): the total flux out through a closed surface equals the integral of the divergence over the solid inside. Physics lives on them: Gauss's law for electric charge and Maxwell's equations are written in exactly these forms.
Theorem
Inside
Boundary
Fundamental theorem
Gradient theorem
Green's
Stokes'
Divergence
The general Stokes theorem. In the language of differential forms all five rows are one statement, : integrating the derivative over a region equals integrating over its boundary . It holds in any number of dimensions, and it is where advanced calculus on manifolds begins.
QuizInteractive · disabled in the PDF
What is the flux of out of the unit sphere?
What is the flux of out of the unit sphere?
Calculus223 / 237
Module 19 · Multiple integrals and vector calculus
Practice problems
ProblemInteractive · disabled in the PDF
Find for along the parabola , .
ProblemInteractive · disabled in the PDF
Use Green's theorem to find anticlockwise round the circle of radius 3 centred at the origin.
ProblemInteractive · disabled in the PDF
For , find the divergence and the curl at the point .
ProblemInteractive · disabled in the PDF
The field is conservative. Find its potential with , and the work along any path from to .
Calculus224 / 237
Module 19 · Multiple integrals and vector calculus
Recap
Double and triple integrals add or ; compute them as iterated integrals, with inner limits that may depend on outer variables.
Polar: . In general, (the Jacobian determinant) scales the area element.
A vector field is conservative if it is a gradient; then line integrals depend only on the endpoints.
Line integral: , the work along a path.
Divergence: spreading. Curl: spinning.
Green's, Stokes' and the divergence theorem: the integral of a derivative inside equals an integral on the boundary.
FlashcardsInteractive · disabled in the PDF
Fubini's theorem
An integral over a rectangle can be done in either order.
Polar area element
.
Jacobian determinant
The factor by which a change of variables scales small areas or volumes.
Conservative field
: path-independent line integrals, zero round loops, zero curl.
Divergence
: the outflow per unit area or volume.
Curl in the plane
: the spin per unit area.
Green's theorem
.
Module 20: Rigour and the frontier
Calculus225 / 237
Module 20 · Rigour and the frontier
What a limit really means
" gets close to as gets close to " is vague: how close, and close enough for what? The definition Cauchy and Weierstrass settled on in the 1800s turns it into a game. You challenge me with a tolerance (epsilon), however small. I must answer with a (delta) so that every within of , apart from itself, gives within of . If I can always answer, the limit is .
The proof is a recipe for , given any . Scratch work runs backwards from .
f(x) = 3x − 1
5 ± ε
Worst error 3δ0.6
Inside the band (1 = yes)1
Pick (the horizontal band) and then (the vertical strip). You win when the graph over the strip stays inside the band: when .
QuizInteractive · disabled in the PDF
For with , which values of work? Choose every one.
For with , which values of work? Choose every one.
ProblemInteractive · disabled in the PDF
For with , what is the largest that works? And for with , what does the recipe (under Go deeper) give?
Going deeper
For curved functions the recipe needs a safety cap. For : . If then , so works. The is typical: first keep in a region where you can bound the other factor.
Calculus226 / 237
Module 20 · Rigour and the frontier
The order of the quantifiers is the whole point
In "for every there is a ", is chosen after and may depend on it. Swap the order and the statement means something else. To show a limit does not exist, negate it: there is one bad for which every fails, because some within lands outside the band.
sin(1/x)
near 0 swings between and infinitely often. With , no strip around 0, however narrow, fits in any band: the limit does not exist.
Put in orderInteractive · disabled in the PDF
Put the parts of the definition of in order.
1.For every
2.there is a
3.we have
4.such that for all with
QuizInteractive · disabled in the PDF
Which statement means ""?
Which statement means ""?
Calculus227 / 237
Module 20 · Rigour and the frontier
The real numbers have no gaps
The rational numbers (fractions) are dense, yet full of holes: the fractions whose square is below 2 have no smallest fraction above them all, because is not a fraction. The real numbers fill every such hole. That is the completeness axiom: every non-empty set of reals that is bounded above has a least upper bound (a supremum), which is itself a real number.
Monotone convergence: an increasing sequence that is bounded above converges (to its supremum).
Intermediate value theorem: a continuous function that changes sign has a root.
Extreme value theorem: a continuous function on attains a maximum and a minimum.
Bolzano–Weierstrass: every bounded sequence has a convergent subsequence.
Note. Every one of these fails over the rationals. is continuous, negative at 1 and positive at 2, and has no rational root. Calculus needs the real numbers, and the reason is completeness.
QuizInteractive · disabled in the PDF
Which set has no least upper bound within the rational numbers?
Which set has no least upper bound within the rational numbers?
Calculus228 / 237
Module 20 · Rigour and the frontier
A proof that is also an algorithm
Here is the intermediate value theorem's proof, by bisection. Suppose is continuous, . Look at the midpoint: keep whichever half still has a sign change. The intervals shrink by half each time, the left ends increase and are bounded, so by completeness they converge to some . Continuity then forces and , so . Run the same steps on a computer and you have a root finder.
Code challengeInteractive · disabled in the PDF
Write bisect(f, a, b, tol): f(a) and f(b) have opposite signs. Halve the interval, keeping the half with a sign change, until it is shorter than tol; return its midpoint.
Bisection starts on , where changes sign. How many halvings are needed before the interval is shorter than ?
Calculus229 / 237
Module 20 · Rigour and the frontier
Uniform continuity: one δ for the whole interval
Continuity at every point lets depend on the point as well as on . Uniform continuity asks for more: one for each that works everywhere at once. On a closed, bounded interval the two are the same (the Heine–Cantor theorem); that is what makes every continuous function on integrable.
f(x) = 1/x
f(p) ± ε
Largest δ that works at p0.1
on with . Slide the point toward 0: the needed shrinks towards 0, so no single works everywhere. is continuous on but not uniformly.
QuizInteractive · disabled in the PDF
Which of these is uniformly continuous on the given set?
Which of these is uniformly continuous on the given set?
Calculus230 / 237
Module 20 · Rigour and the frontier
The chain of theorems behind the fundamental theorem
The results you have used since the derivative module rest on each other. Completeness gives the extreme value theorem. If , a maximum or minimum must be inside, where : Rolle's theorem. Tilt the picture and you get the mean value theorem. And the mean value theorem proves the fundamental theorem.
The left side never changes, and the right side is a Riemann sum for every partition. So must be the integral.
Put in orderInteractive · disabled in the PDF
Put these in the order in which each is used to prove the next.
1.Extreme value theorem
2.Completeness of the real numbers
3.Mean value theorem
4.Fundamental theorem of calculus
5.Rolle's theorem
Calculus231 / 237
Module 20 · Rigour and the frontier
Beyond Riemann: measure and the Lebesgue integral
The Riemann integral slices the -axis. Some functions defeat it: the Dirichlet function, 1 on rational numbers and 0 on irrationals, has every interval containing both, so upper sums are always 1 and lower sums always 0. Lebesgue (1902) sliced the -axis instead: for each value, measure how much of the -axis takes it. That needs a notion of size for strange sets, called measure: an interval has measure equal to its length, and any countable set, such as the rationals, has measure 0.
Why mathematicians switched. Lebesgue's integral agrees with Riemann's whenever both exist, but its limits behave far better: the dominated convergence theorem lets you swap and under one easy condition. Modern probability is built on it: a probability is a measure, and an expected value is a Lebesgue integral.
QuizInteractive · disabled in the PDF
Why do the rational numbers in have measure 0?
Why do the rational numbers in have measure 0?
Calculus232 / 237
Module 20 · Rigour and the frontier
Calculus of variations: the best function
Ordinary optimisation finds the best number. The calculus of variations finds the best function: the shortest path, the fastest slide, the shape a hanging chain takes. You minimise a functional, a number computed from a whole function, and the condition that replaces is a differential equation, the Euler–Lagrange equation.
Cycloid: fastest
Straight line: shortest
The brachistochrone: the curve of fastest descent from to under gravity is not the straight line but a cycloid, which drops steeply first to pick up speed.
QuizInteractive · disabled in the PDF
Applied to (with in place of as the variable and as the function), what does the Euler–Lagrange equation give?
Applied to (with in place of as the variable and as the function), what does the Euler–Lagrange equation give?
Calculus233 / 237
Module 20 · Rigour and the frontier
Automatic differentiation: the chain rule as code
Training a neural network needs the gradient of one number (the error) with respect to millions of weights. Finite differences would take millions of evaluations and lose digits; symbolic algebra would produce enormous formulas. Automatic differentiation applies the chain rule to each elementary operation as the program runs, giving exact derivatives at small cost. Forward mode carries a value and its derivative together, as a dual number with . Reverse mode (backpropagation) records the operations, then runs the chain rule backwards, getting the whole gradient for a small multiple (a few times) of the cost of one evaluation, however many weights there are.
The product rule and the chain rule fall out of the arithmetic of .
Code challengeInteractive · disabled in the PDF
A Dual carries a value v and a derivative d. add is done. Finish mul (the product rule) and sin (the chain rule), so that f(variable(x)).d is exactly f'(x).
Push the dual number through by hand, with . What are the value part and the part of the result?
Calculus234 / 237
Module 20 · Rigour and the frontier
Problems that mix everything
QuizInteractive · disabled in the PDF
What is ?
What is ?
QuizInteractive · disabled in the PDF
What is ?
What is ?
QuizInteractive · disabled in the PDF
What is ?
What is ?
QuizInteractive · disabled in the PDF
What is ? (Hint: differentiate and multiply by .)
What is ? (Hint: differentiate and multiply by .)
Calculus235 / 237
Module 20 · Rigour and the frontier
Practice problems that mix everything
ProblemInteractive · disabled in the PDF
Evaluate .
ProblemInteractive · disabled in the PDF
For , find .
ProblemInteractive · disabled in the PDF
Which makes as large as possible, and what is that largest value?
Calculus236 / 237
Module 20 · Rigour and the frontier
More practice problems that mix everything
ProblemInteractive · disabled in the PDF
The solution of with has no simple formula. Find and from the equation, and use the Taylor polynomial at 0 to estimate .
ProblemInteractive · disabled in the PDF
What is the average value of over the unit disc ?
Calculus237 / 237
Module 20 · Rigour and the frontier
Recap, and where to go next
Limits are defined by and : for every tolerance, a closeness that guarantees it. Quantifier order is everything.
Completeness, no gaps in the reals, is what makes the IVT, EVT and every theorem after them true.
Uniform continuity: one everywhere; automatic for continuous functions on .
Completeness → EVT → Rolle → MVT → the fundamental theorem.
Lebesgue integration measures the sets where takes each value; it underlies modern probability.
The calculus of variations optimises functions; automatic differentiation is the chain rule run by a computer.
Next: real analysis (proofs of all of this), complex analysis, differential equations, differential geometry, numerical analysis.
FlashcardsInteractive · disabled in the PDF
ε-δ definition of a limit
: .
Completeness axiom
Every non-empty set of reals bounded above has a least upper bound.
Uniform continuity
For each , one that works at every point.
Measure zero
Coverable by intervals of total length as small as you like; every countable set is.
Euler–Lagrange equation
.
Dual number
with : a value and its derivative, carried together.
Reverse-mode autodiff
Record the operations, then apply the chain rule backwards: a whole gradient for a few times the cost of one evaluation.
Answer key
1. Rates of change: the question calculus answers · The average rate of change of a function · QuizWhat is the average rate of change of from to ?B. and , so the change in output is . The change in input is , and . The tempting is only the change in output: a rate always divides by the change in input.
1. Rates of change: the question calculus answers · The average rate of change of a function · ProblemFind the average rate of change of from to .11
The outputs at the two ends:
Divide the change in output by the change in input:
On average, grows by for each that grows. Watch the sign of : subtracting adds .
1. Rates of change: the question calculus answers · Speed from a distance graph · ProblemThe ball has fallen metres after seconds. What is its average speed between s and s?24.5 m/s
Where the ball is at each time:
That is faster than the m/s of the second before: a falling ball keeps speeding up.
1. Rates of change: the question calculus answers · Speed from a distance graph · Code challengeWrite averageRate(f, a, b): the average rate of change of the function f from a to b, that is the change in f divided by the change in input.One solution:
It is the formula as code: call f at both ends, subtract, divide by the run. Swapping the ends flips the sign of both the top and the bottom, so the rate stays the same. A common slip is forgetting the brackets: f(b) - f(a) / (b - a) divides only f(a).
1. Rates of change: the question calculus answers · Speed right now is a puzzle · QuizWhat speed do these averages approach, as gets closer and closer to ?C. m/sThe average is . As shrinks, shrinks to nothing, leaving m/s. That number is the instantaneous speed at 1 s. Notice you never set (that would be ): you asked what the averages approach. That idea is a limit, the next module.
1. Rates of change: the question calculus answers · The area under a speed graph is the distance · QuizA cyclist rides at m/s for s, then at m/s for s. How far does she go?B. mThe speed graph is two rectangles: m and m, so m in all. Averaging the speeds, m/s over 15 s gives m, which is wrong: she spent longer at 6 m/s, so the times must weigh the speeds. Adding areas does that for you.
1. Rates of change: the question calculus answers · Two questions, slopes and areas · QuizWhich of these is a question for integral calculus? Choose all that apply.A. How much water flowed into a bath, given the flow rate each second; C. The total rainfall in a day, given the rate per hourAdding up a rate over time to get a total is an area question: water from flow rate, rainfall from rate per hour. The balloon’s growth "at the moment" and the steepest point are both about slopes, so they belong to differential calculus.
1. Rates of change: the question calculus answers · Where calculus came from · Put in orderPut these in the order they happened.1. Archimedes finds the area of a parabolic segment 2. Fermat finds tangents and maxima of curves 3. Newton develops his method of fluxions 4. Leibniz publishes the first paper on differential calculus 5. Cauchy builds calculus on limits 6. Weierstrass gives the ε-δ definitionsArchimedes (around 250 BC), Fermat (1630s), Newton (1665–66, unpublished), Leibniz (1684), Cauchy (1820s), Weierstrass (around 1860). Newton had his ideas first, but Leibniz published first, which is why the dispute was so heated.
1. Rates of change: the question calculus answers · Practice problems · ProblemLet . Simplify the average rate of change of from to (for ). Then say what it approaches as gets closer and closer to .Average rate 7 + h; It approaches 7
The two outputs:
The average rate of change, the slope of the secant:
As shrinks towards , heads for : the slope of the curve right at . You never set ; you watch where goes.
1. Rates of change: the question calculus answers · Practice problems · ProblemA stone dropped from a cliff falls metres in seconds. Find its average speed from to as a formula in , and then its speed at exactly s.Average speed 29.4 + 4.9*h m/s; Speed at s 29.4 m/s
As shrinks, shrinks to nothing, so at exactly s the stone falls at m/s. Notice : its speed grows by m/s every second.
1. Rates of change: the question calculus answers · Practice problems · ProblemA car drives at a steady m/s for s, then speeds up steadily from m/s to m/s over the next s. How far does it go in these s, and what is its average speed?Distance 500 m; Average speed 50/3 ≈ 16.6667 m/s
The distance is the area under the speed graph. The first s are a rectangle:
The next s are a rectangle wide and tall, with a triangle on top, wide and tall:
In all m. The average speed is the total distance over the total time:
1. Rates of change: the question calculus answers · Practice problems · ProblemA tank drains so that minutes after the tap opens it holds litres. What is the average rate of change of from to minutes?-21 L/min
The tank loses litres a minute on average over those minutes. The minus sign says the water is going down, like a secant line that falls.
2. Limits · Guessing a limit with a table · Code challengeWrite valuesNear(f, a, n): a vector of f(a + 0.1), f(a + 0.01), … , , the values of f as the input closes in on a from above.One solution:
Solution
1#include<cmath>2#include<functional>3#include<vector>45std::vector<double>valuesNear(std::function<double(double)> f,6double a,int n){7 std::vector<double> values;8for(int k =1; k <= n; k++){9 values.push_back(f(a + std::pow(10,-k)));10}11return values;12}
The loop runs k from 1 to n and evaluates f at a + std::pow(10, -k): , , and so on. Starting at k = 0 is the usual slip: it adds f(a + 1), a point nowhere near , and gives one value too many. C++ has no power operator, so is std::pow(10, -k); 10 ^ -k compiles, but ^ is bitwise XOR, a different number entirely.
2. Limits · Limits from the left and from the right · QuizFor this , what is ?D. It does not existThe left-hand limit is and the right-hand limit is . They disagree, so there is no single value approaches: the two-sided limit does not exist. is true, but the value at the point never decides the limit. Averaging to is not a thing limits do.
2. Limits · Three ways a limit can fail to exist · QuizWhat happens to as ?C. It goes to from the right and from the left, so there is no limitFor small positive , is huge and positive; for small negative it is huge and negative. The one-sided "limits" are and , which disagree. Unlike , you can’t even write for the two-sided limit.
2. Limits · Limit laws let you split the work · QuizWhat is ?A. The bottom at is , not , so you may substitute: . Substitution only fails when it gives a on the bottom; then you need the tricks on the next slide.
2. Limits · When substitution gives zero over zero · Fill the blanksFind by factoring. Fill in the blanks.1: 3, 2: 6 is a difference of squares, . Cancelling is allowed because a limit never looks at itself. What is left, , can be substituted: .
2. Limits · When substitution gives zero over zero · ProblemFind .5/6 ≈ 0.833333
At the top is and the bottom is . Factor both:
Now the bottom isn’t at , so substitute:
2. Limits · The squeeze theorem · ProblemA function satisfies for every . Find .7
Both bounds are polynomials, so substitute:
Both head for and is trapped between them, so by the squeeze theorem . You never needed a formula for .
2. Limits · The most important trig limit · QuizWhat is ?B. Write it as . As , too, so , leaving . The tempting comes from using the rule without matching the angle on top to the bottom.
2. Limits · Limits at infinity and horizontal asymptotes · Code challengeWrite limitAtInfinity(top, bottom). Each argument is a polynomial’s coefficients, highest power first ({3, 0, 1} is ), and its first coefficient isn’t 0. Return the limit as : 0, the ratio of leading coefficients, or INFINITY / -INFINITY (from <cmath>).One solution:
Solution
1#include<cmath>2#include<vector>34doublelimitAtInfinity(const std::vector<double>& top,5const std::vector<double>& bottom){6double ratio = top[0]/ bottom[0];7if(top.size()< bottom.size())return0;8if(top.size()== bottom.size())return ratio;9return ratio >0? INFINITY :-INFINITY;10}
The degree is one less than the size of the vector. For huge only the leading terms matter, so the fraction behaves like . If that shrinks to ; if it is ; if it grows without bound, with the sign of . Forgetting the sign is the usual mistake: heads to . INFINITY is a real double value, not an error, so the tests can compare it exactly with EXPECT_EQ.
2. Limits · Practice problems · ProblemFind .1/6 ≈ 0.166667
Factoring works too, once you see for .
2. Limits · Practice problems · ProblemFind .-1/4 ≈ −0.25
Divide by . It cancels, since a limit never looks at itself:
This is the slope of at , found as the limit of secant slopes: what module 4 calls a derivative.
2. Limits · Practice problems · ProblemWith in radians, find (a) and (b) .(a) 5/2 ≈ 2.5; (b) 4/3 ≈ 1.33333
(a) Multiply and divide by , so the angle on top matches the bottom:
(b) Divide the top and the bottom by , then match each angle:
The limit of a quotient is the quotient of the limits here, because the bottom’s limit, , isn’t .
2. Limits · More practice problems · ProblemLet for and for . Find the left-hand and right-hand limits at . Then suppose the right piece were instead: which would make exist? 3; 5; 2
From the left, , a line, so substitute: .
From the right, : . They differ, so does not exist: the graph jumps.
With on the right, the right-hand limit is . It matches the left when , so .
2. Limits · More practice problems · ProblemFind (a) and (b) .(a) 2; (b) 3/2 ≈ 1.5
(a) Divide the top and the bottom by :
(b) Divide the top and the bottom by . For , , so it goes inside the root as :
The highest powers decide: the top behaves like and the bottom like .
3. Continuity · The kinds of discontinuity · QuizWhat kind of discontinuity does have at ?A. RemovableFor , , so the limit at is . But is , undefined: condition 1 fails. Setting fills the hole, which makes it removable. A from substitution often means a hole, not a vertical asymptote.
3. Continuity · The kinds of discontinuity · Problem is undefined at . What value should be given to make continuous there? 5
So . Defining makes the value equal the limit: the discontinuity was removable, and now it is removed.
3. Continuity · Most formulas are continuous wherever they make sense · QuizWhere is not continuous? Choose all that apply.B. ; C. It is a fraction of polynomials, so it breaks only where the bottom is zero: at and . At the top is zero, which just makes , a perfectly good value.
3. Continuity · Choosing a value to join two pieces · Fill the blanksMake (for ) and (for ) continuous.1: 2, 2: 1The right piece is at the join. The left piece arrives at . Setting them equal gives . Then the left-hand limit, the right-hand limit and are all .
3. Continuity · Choosing a value to join two pieces · ProblemFind so that for and for is continuous at . 4
The left piece arrives at . The right piece is at .
Check: with the left-hand limit, the right-hand limit and are all .
3. Continuity · The theorem needs continuity · QuizWhich of these does the intermediate value theorem guarantee has a root in the given interval? Choose all that apply.A. on ; D. on is at and at , and is a continuous polynomial: a root is guaranteed. is about at and at , and is continuous: guaranteed. breaks at and breaks at , inside their intervals, so the theorem says nothing (and neither has a root there).
3. Continuity · Bisection: halve the interval until the root is trapped · Put in orderPut one step of the bisection method in order.1. Check that and have opposite signs 2. Compute the midpoint 3. Evaluate 4. If and have opposite signs, set ; otherwise set 5. Stop if is smaller than the tolerance, else repeatThe sign check comes first: without a sign change the IVT promises nothing. Then the midpoint and its value decide which half keeps the sign change. Comparing with (not with alone) is what works for both rising and falling functions.
3. Continuity · Bisection as code · Code challengeWrite bisect(f, a, b, tol). f(a) and f(b) have opposite signs. Halve the interval, keeping the half where the sign changes, until b - a < tol, then return the midpoint.One solution:
Solution
1#include<functional>23doublebisect(std::function<double(double)> f,4double a,double b,double tol){5while(b - a >= tol){6double m =(a + b)/2;7if(f(m)*f(a)>0) a = m; // same sign: the root is right of m8else b = m;9}10return(a + b)/2;11}
If has the same sign as , the sign change must be in , so moves up to ; otherwise moves down. Two numbers have the same sign exactly when their product is positive, which is the test f(m) * f(a) > 0. Testing f(m) > 0 to decide only works when rises; falls, and that version would walk away from the root. Each loop halves the width, so it ends after about steps.
3. Continuity · Bisection as code · QuizStarting from an interval of width , about how many bisection steps make it narrower than ?B. After steps the width is . Since , , so 20 steps do it. Bisection gains about one decimal digit every 3.3 steps: slow but certain. Newton’s method (module 8) is much faster, when it works.
3. Continuity · The extreme value theorem · QuizWhich function is guaranteed a maximum by the extreme value theorem?C. on is continuous everywhere and is closed: the theorem applies. on the open creeps toward but never gets there. grows without bound near . breaks at , inside .
3. Continuity · Practice problems · ProblemFind and so that this function is continuous everywhere: for , for , and for . 1; 5
At : the left piece arrives at , and the middle piece is at .
At : the middle piece is at , and the right piece arrives at .
Subtracting the first equation from the second gives , so and . The middle piece is .
3. Continuity · Practice problems · Problem is discontinuous at two points. Find the one that is removable, the value that fills its hole, and the one where blows up.Removable at 1; Filled by the value -1/2 ≈ −0.5; Infinite at 3
At the factor cancels and the limit is : a hole, removed by setting .
At nothing cancels: the bottom goes to while the top stays near , so blows up. That one is infinite, and no value of can fix it.
3. Continuity · Practice problems · Problem has a root in . Take three steps of the bisection method: which interval are you left with? And how many steps, starting from , make the interval narrower than ?Left end 1.25; Right end 1.375; Steps for a width under 10
After three steps the root is trapped in . (It is .)
The width after steps is . Since and , : it takes steps.
3. Continuity · Practice problems · ProblemLet for , and . Which makes continuous at ? 3
So . Any other value leaves a removable discontinuity at : the graph heads for height from both sides.
4. The derivative · Working out a derivative from the definition · Find the bugThis works out the derivative of at . One line is wrong. Which?Line 2: = 3(a^2 + 2ah + h^2) - 3a^2 is , not : the middle term was lost. With it, the quotient is and the derivative is . A derivative of everywhere would mean is flat, which the graph plainly isn’t: a good sanity check.
4. The derivative · Working out a derivative from the definition · ProblemUse the definition of the derivative to find for . Then find .4*x - 3; 5
So , and .
4. The derivative · The equation of the tangent line · Fill the blanksFind the tangent line to at , using . Write decimals.1: 0.5, 2: -0.25, 3: 1 and . Expanding, . The slope is negative because falls as grows.
4. The derivative · The equation of the tangent line · ProblemFind the tangent line to at , using . Give it as .-4*x + 4
Check: at the line gives , the curve’s height.
4. The derivative · The derivative is a function too · Quiz always rises. What is its slope at ?A. : the tangent at the origin is flat, the -axis itself. A function can rise everywhere and still be momentarily flat at a point. So "slope 0" does not mean "turns round", a fact module 7 relies on.
4. The derivative · Ways to write the derivative · Quiz is the water in a tank, in litres, minutes after midnight. . What does that say?B. At 00:10 the tank is losing water at 4 litres per minuteA derivative is a rate: litres per minute, at that moment. Negative means the amount is falling. It says nothing directly about how much is in the tank (that is ) or about the total change over the first 10 minutes (that is ).
4. The derivative · Differentiable means smooth, not only unbroken · QuizWhich statement is true?B. If is differentiable at , it is continuous at Differentiable is the stronger property. Since , : that is continuity. The converse fails at every corner, being the classic case.
4. The derivative · Reading the derivative from a graph · QuizFrom the graph alone, where is ?B. Between and The curve climbs to a hilltop at , falls to a valley at , then climbs again. Falling means a negative slope, so on , and exactly at the hilltop and the valley. Confusing " is negative" with " is falling" is the usual slip: is negative for and for , which is a different set.
4. The derivative · Finite differences as code · Code challengeWrite forwardDiff(f, x, h) and centralDiff(f, x, h), the two estimates of from the last slide.One solution:
The central difference divides by 2 * h because its two points are apart; dividing by h doubles the answer, the most common slip. It is exact for a parabola: , whatever is, because the error terms of the two sides cancel. using Fn = … gives the long function type a short name. The tests wrap std::sin in a lambda because std::sin comes in several versions (for float, double…), and the compiler can’t tell which one to pass.
4. The derivative · Practice problems · ProblemUse the definition of the derivative to find for . Then give the tangent line at as .1/6 ≈ 0.166667; Tangent: x/6 + 3/2
The tangent goes through with slope :
4. The derivative · Practice problems · ProblemThe tangent to at crosses the -axis at one point and meets the curve again at another. Find the of each. (.)Crosses the -axis at 2/3 ≈ 0.666667; Meets the curve again at -2
At : and , so the tangent is .
It crosses the axis where : .
It meets the curve where :
is the point of tangency, a double root because the line touches there. The other meeting is at , the point .
4. The derivative · Practice problems · ProblemEstimate for with , first with the forward difference, then with the central difference. (The true value is .)Forward 3.31; Central 3.01
The forward error, , is close to the estimate . The central error, , is exactly: about 30 times smaller for the same .
4. The derivative · Practice problems · ProblemA stone thrown upward is metres high after seconds. From the definition of the derivative, find its velocity . How fast is it rising at s, and when does it stop rising?20 - 10*t m/s; At 10 m/s; Stops rising at 2 s
So m/s, and m/s.
It rises while and stops rising when : at s. It is then at its highest, m.
5. Rules for derivatives · The power rule · QuizWhat is ?B. Write it as . The power rule brings down and lowers the power by one, from to : . Going from to is the usual slip: lowering a negative power makes it more negative.
5. Rules for derivatives · Sums and constant multiples · Fill the blanksDifferentiate , term by term.1: 10, 2: -6, 3: 3, , and . So . A constant multiple never changes the rule, it only scales the answer.
5. Rules for derivatives · Sums and constant multiples · ProblemDifferentiate . Then find .4*x^3 - 6*x - 8/x^2 + 2/sqrt(x); -8
The constant has derivative . At : .
5. Rules for derivatives · Differentiating a polynomial in code · Code challengeWrite derivePoly(c), the coefficients of the derivative (lowest power first; {} for a constant), and evalPoly(c, x), the polynomial’s value at x.One solution:
Solution
1#include<vector>23std::vector<double>derivePoly(const std::vector<double>& c){4 std::vector<double> d;5for(int k =1; k <int(c.size()); k++) d.push_back(k * c[k]);6return d;7}89doubleevalPoly(const std::vector<double>& c,double x){10double sum =0;11for(int k =int(c.size())-1; k >=0; k--) sum = sum * x + c[k];12return sum;13}
The term at index k becomes , so the loop starts at k = 1 (the constant has nothing to give) and each k * c[k] lands one index lower, at k - 1. Starting at k = 0 is the common off-by-one: it pushes a 0 for the constant and every coefficient sits one place too high. int(c.size()) turns the size, which is an unsigned std::size_t, into an int, so that evalPoly’s k can go below 0 to end its loop. evalPoly uses Horner’s rule, , which needs no powers at all. Whole-number coefficients times whole numbers are exact in a double, which is why the first two tests may compare with EXPECT_EQ.
5. Rules for derivatives · The derivative of ln x · QuizWhat is ?A. stays , becomes , and becomes . The second option applies the power rule to , but the power rule is for , with in the base. In , is the exponent: a different kind of function.
5. Rules for derivatives · The product rule · Find the bugThis differentiates . One line is wrong. Which?Line 3: (fg)' = f' g + f g' = 3x^2 sin x + x^3 cos xMultiplying the derivatives is the classic mistake. Test it on : , but the derivative of is . The product rule gives , as it should.
5. Rules for derivatives · The quotient rule · QuizWhat is ?B. With and : . Swapping the order on top gives the third option, the right size with the wrong sign. And is the "derivative of top over derivative of bottom" mistake.
5. Rules for derivatives · The quotient rule · ProblemDifferentiate and simplify. What is the slope at ?4*x/(x^2 + 1)^2; Slope at 1
At : .
5. Rules for derivatives · Higher derivatives · QuizWhat is the 4th derivative of ?D. : the derivatives cycle with period 4. So the 4th, 8th, 100th derivatives are all . This cycle is what makes the Taylor series of sine so tidy (module 16).
5. Rules for derivatives · Position, velocity and acceleration · QuizAt what time is the ball highest, and how high is it?A. At s, about m upAt the top the velocity is : gives s. Then m. At the top the acceleration is still m/s², not : the ball is stopped for an instant, but its velocity is still changing.
5. Rules for derivatives · Practice problems · ProblemDifferentiate , and find the slope at .2*x*ln(x) + x; Slope at 3*e ≈ 8.15485
5. Rules for derivatives · Practice problems · ProblemFind the tangent line to at , as .2*e*x - e
Its slope is , and it crosses the -axis at .
5. Rules for derivatives · Practice problems · ProblemLet . Find and .6*x - sin(x); sin(x)
The polynomial part runs out after four steps (), just as the sine comes back round to itself.
5. Rules for derivatives · Practice problems · ProblemA particle moves along a line, at position metres after seconds (). At which two times is it at rest? What is its acceleration at the second of them?First at rest at 1 s; Then again at 3 s; Acceleration then 6 m/s²
at s and at s: it stops, turns round, and stops again.
At s it is stopped but accelerating forwards, so it sets off forwards again. At s, m/s²: that is where it turns back.
5. Rules for derivatives · More practice problems · ProblemDifferentiate and simplify. At which is the tangent flat?e^x*(x - 1)/x^2; Flat at 1
The tangent is flat where . Since and (for ), only will do: , at the point .
5. Rules for derivatives · More practice problems · ProblemA culture of bacteria has cells after hours. How fast is it growing at hours?4000*ln(2) ≈ 2772.59 cells per hour
At that moment it has cells, and it is growing at times its size per hour: growth in proportion to size.
6. The chain rule and implicit differentiation · Functions inside functions · QuizIn , which is the inner function?B. To compute for a number , you take first, then the logarithm of that. What you do first is the inner function: , and the outer one is . It is not a product: nothing is multiplied.
6. The chain rule and implicit differentiation · The chain rule in practice · Fill the blanksDifferentiate . Write the inner derivative as a number times a power.1: 15x^2, 2: -sin uThe derivative of is , kept at the inner function , and the inner derivative is . So .
6. The chain rule and implicit differentiation · The chain rule in practice · ProblemDifferentiate , and find the slope at .16*x*(2*x^2 - 3)^3; Slope at -16
At : .
6. The chain rule and implicit differentiation · The mistake everyone makes once · Find the bugThis differentiates . One line is wrong. Which?Line 2: d/dx (x^2 + 1)^3 = 3(x^2 + 1)^2 * 2xThe outer power rule gave , but the inside has derivative , so the term is . Line 3 is wrong too, but only because it copied line 2: the first wrong step is the bug.
6. The chain rule and implicit differentiation · The chain rule as code · Code challengeWrite chainDerivative(fPrime, g, gPrime). It returns a function of x giving the derivative of f(g(x)), by the chain rule.One solution:
The outer derivative is evaluated at the inner function, fPrime(g(x)), not at x: , not . Then it is multiplied by gPrime(x). Both halves are needed: the starter’s fPrime(x) gets each wrong. The last test checks the rule against the finite difference from module 4, which is how you test a hand-written derivative in practice. Without the = in [=], the lambda could not use fPrime, g or gPrime at all: the compiler stops with an error.
6. The chain rule and implicit differentiation · Implicit differentiation · ProblemThe point is on the ellipse . Find the slope of the tangent there, and the tangent line as .-1/2 ≈ −0.5; Tangent: -x/2 + 2
At : .
6. The chain rule and implicit differentiation · Implicit differentiation, step by step · Put in orderPut the steps of implicit differentiation in order.1. Differentiate both sides with respect to 2. Wherever is differentiated, multiply by (the chain rule) 3. Collect the terms with on one side 4. Factor out and divide to get alone 5. Substitute the point’s and You can only substitute the point at the end, once is alone: substituting before differentiating would turn the curve into a single number, whose derivative is . The chain-rule factor appears during differentiation, and gathering it up is plain algebra.
6. The chain rule and implicit differentiation · Derivatives of inverse functions · Quiz has an inverse, and . What is ?B. . The point on the inverse matches on , so . Evaluating at instead gives : the slope must be taken at the matching point , not at .
6. The chain rule and implicit differentiation · Logarithmic differentiation · QuizAt what is the slope of equal to ?C. is never for , so the slope is only when , that is , . That is the lowest point of , about . At the slope is .
6. The chain rule and implicit differentiation · Derivatives of the inverse trig functions · QuizWhat is ?B. Outer derivative at gives ; times the inner derivative . The first option forgets the inner derivative, the third squares wrongly: .
6. The chain rule and implicit differentiation · Practice problems · ProblemDifferentiate (a) and (b) .(a) -2*sin(2*x)*e^(cos(2*x)); (b) 2*x/(x^2 + 9)
(a) Peel the layers from the outside:
(b) Outer , inner :
6. The chain rule and implicit differentiation · Practice problems · ProblemDifferentiate and factor the result. At which is the tangent flat?x*e^(-3*x)*(2 - 3*x); Flat at 2/3 ≈ 0.666667
is never , so only at and . The one with is .
6. The chain rule and implicit differentiation · Practice problems · Problem has an inverse. Find and .1/7 ≈ 0.142857; 1/2 ≈ 0.5
.
, so matches :
, so matches :
6. The chain rule and implicit differentiation · Practice problems · ProblemUse logarithmic differentiation to differentiate (for ). What is the slope at ?2*x^(2*x)*(ln(x) + 1); Slope at 2
At : .
6. The chain rule and implicit differentiation · More practice problems · ProblemThe point is on the curve . Find there, and the tangent line as .-4/5 ≈ −0.8; Tangent: -4*x/5 + 14/5
At : .
6. The chain rule and implicit differentiation · More practice problems · ProblemLet . Find the slope of its graph at and at .At pi/4 + 1/2 ≈ 1.2854; At pi/3 + sqrt(3)/4 ≈ 1.48021
7. Graphs, extremes and optimisation · Critical points are where the slope is zero or undefined · QuizWhat are the critical points of ?C. , and , which is at . Dividing by loses the solution : always factor instead of dividing. are where itself is , not its slope.
7. Graphs, extremes and optimisation · The first derivative test · Quiz. What does have at ?C. Neither is never negative, so near the sign of is the sign of : positive on both sides. No change of sign, so just flattens out for a moment and keeps rising. At , goes to : a local minimum there.
7. Graphs, extremes and optimisation · The first derivative test · ProblemFind the local maximum and the local minimum of : where each one is, and its value.Local maximum at -1; Its value 12; Local minimum at 2; Its value -15
The critical points are and . Test points: , , .
So goes to at , a local maximum, and to at , a local minimum:
7. Graphs, extremes and optimisation · The second derivative test · QuizFor , and . What is at ?B. A local minimumThe second derivative test is silent when , but the first derivative test isn’t: goes to at , a minimum. does not make an inflection point either: is positive on both sides, so the concavity never changes.
7. Graphs, extremes and optimisation · The mean value theorem · QuizThe mean value theorem implies which of these?A. If everywhere on an interval, is constant thereIf took two different values at and , the theorem would give a with . So zero slope everywhere means constant: the reason all antiderivatives differ by a constant (module 10). only gives a flat tangent somewhere (Rolle’s theorem), not a flat function.
7. Graphs, extremes and optimisation · The mean value theorem · ProblemFind the number that the mean value theorem promises for on . 4
is inside , as the theorem promises. There the tangent is parallel to the secant from to .
7. Graphs, extremes and optimisation · Sketching a curve from its derivatives · Put in orderPut the steps of sketching in a sensible order.1. Find the domain, and where the graph crosses the axes 2. Compute and find the critical points 3. Use the sign of to find where rises and falls, and classify the extremes 4. Compute and find the concavity and inflection points 5. Check what happens as and near any asymptotes 6. Plot the key points and join them with the right shapeEach step uses the one before: you need before you can read rising and falling, and the critical points before classifying them. Plotting comes last, when you know every feature it must show. In practice the behaviour at infinity can be checked at any time; it just has to be done before drawing.
7. Graphs, extremes and optimisation · The biggest value on a closed interval · QuizWhat is the maximum of the running example on ?A. , at The critical points inside : only , with . The ends: and . The largest is . On the right end won instead: always check the ends.
7. Graphs, extremes and optimisation · Optimisation: finding the best design · QuizFrom a 30 cm square of card, cut a square of side from each corner and fold up an open box: . Which gives the biggest volume?A. cm, cm³By the product and chain rules, , which is at and . On , and cm³. is a critical point too, but it is the empty box.
7. Graphs, extremes and optimisation · Finding a maximum by computer · Code challengeWrite findMax(f, a, b) for a unimodal f on [a, b]: repeat the ternary search step until b - a < 1e-9, then return the midpoint, the of the peak.One solution:
Solution
1#include<functional>23doublefindMax(std::function<double(double)> f,double a,double b){4while(b - a >=1e-9){5double m1 = a +(b - a)/3;6double m2 = b -(b - a)/3;7if(f(m1)<f(m2)) a = m1;8else b = m2;9}10return(a + b)/2;11}
When , the function is still rising somewhere after , and a unimodal function never rises again after its peak, so the peak is right of : move a up. Moving b in that case is the usual slip, and it walks straight away from the peak. Each step keeps two thirds, so it needs about steps: roughly 60 for .
7. Graphs, extremes and optimisation · Practice problems · ProblemFind the inflection point of , and the slope of the curve there. 1; -9; Slope there -12
is negative for and positive for , so the concavity changes at .
The inflection point is , where the curve falls most steeply, with slope .
7. Graphs, extremes and optimisation · Practice problems · ProblemFind the largest and the smallest values of on .Largest 66; Smallest -15
Both are inside . Evaluate there and at the ends:
The largest value is , at the right end, and the smallest is , at . The local maximum at is not the largest value on this interval: the ends matter.
7. Graphs, extremes and optimisation · Practice problems · ProblemA farmer has m of fence to make a rectangular field beside a straight river. The side along the river needs no fence. Which dimensions give the largest area, and what is that area?Each side meeting the river 60 m; Side along the river 120 m; Largest area 7200 m²
With the two sides that meet the river long, the fence left for the far side is :
Compare with the ends: , while m². The best field is m deep and m along the river: twice as long as deep, because only one long side needs fence.
7. Graphs, extremes and optimisation · Practice problems · ProblemWhich point of the curve is closest to the point ? Give its , and its distance from .5/2 ≈ 2.5; Distance sqrt(11)/2 ≈ 1.65831
This is the smallest: goes to there, and it is the only critical point for (at the end , is bigger).
7. Graphs, extremes and optimisation · More practice problems · ProblemAn open-topped box with a square base must hold cm³. Which base side and height use the least cardboard, and how much cardboard is that?Base side 40 cm; Height 20 cm; Cardboard 4800 cm²
for and for : falls all the way to and rises after it, so gives the least cardboard. (There are no ends to check here.)
7. Graphs, extremes and optimisation · More practice problems · ProblemA closed cylindrical can must hold cm³. Which radius and height use the least metal? (Its volume is , and its surface is two discs and a side, .)Radius cbrt(500/pi) ≈ 5.41926 cm; Height 2*cbrt(500/pi) ≈ 10.8385 cm
goes to there, so it is the least.
The best can is exactly as tall as it is wide: its height equals its diameter.
8. Linear approximation, related rates and Newton's method · Near a point, a curve is almost its tangent · ProblemLinearise at , and use it to estimate .2 + (x - 8)/12; 2.01
8. Linear approximation, related rates and Newton's method · Approximations worth knowing by heart · QuizLinearise at to estimate .B. and , so (truly ). Adding the straight on, as if the slope were , gives , which is far off.
8. Linear approximation, related rates and Newton's method · A linearisation as code · Code challengeWrite linearise(f, fPrime, a). It returns the function .One solution:
Working out f(a) and fPrime(a) once, outside the returned lambda, means every call to L costs one multiplication and an addition: that cheapness is the point of a linearisation. [=] copies height, slope and a into the lambda, so L keeps them. Writing slope * x instead of slope * (x - a) is the slip to avoid: it is a line with the right slope through the wrong point.
8. Linear approximation, related rates and Newton's method · Differentials: small changes in, small changes out · Fill the blanksA sphere has . Estimate the change in volume when goes from 5 cm to 5.02 cm. Leave as pi.1: 25, 2: 0.02, 3: 2, which at is ; times that is cm³. The derivative of being , the surface area, is no accident: a thin shell of thickness has volume about area times thickness.
8. Linear approximation, related rates and Newton's method · How big is the error? · QuizYou measure a cube’s side with a possible error of 1%. About how large can the error in its volume be, relatively?B. , so . Cubing triples the relative error; squaring would double it. Checking: , just over 3% bigger.
8. Linear approximation, related rates and Newton's method · Related rates · ProblemA stone dropped in a pond makes a circular ripple whose radius grows at cm/s. How fast is the area inside the ripple growing when the radius is cm?60*pi ≈ 188.496 cm²/s
The radius grows steadily, but the area grows faster and faster: at cm it would be cm²/s.
8. Linear approximation, related rates and Newton's method · The sliding ladder · Put in orderPut the steps for solving a related rates problem in order.1. Draw a picture and name the changing quantities 2. Write the given rate and the wanted rate as derivatives 3. Write an equation linking the quantities 4. Differentiate it with respect to time 5. Substitute the values at the moment asked about, and solveThe equation must be true at every moment before you differentiate it; only then do you plug in the moment’s numbers. Substituting before differentiating is the classic error: it turns a changing quantity into a constant.
8. Linear approximation, related rates and Newton's method · Newton’s method doubles the digits each step · Code challengeWrite newton(f, fPrime, x0, steps): start at x0, take steps Newton steps, and return the last .One solution:
Solution
1#include<functional>23usingFn= std::function<double(double)>;45doublenewton(Fn f,Fn fPrime,double x0,int steps){6double x = x0;7for(int i =0; i < steps; i++){8 x = x -f(x)/fPrime(x);9}10return x;11}
Each pass replaces x with where its tangent crosses zero. Adding f(x) / fPrime(x) instead of subtracting sends each guess the wrong way and the method runs off. Note how few steps the tests allow: 5 steps reach 12 digits, where bisection would need about 40.
8. Linear approximation, related rates and Newton's method · When Newton’s method fails · QuizWhat is a robust way to combine the two root finders you know?A. Use bisection to get close, then switch to Newton’s methodBisection always closes in, but slowly; Newton’s method is fast only once it is close. Bisecting to a small bracket and then taking Newton steps (falling back to bisection if a step leaves the bracket) is what safeguarded library root finders do. Brent’s method, a common one, works the same way, with fast steps that need no derivative.
8. Linear approximation, related rates and Newton's method · Practice problems · ProblemA cube’s side is measured as cm, with a possible error of cm. Use a differential to estimate the possible error in its volume, then give that as a percentage of the volume.Error in the volume 15 cm³; Relative error 1.5 %
As a check: the side’s relative error is , and cubing triples it to .
8. Linear approximation, related rates and Newton's method · Practice problems · ProblemA m ladder leans against a wall, and its foot is pulled away from the wall at m/s. How fast is the top moving when the foot is m from the wall? Give , where is the height of the top (it is negative, since the top falls).-5/6 ≈ −0.833333 m/s
When , . Substitute, with :
8. Linear approximation, related rates and Newton's method · Practice problems · ProblemUse Newton’s method on , starting from . Find and . 2.1; 2.1 - 0.061/11.23 ≈ 2.09457
The root is , so already has five correct digits. This is the very equation Newton used to demonstrate his method.
8. Linear approximation, related rates and Newton's method · Practice problems · ProblemWater pours at m³/min into a tank shaped like a cone, point down, m deep with a top radius of m. How fast is the water level rising when the water is m deep? (A cone’s volume is .)8/(9*pi) ≈ 0.282942 m/min
By similar triangles , so the water’s volume is a function of its depth alone:
Substitute and :
8. Linear approximation, related rates and Newton's method · More practice problems · ProblemUse the linearisation of at (that is, ) to estimate . Remember to work in radians.1/2 + sqrt(3)*pi/360 ≈ 0.515115
is radians, so :
The true value is . Stepping by instead of , as if degrees were radians, gives : more than any sine can be.
8. Linear approximation, related rates and Newton's method · More practice problems · ProblemA ball’s radius is measured with a possible error of . (a) About how large can the relative error in its volume be? (b) To know the volume to within , how precisely must the radius be measured?(a) 6 %; (b) 1 %
(a) .
(b) needs : the radius must be measured to within .
9. Area and the definite integral · Sigma notation for long sums · QuizWhat is ?C. The terms are (for ), which add to . That is : the sum of the first odd numbers is always . The tempting is only the last term.
9. Area and the definite integral · Sigma notation for long sums · ProblemUse the sum formulas to find (a) and (b) .(a) 670; (b) 715
9. Area and the definite integral · Riemann sums in general · Code challengeWrite riemann(f, a, b, n, rule), the left, right or midpoint Riemann sum of f on [a, b] with n strips. Rule is an enum class: a type whose only values are the ones it lists, Rule::left, Rule::right and Rule::midpoint.One solution:
Solution
1#include<functional>23enumclassRule{left,right,midpoint};45doubleriemann(std::function<double(double)> f,6double a,double b,int n,Rule rule){7double dx =(b - a)/ n;8double shift =0.5; // the midpoint9if(rule == Rule::left) shift =0;10if(rule == Rule::right) shift =1;11double sum =0;12for(int i =0; i < n; i++){13 sum +=f(a +(i + shift)* dx)* dx;14}15return sum;16}
Every rule visits strip i once; only the point where the height is taken moves: i * dx, (i + 1) * dx or (i + 0.5) * dx past a. A frequent slip is looping i from 0 to n inclusive for the right sum, which adds an extra strip beyond b. Multiplying by dx inside the loop or once at the end gives the same answer. Notice 1.0 / 3 in the tests: 1 / 3 divides two ints and is 0.
9. Area and the definite integral · Riemann sums in general · ProblemWork out the left, right and midpoint sums for on with strips. 3.75; 5.75; 4.625
. At the edges is ; at the midpoints it is .
The exact area is (module 10 shows how). The midpoint sum is off by only ; the left and right sums by about and .
9. Area and the definite integral · Area below the axis counts as negative · QuizWhat is ?A. is an odd function: its graph on the left of is its graph on the right turned upside down. The area below the axis on exactly cancels the area above it on . The total shaded area is , but the integral counts the left part as negative.
9. Area and the definite integral · Properties of the integral · QuizGiven and , what is ?B. Splitting at : . Reversing the limits flips the sign, so , and the constant 3 comes out: . Missing the reversed limits gives .
9. Area and the definite integral · Displacement and distance from velocity · QuizOver the 8 seconds, the displacement is m. What is the total distance travelled?C. mForward, from to s: a triangle of base and height , area m. Backward, from to s: a triangle of base and depth , area m. Displacement is m; distance is m.
9. Area and the definite integral · Displacement and distance from velocity · Code challengeWrite displacement(v, a, b, n) and distance(v, a, b, n): midpoint Riemann sums with n strips of v and of its absolute value.One solution:
Solution
1#include<cmath>2#include<functional>34usingFn= std::function<double(double)>;56doublemidpoint(Fn f,double a,double b,int n){7double dt =(b - a)/ n;8double sum =0;9for(int i =0; i < n; i++) sum +=f(a +(i +0.5)* dt)* dt;10return sum;11}1213doubledisplacement(Fn v,double a,double b,int n){14returnmidpoint(v, a, b, n);15}1617doubledistance(Fn v,double a,double b,int n){18returnmidpoint([=](double t){return std::abs(v(t));}, a, b, n);19}
Distance is the integral of speed, , so the only difference is wrapping v in std::abs before summing: the lambda [=](double t) { return std::abs(v(t)); } is the speed, built from v. Taking std::abs of the final displacement instead gives , not : the cancellation has already happened by then.
9. Area and the definite integral · Practice problems · ProblemWrite the right sum for as a formula in . Then find the integral as its limit.4*(n + 1)*(2*n + 1)/(3*n^2); 8/3 ≈ 2.66667
That is times the under on : the region is twice as wide, and at matching points four times as tall.
9. Area and the definite integral · Practice problems · ProblemFind these integrals from areas you know: (a) and (b) .(a) 9*pi/2 ≈ 14.1372; (b) 4
(a) The region is half a disc of radius :
(b) Below the axis, from to , is a triangle with base and depth . Above it, from to , is one with base and height :
9. Area and the definite integral · Practice problems · ProblemYou know , and . Find (a) , (b) and (c) .(a) 9; (b) 21; (c) -3
9. Area and the definite integral · Practice problems · ProblemA lift moves with velocity m/s for s, with up counted as positive. Find its displacement, and the total distance it travels.Displacement -10 m; Distance 26 m
Up, from to s: a triangle with base and height , area m. Down, from to s: a triangle with base and depth , area m.
It ends m below where it started, having travelled m.
9. Area and the definite integral · More practice problems · ProblemThe area under from to is exactly . Work out the midpoint sums and for it.pi*sqrt(2)/2 ≈ 2.22144; pi/2*(sin(pi/8) + sin(3*pi/8)) ≈ 2.05234
The errors are about and : doubling divided the error by about , as it should for a midpoint sum.
9. Area and the definite integral · More practice problems · ProblemFind without any sums.20
is odd, so its area below the axis on cancels its area above on . The constant is a rectangle wide and tall.
10. The fundamental theorem of calculus · Part 1: the area’s rate of growth is the height · QuizLet . What are and ?A. , : no width, no area. By part 1, , so . No integral needs computing. Differentiating to get is the slip: part 1 gives back the integrand itself, not its derivative.
10. The fundamental theorem of calculus · Part 1 with the chain rule · Fill the blanksDifferentiate (for ). Use ln and ^.1: 3x^2, 2: x^3, 3: 9x^2 ln xPut the upper limit into the integrand, , and multiply by its derivative . Since , the result is . Forgetting the is the same mistake as forgetting the inner derivative in any chain rule.
10. The fundamental theorem of calculus · Part 1 with the chain rule · ProblemLet . Find , and .2*x/(1 + x^4); 1
The upper limit is , with :
. The lower limit, , makes no difference to the derivative.
10. The fundamental theorem of calculus · Antiderivatives, and the constant C · QuizWhich function is an antiderivative of ?A. Check by differentiating: by the chain rule, and the vanishes. Checking an antiderivative by differentiating it is always the quickest test. Undoing the chain rule in general is substitution (module 11).
10. The fundamental theorem of calculus · A table of antiderivatives · QuizWhat is ?B. You need a function whose derivative is . Since , . The minus sign is the one people drop: derivative and antiderivative of the trig functions go in opposite directions round the cycle.
10. The fundamental theorem of calculus · Working with indefinite integrals · Fill the blanksFind . Write powers with ^.1: x^6, 2: -e^x, 3: CRaise the power by one and divide by the new power: . is the one power the rule can’t do, and gives . is its own antiderivative. The says that the answer is a family, not a single function.
10. The fundamental theorem of calculus · Evaluating a definite integral without slips · Find the bugThis computes . One line is wrong. Which?Line 2: F(x) = x^3 - x^2Line 2 differentiates instead of integrating. The antiderivative raises each power: . Then . A quick check catches it: differentiating must give back , and .
10. The fundamental theorem of calculus · Evaluating a definite integral without slips · QuizWhat is ?A. , with antiderivative . Then . forgets to subtract the value at the lower limit.
10. The fundamental theorem of calculus · Evaluating a definite integral without slips · ProblemEvaluate .20/3 ≈ 6.66667
Bracket the whole of before subtracting it: every sign inside flips.
10. The fundamental theorem of calculus · The net change theorem · QuizA town grows at people per year. How many people does it gain from to years?C. . is the growth rate at , people per year, not a number of people. forgets that the rate keeps rising.
10. The fundamental theorem of calculus · Both parts of the theorem, in code · Code challengeWrite accumulate(f, a, n). It returns the function , worked out with a midpoint sum of n strips each time it is called. The last test checks part 1: the slope of is .One solution:
Solution
1#include<functional>23usingFn= std::function<double(double)>;45Fnaccumulate(Fn f,double a,int n){6return[=](double x){7double dt =(x - a)/ n;8double sum =0;9for(int i =0; i < n; i++) sum +=f(a +(i +0.5)* dt)* dt;10return sum;11};12}
Each call integrates from a to its own x, so the strip width (x - a) / n is worked out inside the returned lambda, not once outside. The last test is the fundamental theorem made numerical: a central difference of the accumulated area gives back the integrand.
10. The fundamental theorem of calculus · Both parts of the theorem, in code · Code challengePolynomials are vectors of coefficients, lowest power first, as in module 5. Write integratePoly(c), the antiderivative with constant 0, and definite(c, a, b), the integral from a to b by part 2.One solution:
Solution
1#include<cmath>2#include<vector>34std::vector<double>integratePoly(const std::vector<double>& c){5 std::vector<double> F ={0};6for(int k =0; k <int(c.size()); k++) F.push_back(c[k]/(k +1));7return F;8}910doublevalue(const std::vector<double>& c,double x){11double sum =0;12for(int k =0; k <int(c.size()); k++) sum += c[k]* std::pow(x, k);13return sum;14}1516doubledefinite(const std::vector<double>& c,double a,double b){17 std::vector<double> F =integratePoly(c);18returnvalue(F, b)-value(F, a);19}
The term becomes , so every coefficient moves up one place and is divided by its new power; the constant 0 goes in front. In definite the constant would cancel anyway, which is why part 2 lets you pick any antiderivative. Dividing by k instead of k + 1 divides the constant term by zero, which for a double gives inf rather than an error. Here c[k] / (k + 1) is a double over an int, so it keeps its fraction; two ints, as in 1 / 3, would not.
10. The fundamental theorem of calculus · Practice problems · ProblemEvaluate (a) and (b) .(a) 3; (b) e - 1 + pi/4 ≈ 2.50368
10. The fundamental theorem of calculus · Practice problems · ProblemFind the function with and . What is ?2*x^3 - 2*x^2 + x + 4; 14
10. The fundamental theorem of calculus · Practice problems · ProblemWater flows out of a tank at litres per minute, minutes after a valve opens. The tank holds litres when it opens. How much flows out in the first minutes, and how much is left then?Flowed out 216 L; Left 284 L
Here , and . The tank had L, so L are left.
10. The fundamental theorem of calculus · Practice problems · ProblemA particle moves with velocity m/s. Over s, find its displacement and the total distance it travels.Displacement 4/3 ≈ 1.33333 m; Distance 4 m
An antiderivative of is , with , , and .
on , on and on , so the middle piece counts with its sign flipped:
10. The fundamental theorem of calculus · More practice problems · ProblemFind in each: (a) , and (b) , with .(a) 3; (b) e^2 ≈ 7.38906
10. The fundamental theorem of calculus · More practice problems · ProblemLet . Where does have a local minimum, and what is its value there? 2; there -16/3 ≈ −5.33333
goes to at (and to at , a local maximum). So the local minimum is at .
The accumulated area keeps falling while the integrand is negative, and starts to grow once turns positive at .
11. Substitution and integration by parts · Every derivative rule runs backwards · QuizWhich function is an antiderivative of ?A. Differentiate each one. By the chain rule, , which is exactly the integrand. The others give a sign or a factor of 2 wrong, or extra terms from the product rule. Recognising the inner function and its derivative sitting next to it is the whole idea of the next slide.
11. Substitution and integration by parts · Substitution undoes the chain rule · QuizWhat is ?A. Take , so and . The integral becomes . The usual slip is the minus sign: the derivative of is . Differentiate to check: .
11. Substitution and integration by parts · Substitution undoes the chain rule · ProblemFind the antiderivative of with . Then use it to work out .((x^3 + 1)^5 - 1)/15; 31/15 ≈ 2.06667
Take , so and :
At this is , so needs : .
11. Substitution and integration by parts · With a definite integral, change the limits too · QuizSomeone substitutes in but keeps the limits 0 and 1. What do they get?A. , the area under over the wrong interval. The answer is : as runs from 0 to 1, runs from 1 to 2. Either change the limits, or put back before using the original ones; mixing the two is the mistake.
11. Substitution and integration by parts · With a definite integral, change the limits too · ProblemEvaluate exactly, changing the limits as you substitute.e - 1 ≈ 1.71828
Take , so . When , ; when , .
Swapping the limits changes the sign, which cancels the minus from .
11. Substitution and integration by parts · Integration by parts undoes the product rule · QuizWhat is ?A. With and : , , so the integral is . The tempting forgets that , and the minus in front makes it plus. Differentiate to check: .
11. Substitution and integration by parts · Integration by parts undoes the product rule · ProblemEvaluate by parts.pi ≈ 3.14159
Take and , so and :
11. Substitution and integration by parts · Trig identities turn powers into things you can integrate · QuizWhich are antiderivatives of ? Choose every one.A. ; B. ; C. The first three are all right: substitute , or , or use . They look different but differ only by constants ( and differ by ), which the absorbs. Two correct answers in different forms are normal in integration; differentiate both to be sure. The last one fails: its derivative is .
11. Substitution and integration by parts · Partial fractions split a fraction into easy pieces · QuizSplit . What are and ?A. , . Cover and put : . Cover and put : . So . Forgetting that comes out negative is the usual slip.
11. Substitution and integration by parts · Try it: cover-up and checking by differentiating · Code challengeWrite coverUp(p, q, a, b): it returns the pair {A, B} with , for . A std::pair<double, double> holds two numbers; auto [A, B] = coverUp(…) unpacks them.One solution:
Solution
1#include<utility>23std::pair<double,double>coverUp(double p,double q,4double a,double b){5 // Cover (x - a), put x = a in what is left; then the same for b.6double A =(p * a + q)/(a - b);7double B =(p * b + q)/(b - a);8return{A, B};9}
Multiply both sides by : you get . At the term vanishes, leaving ; is the same with the roles swapped. The common mistake is the sign of the denominator: for it is , not . The last test writes 5.0 / (3 * -2): with 5 / it would divide two ints and expect 0.
11. Substitution and integration by parts · Try it: cover-up and checking by differentiating · Code challengeWrite isAntiderivative(F, f, xs): it returns true when, at every point in xs, the central difference (F(x + h) - F(x - h)) / (2 * h) with h = 1e-5 is within 1e-6 of f(x).One solution:
Solution
1#include<cmath>2#include<functional>3#include<vector>45usingFn= std::function<double(double)>;67boolisAntiderivative(Fn F,Fn f,const std::vector<double>& xs){8double h =1e-5;9for(double x : xs){10double slope =(F(x + h)-F(x - h))/(2* h);11if(std::abs(slope -f(x))>=1e-6)returnfalse;12}13returntrue;14}
The central difference has an error proportional to , about here, far below the tolerance, while a wrong antiderivative is off by a visible amount. Returning false at the first failing point stops the loop there; only after every point has passed is the answer true. A one-sided difference would be off by about , , and reject correct answers.
11. Substitution and integration by parts · A strategy for choosing a method · QuizWhich method suits , and with which ?A. By parts, with and Logarithms come first in LIATE: differentiating gives , which cancels against , leaving . The result is . The other way round you would need to integrate and get a messier integral. Substitution fails because , the derivative of , is not a factor.
11. Substitution and integration by parts · A strategy for choosing a method · Put in orderPut the steps of integrating by parts in order.1. Choose and 2. Work out and 3. Write 4. Integrate what is left: 5. Differentiate the answer to check it gives Choose, then compute and (integrating needs the factor ), then apply the formula, then finish the simpler integral, then check. Checking last is not optional: differentiating gives .
11. Substitution and integration by parts · Some integrals have no formula at all · QuizWhich of these has an elementary antiderivative?A. With , , so . The factor is exactly what substitution needs. Without it, has no elementary antiderivative; you integrate it with a series (a later module) or numerically (the module after next).
11. Substitution and integration by parts · Practice problems · ProblemEvaluate : factor the bottom, split the fraction into , and integrate. 3; 1; The integral ln(81/2) ≈ 3.7013
. Cover-up: and .
11. Substitution and integration by parts · Practice problems · ProblemEvaluate .2/3 ≈ 0.666667
With , , and runs from 1 down to 0:
11. Substitution and integration by parts · Practice problems · ProblemFind the function with for and .x^2*ln(x)/2 - x^2/4 + 1/4
Take and , so and :
At : , so and .
Check by differentiating: .
11. Substitution and integration by parts · Practice problems · ProblemWater flows into a tank at litres per minute, minutes after a tap is opened. How much water flows in during the first 4 minutes? Give it exactly or to 3 significant figures.Water 4 - 12*e^(-2) ≈ 2.37598 L
The water is the integral of the rate. By parts, and , so and :
12. Areas, volumes and averages · The area between two curves is top minus bottom · QuizWhat is the area between and the -axis?A. The parabola meets the axis where , at . Then . is only the right half; finding the limits first, from where the curves meet, is the step people skip.
12. Areas, volumes and averages · The area between two curves is top minus bottom · ProblemFind the area of the region between the parabola and the line . First find where they meet.Left crossing, -2; Right crossing, 1; Area 9/2 ≈ 4.5
gives , so : and . At the parabola is at 4 and the line at 2, so the parabola is on top.
12. Areas, volumes and averages · When the curves cross, split the integral · QuizWhat is , without splitting?A. . The piece where is on top and the piece where is on top cancel exactly. That is a correct net integral but the wrong area: the region plainly has area about .
12. Areas, volumes and averages · Volumes by slicing: disks · QuizWhat is the volume of that bowl, for , spun around the -axis?A. . The tempting comes from integrating itself instead of its square: the area of a disk is , so the radius must be squared.
12. Areas, volumes and averages · Volumes by slicing: disks · ProblemThe arch of , for , spins around the -axis. Find the volume of the solid it sweeps out.Volume pi^2/2 ≈ 4.9348
12. Areas, volumes and averages · Washers have a hole in the middle · QuizWhich integral gives the volume when the region between and , for , spins around the -axis?A. Outer radius , inner radius : the washer is . The tempting squares the difference of the radii, which is the area of a disk as thick as the region, not of a ring. and are different numbers.
12. Areas, volumes and averages · Shells: slicing parallel to the axis · QuizThe region under for spins around the -axis. What is its volume, by shells?A. . is : disks around the x-axis, a different solid. Pick the method by the axis: shells have radius when spinning around the -axis.
12. Areas, volumes and averages · The average value of a function · QuizWhat is the average value of on ?A. . Not , the average of the end values and : that only works for straight lines. The curve spends most of the interval low down, so its average is lower.
12. Areas, volumes and averages · The average value of a function · Code challengeWrite average(f, a, b, n): the average value of f on [a, b], from a Riemann sum with n equal strips, each measured at its midpoint.One solution:
Solution
1#include<functional>23doubleaverage(std::function<double(double)> f,4double a,double b,int n){5double width =(b - a)/ n;6double area =0;7for(int i =0; i < n; i++){8 area +=f(a +(i +0.5)* width)* width;9}10return area /(b - a);11}
The sum of f(midpoint) * width approximates the integral, and dividing by b - a turns the area into an average. Since every strip has the same width, this is the same as the plain average of the sampled values: the continuous average really is the limit of ordinary averages. Forgetting the division gives the area, 9, instead of the average, 3.
12. Areas, volumes and averages · The length of a curve · Code challengeWrite arcLength(f, a, b, n): split [a, b] into n equal steps and add the straight-line distances between consecutive points on the curve (use std::hypot(dx, dy), from <cmath>, which is ).One solution:
Solution
1#include<cmath>2#include<functional>34doublearcLength(std::function<double(double)> f,5double a,double b,int n){6double dx =(b - a)/ n;7double length =0;8for(int i =0; i < n; i++){9double x = a + i * dx;10 length += std::hypot(dx,f(x + dx)-f(x));11}12return length;13}
Each chord is , exactly the of the formula before the limit; adding chords is how arc length is defined in the first place. The chords cut corners, so the sum is always a little short, and the shortfall shrinks as n grows. The starter returns b - a, the length of a flat line: right only when the curve is flat. In the tests, 2.0 / 3 and 14.0 / 3 are written with a .0 on purpose: 2 / 3 divides two ints, and is 0.
12. Areas, volumes and averages · Work done by a varying force · QuizA spring with N/m is stretched from m to m. How much work does that take?A. J J. J would be , as if the spring started relaxed: the first m was already stretched, and the later centimetres are the expensive ones because the force is bigger there.
12. Areas, volumes and averages · A preview: probability as area · QuizFor the density on , what is ?A. First, it is a density: and . Then . Not : the density grows with , so most of the probability sits in the right half. The statistics course builds everything on this idea.
12. Areas, volumes and averages · Practice problems · ProblemThe region between and spins around the -axis. Find the volume of the solid.Volume 64*pi/15 ≈ 13.4041
The curves meet at and , and between them : the outer radius is and the inner one .
12. Areas, volumes and averages · Practice problems · ProblemThe region under and above the -axis spins around the -axis. Find its volume by shells.Volume pi/6 ≈ 0.523599
12. Areas, volumes and averages · Practice problems · ProblemOver a 12-hour day the temperature is degrees Celsius, hours after 6 am. What is the average temperature from to ?Average 10 + 12/pi ≈ 13.8197 °C
The temperature runs from 10 to 16 °C, but the average is not 13: the sine arch spends more of the day near its top than near its ends.
12. Areas, volumes and averages · More practice problems · ProblemFind the length of the curve from to .Length 8*(10*sqrt(10) - 1)/27 ≈ 9.07342
The straight line from to is long: the curve is a little longer, as it must be.
12. Areas, volumes and averages · More practice problems · ProblemA force of holds a spring stretched beyond its natural length. Find its spring constant, and the work needed to stretch it from to beyond its natural length. 300 N/m; Work 12 J
, so .
12. Areas, volumes and averages · More practice problems · ProblemA random quantity has density on , and 0 elsewhere. Find , the probability , and the mean .1/9 ≈ 0.111111; 8/27 ≈ 0.296296; 9/4 ≈ 2.25
, so .
The mean, , is past the middle of because the density grows with .
13. Numerical integration · Computers integrate by sampling · QuizWhen do you need to integrate numerically? Choose every one.A. The antiderivative is not elementary, like for ; B. You only have measured values, not a formula; D. The antiderivative exists but would take pages of algebraWith no formula, or only data, sampling is the only option; and even when a formula exists, a good numerical method with an error estimate is often faster and safer than pages of algebra. For the antiderivative is immediate and exact, so there is no reason to approximate.
13. Numerical integration · The trapezoid rule joins the samples with straight lines · Code challengeWrite trapezoid(f, a, b, n): the trapezoid rule with n equal pieces.One solution:
Solution
1#include<functional>23doubletrapezoid(std::function<double(double)> f,4double a,double b,int n){5double h =(b - a)/ n;6double sum =(f(a)+f(b))/2;7for(int i =1; i < n; i++){8 sum +=f(a + i * h);9}10return sum * h;11}
Start with the two half-weighted ends, add the inside points once each, and multiply by at the end (one multiplication instead of ). A common slip is a loop from 0 to n, which counts the ends fully as well: the answer then comes out too big by . For a convex curve like the chords lie above it, so the rule overestimates.
13. Numerical integration · The trapezoid rule joins the samples with straight lines · ProblemUse the trapezoid rule with to estimate , and find its error: the estimate minus the exact value, 4. 4.25; Error 0.25
The samples are , , , and .
The exact value is , so the error is : is convex on , and the chords lie above it.
13. Numerical integration · The midpoint rule samples the middle of each piece · Fill the blanksComplete the midpoint rule.1: n, 2: 0.5, 3: hThe step is . Piece runs from to , so its centre is at . Every rectangle has width , so multiplying once at the end is enough. No end point is ever sampled, which also makes the rule usable when blows up at an end.
13. Numerical integration · The midpoint rule samples the middle of each piece · QuizFor some integral, is too big. About what would you expect to be off by?A. too smallFor smooth and small , the trapezoid error is about and the midpoint error about : half the size, opposite sign. That suggests combining them so the errors cancel, which is exactly the next slide.
13. Numerical integration · The midpoint rule samples the middle of each piece · ProblemNow use the midpoint rule with on the same integral, . What is , and what is its error? 3.875; Error −0.125
The centres are , , and , whose cubes are , , and .
The error is : half the trapezoid error, , with the opposite sign.
13. Numerical integration · Simpson's rule fits parabolas · Find the bugThis Simpson's rule gives wrong answers even for . Which line is wrong?Line 6: int w = i % 2 == 1 ? 4 : 2;The odd-numbered points, the middles of each pair, get weight 4; the even inside points, shared by two pairs, get 2. Swapped, the weights add up to the wrong total: with and it gives instead of . Testing with , where every rule must give , catches weight mistakes at once.
13. Numerical integration · Simpson's rule fits parabolas · Code challengeWrite simpson(f, a, b, n): Simpson's rule with n pieces. It returns a std::optional<double>: the estimate, or std::nullopt (no answer) when n is odd.One solution:
Solution
1#include<functional>2#include<optional>34std::optional<double>simpson(std::function<double(double)> f,5double a,double b,int n){6if(n %2!=0)return std::nullopt; // n must be even7double h =(b - a)/ n;8double sum =f(a)+f(b);9for(int i =1; i < n; i++){10 sum +=(i %2==1?4:2)*f(a + i * h);11}12return sum * h /3;13}
The ends get weight 1, odd inside points 4 and even inside points 2, and the sum is multiplied by . With , Simpson is already within about of 2; the trapezoid rule needs more than 100 pieces for that. An odd leaves one piece without a partner, so the parabolas do not fit, and the honest thing is to refuse: std::nullopt says “no answer” without stopping the program, and *s reads the number out of an answer that has one.
13. Numerical integration · Simpson's rule fits parabolas · ProblemEstimate , which is exactly 2, with (so ): by the trapezoid rule, and by Simpson's rule. Give exactly or to 4 decimal places.pi*(1 + sqrt(2))/4 ≈ 1.89612; pi*(2*sqrt(2) + 1)/6 ≈ 2.00456
The samples are .
From the same five samples, the trapezoid rule is off by about and Simpson by about , over twenty times less.
13. Numerical integration · Error and order: what halving the step buys · QuizSimpson's rule with has an error of . About what is the error with ?A. Order 4: halving divides the error by , and . is what an order-2 rule would give. Measuring the ratio of errors as doubles is how you check, in practice, that code implements the rule you think it does.
13. Numerical integration · Adaptive methods spend samples where they are needed · QuizWhy does adaptive Simpson split the pieces near 0 more often for on ?A. Its error estimate is large there, because curves sharply near 0The derivatives of blow up at 0, so a parabola fits it badly there, and the halves disagree with the whole. Far from 0 it is gentle, the estimates agree, and the method stops early. This is how library integrators (such as QUADPACK, behind many scientific tools) handle awkward functions without being told where the trouble is.
13. Numerical integration · Monte Carlo: integrate by random sampling · QuizA Monte Carlo estimate with samples has an error of about . How many samples for ?A. The error goes like : ten times smaller error needs ten times bigger, so a hundred times bigger. That is why Monte Carlo is the last resort in one dimension and the first choice in fifty.
13. Numerical integration · Practice problems · ProblemFor one smooth integral, has an error of . For another, (Simpson's rule) has an error of . Estimate the error of for the first, and of for the second.Error of 0.0002; Error of 0.0000125
From to , becomes 4 times smaller, so an error of order shrinks by .
13. Numerical integration · Practice problems · ProblemHow many trapezoids guarantee that is within of ? Use the bound , with on , and give the smallest whole . 48
So is the smallest the bound guarantees. The real error is a little smaller, because the bound uses the largest value of , , all along the interval.
13. Numerical integration · Practice problems · ProblemA car starts from rest, and its speed is logged every 10 seconds: m/s at s. Estimate how far it travels in those 40 seconds, by the trapezoid rule and by Simpson's rule.Trapezoid 690 m; Simpson 700 m
The speeds rise by less each time (12, 8, 4, 2), so the curve bends down: the chords lie below it and the trapezoid estimate is a little low, while Simpson follows the bend.
13. Numerical integration · Practice problems · ProblemA Monte Carlo estimate with random samples has an error of about . About how many samples bring the error down to ? 40000
The error is about . To make it 4 times smaller, must be 4 times bigger, so must be times bigger:
14. Infinity: L'Hôpital and improper integrals · Some limits cannot be read off · QuizWhich of these forms is not indeterminate?A. A top shrinking to 0 over a bottom growing without bound can only go to 0: both effects push the same way. In the others the two parts pull in opposite directions, and which wins depends on the functions. is the sneaky one: , but , because the base is only near 1.
14. Infinity: L'Hôpital and improper integrals · L'Hôpital's rule compares the speeds · QuizWhat is ?A. It is , so differentiate: , still . Again: . Stopping after one step and saying " at 0 is 0" is the usual slip: that was still indeterminate.
14. Infinity: L'Hôpital and improper integrals · L'Hôpital's rule compares the speeds · QuizSomeone computes with L'Hôpital: . What is the real limit?A. At the fraction is , nothing indeterminate about it, so plugging in is the answer. The rule only holds for and ; used on anything else it gives nonsense. Always check the form first.
14. Infinity: L'Hôpital and improper integrals · L'Hôpital's rule compares the speeds · ProblemFind .2
At the top is and the bottom is 0: the form is .
14. Infinity: L'Hôpital and improper integrals · Rewrite the other forms as a fraction · QuizWhat is ?A. Take logs: , as above. So . It looks as if to any power should be 0, but the exponent is shrinking too, and the two effects balance at 1. Forgetting to undo the log at the end, and answering 0, is the classic slip.
14. Infinity: L'Hôpital and improper integrals · Rewrite the other forms as a fraction · ProblemFind .e^3 ≈ 20.0855
14. Infinity: L'Hôpital and improper integrals · Logs are slow, powers are steady, exponentials win · QuizWhat is ?A. Any power of a log loses to any positive power of . To see it, put : the fraction is , a power over an exponential, which goes to 0. The table hides this for small : at the top is about 98 and the bottom 10. Growth rates are about the long run.
14. Infinity: L'Hôpital and improper integrals · An integral over an infinite interval is a limit · QuizWhat is ?A. . Exponential decay is fast enough for a finite area. Answering comes from dividing by the wrong way: the antiderivative of is .
14. Infinity: L'Hôpital and improper integrals · An integral over an infinite interval is a limit · ProblemEvaluate .pi/2 ≈ 1.5708
Far out the curve falls like , a integrand, so a finite area is what you should expect.
14. Infinity: L'Hôpital and improper integrals · The p-integrals: the yardstick for convergence · Code challengeWrite pIntegral(p): the value of the integral of from 1 to infinity, or INFINITY (from <cmath>) when it diverges.One solution:
Solution
1#include<cmath>23doublepIntegral(double p){4 // The antiderivative is x^(1 - p) / (1 - p); it only5 // shrinks to 0 at infinity when 1 - p is negative.6if(p <=1)return INFINITY;7return1/(p -1);8}
For , . When , and the value is . When , . is the logarithm, which also grows without bound. Writing 1 / (p - 1) for every would return for : a negative area for a positive function, which should make you suspicious.
14. Infinity: L'Hôpital and improper integrals · Integrands that blow up are improper too · QuizSomeone writes . What is wrong?A. blows up at , inside the interval, and the integral divergesA positive function cannot have a negative integral: that is the alarm. The fundamental theorem needs continuous on the whole interval, and is not defined at 0. Split at 0: is a -integral with , so it diverges, and so does the whole thing. Always look for points where the integrand blows up inside the interval.
14. Infinity: L'Hôpital and improper integrals · Integrands that blow up are improper too · ProblemEvaluate . The integrand goes to at .-1
As , and (by L'Hôpital, earlier in this module). So the integral is : the region lies below the axis, with area 1.
14. Infinity: L'Hôpital and improper integrals · Compare with something you know · QuizWhich of these converge? Choose every one.A. ; C. and , both under a convergent integral. behaves like for large (its antiderivative is ), and is : both diverge. What matters is how the integrand behaves far out, not its first few values.
14. Infinity: L'Hôpital and improper integrals · Compare with something you know · Code challengeWrite improper(f, a, n): approximate the integral of f from a to infinity by substituting , which maps t in [0, 1) onto [a, ∞), then using the midpoint rule with n pieces on .One solution:
Solution
1#include<functional>23doubleimproper(std::function<double(double)> f,double a,int n){4auto g =[=](double t){5returnf(a + t /(1- t))/((1- t)*(1- t));6};7double h =1.0/ n;8double sum =0;9for(int i =0; i < n; i++) sum +=g((i +0.5)* h);10return sum * h;11}
The substitution squeezes the infinite interval into ; is the stretch factor. The midpoint rule never samples , where would be infinite. This only works when the integral converges: try it on and the answer keeps growing with n, which is the numerical sign of divergence. Forgetting the factor gives the integral of the wrong function. And the step is 1.0 / n: with an intn, 1 / n is 0.
14. Infinity: L'Hôpital and improper integrals · Gabriel's horn: finite volume, infinite surface · QuizWhy is the horn's volume finite while its surface is not?A. Volume uses (the radius squared), which falls fast enough; area uses about , which does notEach disk has area , a integrand; each ring of surface has area about , a integrand. One power of is the whole difference. Volume and area are not comparable at all: they are measured in different units.
14. Infinity: L'Hôpital and improper integrals · Practice problems · ProblemEvaluate .1/ln(2) ≈ 1.4427
With , ; gives , and as .
Compare , which diverges: one more power of the log makes the difference.
14. Infinity: L'Hôpital and improper integrals · Practice problems · ProblemA drug is absorbed into the blood at a rate of milligrams per hour, hours after a dose. How much is absorbed in the first 5 hours, and how much in total, if absorption goes on forever?First 5 hours 250*(1 - e^(-1)) ≈ 158.03 mg; In total 250 mg
About 63% of the total arrives in the first 5 hours.
14. Infinity: L'Hôpital and improper integrals · Practice problems · ProblemThe region under , for , spins around the -axis: a solid that goes on forever. Find its volume.Volume pi/2 ≈ 1.5708
Finite: the radius shrinks exponentially, far faster than the of Gabriel's horn.
15. Sequences and series · A sequence is a list that goes on forever · QuizWhat is the limit of ?A. Divide top and bottom by : . For large only the highest powers matter. The and the affect the first terms, never the limit.
15. Sequences and series · A series is the limit of its partial sums · QuizA series has partial sums . What is its sum, and what is its first term?A. Sum , first term The sum is . The first term is . Keep the two sequences apart: the terms , and the partial sums . Here the terms are , which go to 0, while the partial sums go to 2.
15. Sequences and series · A series is the limit of its partial sums · ProblemUsing , find the partial sum of , and the sum of the series.17/15 ≈ 1.13333; Sum 3/2 ≈ 1.5
So . As the last two terms vanish, and the sum is .
15. Sequences and series · Geometric series: the one you can always sum · QuizWhat is ?A. The first term is (the sum starts at ) and , so the sum is . The tempting is , which assumes the series starts with 1, at . Always check where the index starts.
15. Sequences and series · Geometric series: the one you can always sum · ProblemFind . Then write the repeating decimal as a fraction, by treating it as a geometric series.5/3 ≈ 1.66667; 3/11 ≈ 0.272727
15. Sequences and series · If the terms do not shrink to zero, the series diverges · QuizWhat does the divergence test say about and about ?A. Nothing about the first; the second diverges, so that series diverges: you keep adding numbers close to 1. , so the test is silent; the series happens to diverge, but you need another argument (grouping, or the integral test next) to show it. "The terms go to 0, so it converges" is the classic false step.
15. Sequences and series · The integral test, and the p-series · QuizWhich of these converge? Choose every one.A. ; C. and (since ) are above 1, so they converge; and do not. converges absurdly slowly, but it converges: the line is sharp at .
15. Sequences and series · The integral test, and the p-series · Code challengeWrite partialSum(term, N): the sum of term(n) for n from 1 to N. term takes n as a double, so a term like 1 / n divides with decimals.One solution:
Solution
1#include<functional>23doublepartialSum(std::function<double(double)> term,int N){4double sum =0;5for(int n =1; n <= N; n++) sum +=term(n);6return sum;7}
A loop from 1 to N inclusive; starting at 0 would divide by zero for , and with a double that gives inf rather than an error, so the sum would be inf. The tests show the two behaviours: settles (after terms it is within of , since the tail is about ), while the harmonic sum keeps growing like , with the Euler–Mascheroni constant. A million terms of a divergent series still only reach about 14.4: you cannot see divergence by adding terms. Had term taken an int, 1 / n would be integer division, 0 for every n above 1.
15. Sequences and series · Comparison tests: measure against a known series · QuizUsing limit comparison, what does do?A. Converges: it behaves like Keep the biggest powers: . Then , a positive finite limit, so it converges like the series. "Its terms go to 0" is true but proves nothing, as the harmonic series shows.
15. Sequences and series · Ratio and root tests: is it eventually geometric? · QuizWhat does the ratio test say about ?A. Nothing: , so the test is silent, even though the series converges (it is a -series). The same comes from the divergent . Each ratio being below 1 is not enough; the limit must be below 1. For powers of , use -series and comparison instead.
15. Sequences and series · Alternating series converge if the terms shrink · Code challengeWrite alternating(N): it returns an Estimate holding sum, the partial sum of 1 - 1/2 + 1/3 - ... up to the term , and bound, the most it can be off by, .One solution:
Solution
1structEstimate{2double sum;3double bound;4};56Estimatealternating(int N){7double sum =0;8for(int n =1; n <= N; n++){9double sign = n %2==1?1:-1;10 sum += sign / n;11}12return{sum,1.0/(N +1)};13}
Odd add, even subtract. The bound holds because the limit is always trapped between two consecutive partial sums, which differ by exactly the next term. Notice how slowly it converges: a thousand terms buy only three digits of . Testing the bound on many , odd and even, catches a sign started the wrong way round. sign is a double, and the bound is 1.0 / (N + 1), for one reason: 1 / (N + 1) divides two ints and is 0, and an intsign / n would be 0 for every n above 1.
15. Sequences and series · Alternating series converge if the terms shrink · ProblemHow many terms of does the alternating series bound say you need, for an error below ? 31
So terms. The series needs 1000 terms for the same guarantee: terms that shrink faster converge faster.
15. Sequences and series · Absolute and conditional convergence · QuizClassify and .A. The first converges conditionally; the second absolutely decreases to 0, so the first converges by the alternating test, but is a series, which diverges: conditional. converges, so the second converges absolutely. Test first; reach for the alternating test only if that fails.
15. Sequences and series · Absolute and conditional convergence · Put in orderPut these in a sensible order to try on a series you do not recognise.1. Divergence test: do the terms go to 0? 2. Is it geometric, telescoping or a -series? 3. Compare with one of those (direct or limit comparison) 4. Ratio or root test, for factorials and powers 5. Alternating series test, if the signs alternateThe divergence test is free, so it goes first. Then the series you can sum or decide outright, then comparisons with them. Ratio and root are next, being powerful for factorials and exponentials. The alternating test comes last because it can show convergence but never absolute convergence, so you use it once the tests on have failed.
15. Sequences and series · Practice problems · ProblemFind the limit of the ratio test for , and for . for 1/3 ≈ 0.333333; for 1/e ≈ 0.367879
Both limits are below 1, so both series converge.
15. Sequences and series · Practice problems · ProblemA ball is dropped from a height of 2 m. Each bounce takes it back up to of the height it last fell from. If it bounces forever, what total distance does it travel, up and down?Distance 14 m
The first fall is 2 m. Then the ball rises and falls m, then m, and so on, each height of the last.
Infinitely many bounces, a finite distance.
15. Sequences and series · Practice problems · ProblemTo test , compare it with . What is , with and ?2
The limit is positive and finite, so the series does what does: it converges.
15. Sequences and series · Practice problems · ProblemFind .3/2 ≈ 1.5
Splitting one series into two is allowed here because both parts converge.
16. Taylor series · A power series is a polynomial that never ends · QuizFor which does converge, and to what?A. , to It is geometric with ratio , which converges exactly when , that is , to . The formula makes sense at , but the series does not converge there: a function and its series can disagree outside the interval.
16. Taylor series · Every power series has a radius of convergence · QuizWhat is the interval of convergence of ?A. It is geometric with ratio , so it converges when : radius 3, centred at 2, so . At both endpoints the ratio is and the terms do not go to 0, so they are excluded. forgets the centre.
16. Taylor series · Taylor series: match every derivative · QuizIn the Maclaurin series of , the coefficient of is . What is ?A. , so . This works both ways: a series you already know hands you all the derivatives at the centre for free. Forgetting the factorial is the usual slip.
16. Taylor series · Taylor series: match every derivative · ProblemFind the Taylor polynomial of centred at , and use it to estimate to 4 decimal places.2 + (x - 4)/4 - (x - 4)^2/64; 2.04937
At : . The true value is , an error of about .
16. Taylor series · Five series worth knowing by heart · QuizDifferentiate the series for term by term. What do you get?A. , the series for Inside its interval, a power series can be differentiated term by term. , since cancels against the top of . So the series of differentiates into the series of , as it must.
16. Taylor series · Build new series from old ones · QuizStart from , whose integral is . What is the Maclaurin series of ?A. Put into the geometric series: for . Integrate term by term from 0 (and ): . At it gives , a famous but very slow way to compute . The factorials belong to , not here.
16. Taylor series · Build new series from old ones · Code challengeWrite expSeries(x, N): the Taylor polynomial of at 0 up to the term . Build each term from the one before (multiply by x / n) instead of computing powers and factorials.One solution:
Solution
1doubleexpSeries(double x,int N){2double term =1;3double sum =1;4for(int n =1; n <= N; n++){5 term *= x / n;6 sum += term;7}8return sum;9}
Since , each term is the last times : one multiplication, and no huge intermediate numbers like or that can overflow. Factorials grow faster than any power, so the terms eventually shrink for every , which is why the radius is infinite.
16. Taylor series · Build new series from old ones · ProblemSubstitute into the series for to get the Maclaurin series of . What is the coefficient of , and what is ?Coefficient of -1/2 ≈ −0.5; 1680
The coefficient of is . The coefficient of is , so , without differentiating eight times.
16. Taylor series · Taylor's remainder: how much to trust a polynomial · QuizOn , every derivative of is at most . What is the smallest that guarantees by the bound ?A. You need . is too small, is enough, so and . The bound is honest: the actual error at is about , still too big. Off-by-one slips between and are the usual mistake.
16. Taylor series · Taylor's remainder: how much to trust a polynomial · ProblemEstimate with the Maclaurin polynomial (exactly, or to 4 decimal places), and bound its error with the remainder formula for , using .23/48 ≈ 0.479167; Error bound 1/384 ≈ 0.00260417
The true error, , is ten times smaller. The term of the sine series is 0, so is also , and the bound, , is much sharper.
16. Taylor series · How a calculator computes sin · Code challengeThe starter sums the series directly. Fix sinTaylor(x) by first reducing x to r = x - 2π · round(x / 2π), which lies in and has the same sine, and summing the series at r. std::round and std::numbers::pi will help.One solution:
Solution
1#include<cmath>2#include<numbers>34doublesinTaylor(double x){5double twoPi =2* std::numbers::pi;6double r = x - twoPi * std::round(x / twoPi);7double term = r;8double sum = r;9for(int k =1; k <40; k++){10 term *=(-r * r)/(2* k *(2* k +1));11 sum += term;12}13return sum;14}
repeats every , so . With the largest term is about , so there is no catastrophic cancellation, and 40 terms are far more than needed. The step from each term to the next multiplies by : the next odd power over the next two factors of the factorial. Production libraries reduce further, to , and use a carefully tuned polynomial rather than the plain Taylor one.
16. Taylor series · Euler's formula: e to an imaginary power · QuizWhat is ?A. : a quarter turn round the circle. Engineers use this to turn every oscillation into the real part of , because exponentials are far easier to differentiate and multiply than sines and cosines.
16. Taylor series · Euler's formula: e to an imaginary power · ProblemWrite as , with and real.1/2 ≈ 0.5; sqrt(3)/2 ≈ 0.866025
It is the point a sixth of the way round the unit circle.
16. Taylor series · When a Taylor series lets you down · Quiz is smooth for every real , yet its Maclaurin series only converges for . Why?A. In the complex numbers it blows up at , at distance 1 from 0The radius of convergence is the distance from the centre to the nearest point where the function misbehaves, counting complex points. at , at distance 1. Real calculus cannot see this; complex analysis explains it, and it is one of the reasons that subject exists.
16. Taylor series · Practice problems · ProblemFind the radius of convergence of . The series converges at exactly one of the two endpoints: which ?Radius 2; It converges at the endpoint -1
The ratio tends to , which is below 1 when : centre 1, radius 2, endpoints and .
So the interval of convergence is .
16. Taylor series · Practice problems · ProblemUse the Maclaurin series of to find .-1/24 ≈ −0.0416667
16. Taylor series · Practice problems · Problem has no elementary antiderivative. Estimate to 5 decimal places from the first three nonzero terms of its Maclaurin series, and give the alternating series bound on the error.Estimate 1/3 - 1/42 + 1/1320 ≈ 0.310281; Error bound 1/75600 ≈ 0.0000132275
The error is at most the first term left out, .
17. Differential equations · An equation whose unknown is a function · QuizWhich function solves with ?A. , and it is 5 at . has the right start value, but its derivative is , not : always check the equation and the condition.
17. Differential equations · A slope field shows every solution at once · QuizFor , along which line are the segments flat?A. Flat means slope 0: , so . Curves where the slope is constant are called isoclines; finding them is the quickest way to sketch a field by hand. The line is different: it is itself a solution, with slope 1 everywhere, and on it.
17. Differential equations · Separable equations: split the variables and integrate · QuizSolve with . What happens?A. , which blows up at Separate: , so ; gives , so . The solution reaches infinity at the finite time : blow-up. Nothing in the innocent-looking equation warns you; growth proportional to is faster than exponential. Solutions of DEs need not exist forever.
17. Differential equations · Separable equations: split the variables and integrate · ProblemSolve with , for .sqrt(x^2 + 4)
At , : . So , and taking the positive root, .
Check: , and .
17. Differential equations · Exponential growth and decay · QuizA substance has a half-life of 8 days. What fraction is left after 24 days?A. 24 days is three half-lives: . Exponential decay removes the same fraction in each equal time, not the same amount. is just , a ratio of the times, which is not how decay works; and a straight-line decline, half gone every 8 days, would be empty by day 16.
17. Differential equations · Exponential growth and decay · ProblemA bacteria culture doubles every 3 hours, starting from 500 cells. How many cells are there after 10 hours, and when does the culture reach cells?After 10 hours 500*2^(10/3) ≈ 5039.68 cells; It reaches at 3*ln(20)/ln(2) ≈ 12.9658 h
With a doubling time of 3 hours, , the same as with .
17. Differential equations · Logistic growth levels off · QuizAt what population does a logistic population grow fastest?A. The growth rate is a downward parabola in , zero at and , with its peak halfway, at . That is the inflection point of the S-curve. Fisheries use this: harvesting at gives the largest sustainable yield.
17. Differential equations · Newton's law of cooling · QuizIn that example, how long until the coffee reaches 50 °C?A. minutesSolve : , so minutes. uses , temperatures instead of differences from the room. The exponential is in , never in itself.
17. Differential equations · Newton's law of cooling · ProblemSoup at 85 °C is left in a room at 25 °C. After 10 minutes it is at 65 °C. Find the cooling constant , and the temperature after 30 minutes.ln(3/2)/10 ≈ 0.0405465 per minute; After 30 minutes 385/9 ≈ 42.7778 °C
Every 10 minutes the difference from the room shrinks by the same factor, : 60, 40, , then degrees.
17. Differential equations · Euler's method: follow the slope a step at a time · Code challengeWrite euler(f, t0, y0, h, steps): take steps Euler steps of size h for y' = f(t, y) from (t0, y0), and return the final y. f is a function of two numbers, a std::function<double(double, double)>.One solution:
Solution
1#include<functional>23doubleeuler(std::function<double(double,double)> f,4double t0,double y0,double h,int steps){5double t = t0;6double y = y0;7for(int i =0; i < steps; i++){8 y += h *f(t, y);9 t += h;10}11return y;12}
Each step uses the slope at the start of the step, then moves both and . Updating t before computing the slope is a common slip that quietly shifts every step. The error is proportional to : with , Euler gets to about 4 digits, after 10 000 steps. Better methods (Runge–Kutta, below) sample several slopes per step and do far better.
17. Differential equations · Second order: a mass on a spring · QuizA 0.5 kg mass hangs on a spring with N/m, no damping. What is its period?A. s rad/s, and one full swing takes s. is itself, in radians per second, not a time. Forgetting the square root gives .
17. Differential equations · Systems: several quantities changing together · Code challengeThe starter steps a spring (, ) with plain Euler, and its energy grows without limit. Change it to semi-implicit Euler: update v first, then update x using the newv. Return the State, x and v, after steps steps of size h.One solution:
Solution
1structState{2double x;3double v;4};56Statespring(double x0,double h,int steps){7double x = x0;8double v =0;9for(int i =0; i < steps; i++){10 v += h *-x;11 x += h * v;12}13return{x, v};14}
Plain Euler multiplies the energy by every step, so over steps of it grows by about times (the swing by ): the simulated spring swings wider and wider. Using the new velocity makes the method symplectic: it keeps a slightly altered energy exactly, so the error wobbles but never builds up. Game physics engines and planetary simulations use this one-line change for exactly that reason.
17. Differential equations · Practice problems · ProblemTake two Euler steps of size for , , to estimate . The exact solution is : how big is Euler's error at ?Euler estimate of 1.22; Error, exact minus Euler 2*e^0.2 - 2.42 ≈ 0.0228055
The exact value is , so the error is about . Euler falls short because the solution curves upward, and each step follows the slope at its start.
17. Differential equations · Practice problems · ProblemA population follows , with and in years. When does it reach 500, and what is its fastest rate of growth?ln(9)/0.4 ≈ 5.49306 years; Fastest growth 100 per year
The two answers belong together: the population grows fastest at the moment it passes .
17. Differential equations · Practice problems · ProblemA mass on a spring with , without damping, is pulled from its rest position and let go. Find its angular frequency, its period, and its greatest speed. 3 rad/s; Period 2*pi/3 ≈ 2.0944 s; Greatest speed 0.3 m/s
Starting at with velocity 0 gives and : . Then , whose size is at most , reached each time the mass passes the middle.
17. Differential equations · Practice problems · ProblemA piece of charcoal has 20% of the carbon-14 that living wood has. Carbon-14 has a half-life of 5730 years. How old is the charcoal?Age 5730*ln(5)/ln(2) ≈ 13304.6 years
A little more than two half-lives: two would leave 25%, three 12.5%.
18. Functions of several variables · A function of two variables is a surface · QuizFor , what is ?A. . Order matters: means , . With them swapped, .
18. Functions of several variables · Level curves: the contour map of a surface · QuizWhat do the level curves of look like?A. Parallel straight lines is the line : slope for every , shifted up as grows. Evenly spaced give evenly spaced lines, because the surface is a tilted plane with the same steepness everywhere.
18. Functions of several variables · A partial derivative changes one variable at a time · QuizFor , what is ?A. Treat as a number: is a constant times , giving , and is a constant, giving 0. Keeping is the usual slip: a term with no in it does not change as changes.
18. Functions of several variables · A partial derivative changes one variable at a time · ProblemLet . Find and , and the mixed partial at .2*x*e^(3*y); 3*x^2*e^(3*y); 6
Differentiating with respect to gives too, as Clairaut's theorem promises.
18. Functions of several variables · The gradient points straight uphill · Code challengeWrite gradient(f, x, y): the gradient at (x, y), as a std::pair{fx, fy}, each by a central difference with h = 1e-5.One solution:
Solution
1#include<functional>2#include<utility>34usingF2= std::function<double(double,double)>;56std::pair<double,double>gradient(F2 f,double x,double y){7double h =1e-5;8double fx =(f(x + h, y)-f(x - h, y))/(2* h);9double fy =(f(x, y + h)-f(x, y - h))/(2* h);10return{fx, fy};11}
Each partial derivative moves only its own variable and holds the other fixed, exactly as in the definition. This is how you check a hand-computed gradient, and it costs 4 evaluations of in two dimensions; with a million variables (a neural network) it would cost two million, which is why the mastery module comes back to automatic differentiation.
18. Functions of several variables · Directional derivatives: the slope in any direction · QuizFor at , someone uses the direction as it is and gets . What went wrong?A. has length 5; dividing by it gives the right answer, The formula needs a unit vector. has length , so the answer comes out 5 times too big. Divide by the length first: , giving . For comparison, the fastest rate here is , so this direction is almost straight uphill.
18. Functions of several variables · Directional derivatives: the slope in any direction · ProblemLet . At the point , find the rate of change of in the direction towards the point , and the fastest rate of change there.Towards 64/5 ≈ 12.8; Fastest rate sqrt(185) ≈ 13.6015
18. Functions of several variables · The tangent plane is the best flat approximation · QuizA box's volume is . At , , (metres), about how much does change if grows by m and the rest stay fixed?A. m³, so m³. The partial derivative is the exchange rate between a small change in one input and the change in the output. is the volume itself, , times : a size, not a rate; uses , the partial in instead of .
18. Functions of several variables · The tangent plane is the best flat approximation · ProblemFind the tangent plane to at , and use it to estimate .5 + 0.6*(x - 3) + 0.8*(y - 4); 4.98
The exact value is .
18. Functions of several variables · Critical points: minima, maxima and saddles · QuizClassify the critical point of at the origin.A. A saddle, , , so : a saddle. Along the -axis curves up; along the -axis curves down. Checking only and calling it a minimum is the classic mistake: one direction is not enough.
18. Functions of several variables · Lagrange multipliers: the best point on a constraint · QuizWhat is the largest value of on the circle ?A. and . Parallel means and , so ; then , . At , (the maximum); at , (the minimum). The method finds both; compare the values to tell which is which.
18. Functions of several variables · Gradient descent: walk downhill · Code challengeWrite descend(grad, start, eta, steps): run gradient descent from start for steps steps, where grad({x, y}) returns the gradient as {gx, gy}, and return the final point. A point is a Vec, a std::pair<double, double>.One solution:
Solution
1#include<functional>2#include<utility>34usingVec= std::pair<double,double>;56Vecdescend(std::function<Vec(Vec)> grad,Vec start,7double eta,int steps){8auto[x, y]= start;9for(int i =0; i < steps; i++){10auto[gx, gy]=grad({x, y});11 x -= eta * gx;12 y -= eta * gy;13}14return{x, y};15}
Compute the whole gradient at the current point, then move both coordinates; updating x first and then using the new x for y's gradient is a different (though here harmless) method. In each step multiplies the distance to by : for that is , which shrinks, and for it is , which grows. The steepest direction sets the largest safe learning rate, where is the largest curvature: here .
18. Functions of several variables · Practice problems · ProblemFind the critical point of , classify it with the second derivative test, and give the value of there. 2; -1; The value of -3
From , . Then gives , and .
18. Functions of several variables · Practice problems · ProblemA farmer has 400 m of fence for a rectangular field along a straight river; the side on the river needs no fence. With the two sides at right angles to the river and the side parallel to it, maximise the area subject to . 100 m; 200 m; Largest area 20000 m²
The side along the river is twice as long as each of the other two.
18. Functions of several variables · Practice problems · ProblemTake two steps of gradient descent on from , with learning rate . Where are you after two steps? 2.28; 0.16
Each step multiplies the distance to the minimum, , by in and by in : the steeper direction closes in faster.
19. Multiple integrals and vector calculus · A double integral adds up over a region · QuizWhat is ?A. The inner integral, in from 0 to 3, is . Then . When is a product over a rectangle, the double integral is just the product . Reading the limits in the right order matters: the inner goes with the inner limits.
19. Multiple integrals and vector calculus · A double integral adds up over a region · ProblemEvaluate over the rectangle where and .27/2 ≈ 13.5
19. Multiple integrals and vector calculus · Over a curved region, the inner limits are functions · QuizWritten with inside instead, . What are the inner limits?A. From to Fix a height between 0 and 1. The line gives the left edge, ; the parabola gives the right edge, (for , ). Draw the region first: reversing the curves without a picture is how the limits end up backwards.
19. Multiple integrals and vector calculus · Over a curved region, the inner limits are functions · Problem has no elementary antiderivative, so cannot be done in this order. Swap the order of integration and evaluate it exactly.(e - 1)/2 ≈ 0.859141
The region is the triangle with corners , and . For each in , runs from 0 to .
19. Multiple integrals and vector calculus · Triple integrals add up over a solid · QuizA unit cube has density kg/m³. What is its mass?A. kg. The density goes from 0 on one face to 1 on the opposite face, so on average it is , times a volume of 1 m³. Mass is the average density times the volume, which is what the triple integral computes.
19. Multiple integrals and vector calculus · Polar coordinates: dA becomes r dr dθ · Code challengeWrite polarIntegral(f, R, n): the integral of f(x, y) over the disc of radius R, using an n by n grid of midpoints in r (from 0 to R) and θ (from 0 to 2π), each weighted by r · Δr · Δθ.One solution:
Solution
1#include<cmath>2#include<functional>3#include<numbers>45usingF2= std::function<double(double,double)>;67doublepolarIntegral(F2 f,double R,int n){8double dr = R / n;9double dth =2* std::numbers::pi / n;10double sum =0;11for(int i =0; i < n; i++){12double r =(i +0.5)* dr;13for(int j =0; j < n; j++){14double th =(j +0.5)* dth;15 sum +=f(r * std::cos(th), r * std::sin(th))* r * dr * dth;16}17}18return sum;19}
The grid is rectangular in but each cell is a curved patch of area about , so every sample is weighted by its own . Leave out r and the disc of radius 2 still gives , by coincidence: equals only when . The other two tests expose it. The midpoint in makes the area test exact, because the integrand is a straight line.
19. Multiple integrals and vector calculus · Polar coordinates: dA becomes r dr dθ · ProblemA circular plate of radius 3 m has density kg/m², where is the distance from its centre in metres. Find its mass.Mass 18*pi ≈ 56.5487 kg
Without the extra you would get , which gives the big outer rings no more weight than the small inner ones.
19. Multiple integrals and vector calculus · The Jacobian: how a change of variables stretches area · QuizThe map , stretches the plane. What is its Jacobian, and what does it mean?A. : every region's area is multiplied by 6. A unit square becomes a 2 by 3 rectangle, of area 6. So the ellipse , the image of the unit disc, has area . Adding the stretches instead of multiplying them is the slip.
19. Multiple integrals and vector calculus · A vector field puts an arrow at every point · QuizWhich field is the gradient of ?A. . So is conservative, with potential . The rotation field is not the gradient of anything: if it were, and would give and , breaking Clairaut's theorem.
19. Multiple integrals and vector calculus · Line integrals add up a field along a path · Code challengeWrite lineIntegral(F, r, a, b, n): split [a, b] into n steps; for each, take the step dr = r(t1) - r(t0) and add F(midpoint) · dr, where the midpoint is halfway between r(t0) and r(t1). A point or a vector is a Vec, a std::pair<double, double>.One solution:
Solution
1#include<functional>2#include<utility>34usingVec= std::pair<double,double>;56doublelineIntegral(std::function<Vec(double,double)> F,7 std::function<Vec(double)> r,8double a,double b,int n){9double h =(b - a)/ n;10double sum =0;11for(int i =0; i < n; i++){12auto[x0, y0]=r(a + i * h);13auto[x1, y1]=r(a +(i +1)* h);14auto[P, Q]=F((x0 + x1)/2,(y0 + y1)/2);15 sum += P *(x1 - x0)+ Q *(y1 - y0);16}17return sum;18}
Each term is the dot product , the work for one small step, so you never need . The last test walks a parabola, not a straight line, and still gets : for a gradient field only the ends matter. Using the field at the start of each step instead of the middle works too, but converges more slowly.
19. Multiple integrals and vector calculus · Divergence measures spreading, curl measures spinning · QuizFor , what are the divergence and the curl?A. Divergence , curl , . Divergence . Curl . Mixing up which variable goes with which component is the usual slip: divergence pairs with ; curl pairs each component with the other variable. Any gradient field has curl 0, by Clairaut.
19. Multiple integrals and vector calculus · Green's theorem: the boundary knows what is inside · QuizUsing Green's theorem, what is anticlockwise round the unit circle? (Hint: in polar, over the unit disc is .)A. . So the line integral is . Green turned a fiddly integral round a curve into an easy one over a disc. The sign of is where it usually goes wrong: .
19. Multiple integrals and vector calculus · Stokes' and the divergence theorem: one idea in every dimension · QuizWhat is the flux of out of the unit sphere?A. , so by the divergence theorem the flux is the volume . Directly: on the unit sphere is the outward unit normal, so and the flux is the surface area, . Two routes, one number. forgets the divergence is 3, not 1.
19. Multiple integrals and vector calculus · Practice problems · ProblemFind for along the parabola , .11/15 ≈ 0.733333
This field is not a gradient (its curl is , not 0), so another path between the same ends could give a different answer.
19. Multiple integrals and vector calculus · Practice problems · ProblemUse Green's theorem to find anticlockwise round the circle of radius 3 centred at the origin.27*pi ≈ 84.823
19. Multiple integrals and vector calculus · Practice problems · ProblemFor , find the divergence and the curl at the point .Divergence 3; Curl -3
At the flow spreads out (a source) and turns clockwise (negative curl).
19. Multiple integrals and vector calculus · Practice problems · ProblemThe field is conservative. Find its potential with , and the work along any path from to .x^2*y + x + y^3; Work 11
gives , so . By the gradient theorem, the work is , whatever the path.
20. Rigour and the frontier · What a limit really means · QuizFor with , which values of work? Choose every one.A. ; B. You need , so . Any smaller works too: once a strip is narrow enough, narrower strips are as well. lets in, where , outside the band. The definition asks for some , not the biggest one.
20. Rigour and the frontier · What a limit really means · ProblemFor with , what is the largest that works? And for with , what does the recipe (under Go deeper) give?Largest for 0.002; for 0.01
exactly when , so ; any bigger lets in an whose value is outside the band.
For : , so . Check: if then , and .
20. Rigour and the frontier · The order of the quantifiers is the whole point · Put in orderPut the parts of the definition of in order.1. For every 2. there is a 3. such that for all with 4. we have The challenge () comes first, then the response (), then the promise about every in the strip, then the conclusion. Putting "there is a " before "for every " would demand one that works for all tolerances at once, which only constant functions near satisfy.
20. Rigour and the frontier · The order of the quantifiers is the whole point · QuizWhich statement means ""?A. There is an such that for every some with has Negating swaps each "for every" with "there is" and negates the end: becomes . The second option is far too strong: it says is never close to at all. One bad and one bad per are enough.
20. Rigour and the frontier · The real numbers have no gaps · QuizWhich set has no least upper bound within the rational numbers?A. Its least upper bound would be , which is not rational; any rational upper bound can be beaten by a smaller one. The others have rational suprema: 2, 1 and 1. A supremum need not belong to the set (2 is not below 2), it only has to be the smallest bound.
20. Rigour and the frontier · A proof that is also an algorithm · Code challengeWrite bisect(f, a, b, tol): f(a) and f(b) have opposite signs. Halve the interval, keeping the half with a sign change, until it is shorter than tol; return its midpoint.One solution:
Solution
1#include<functional>23doublebisect(std::function<double(double)> f,4double a,double b,double tol){5double fa =f(a);6while(b - a > tol){7double m =(a + b)/2;8double fm =f(m);9if(fm * fa >0){ // the same sign10 a = m;11 fa = fm;12}else{13 b = m;14}15}16return(a + b)/2;17}
The invariant is " changes sign on "; each step keeps it and halves the length, so after steps the root is pinned within : about 40 steps for 12 digits. Comparing signs, rather than assuming , makes the third test pass. This is the IVT proof almost line for line, and it shows why completeness matters: the loop produces a sequence of nested intervals, and only completeness guarantees there is a number inside all of them.
20. Rigour and the frontier · A proof that is also an algorithm · ProblemBisection starts on , where changes sign. How many halvings are needed before the interval is shorter than ?Halvings 20
So . Each halving buys about 0.3 decimal digits, whatever the function: steady, but slower than Newton's method (module 8), which roughly doubles the digits each step once it is close to a root.
20. Rigour and the frontier · Uniform continuity: one δ for the whole interval · QuizWhich of these is uniformly continuous on the given set?A. on (by the mean value theorem, since ), so works everywhere. gets ever steeper as grows, so must shrink far out; and misbehave near 0. A bounded derivative is a quick test for uniform continuity.
20. Rigour and the frontier · The chain of theorems behind the fundamental theorem · Put in orderPut these in the order in which each is used to prove the next.1. Completeness of the real numbers 2. Extreme value theorem 3. Rolle's theorem 4. Mean value theorem 5. Fundamental theorem of calculusCompleteness guarantees a maximum and a minimum exist on ; Rolle locates a flat point between equal values; the MVT is Rolle applied to minus its chord; the FTC follows by the MVT on each piece of a partition, as above. Without completeness the very first step fails, and with it the whole chain.
20. Rigour and the frontier · Beyond Riemann: measure and the Lebesgue integral · QuizWhy do the rational numbers in have measure 0?A. They can be listed ; cover by an interval of length , total at most , for any Rationals are countable: they can be put in a list. Covering the $n$th by an interval of length uses total length , which can be as small as you like. They are infinitely many and dense, which is what makes the result surprising.
20. Rigour and the frontier · Calculus of variations: the best function · QuizApplied to (with in place of as the variable and as the function), what does the Euler–Lagrange equation give?A. , the spring equation and , whose time derivative is . So : Newton's law for a spring. This , kinetic minus potential energy, is the Lagrangian, and "nature makes stationary" (the principle of least action) reproduces all of classical mechanics.
20. Rigour and the frontier · Automatic differentiation: the chain rule as code · Code challengeA Dual carries a value v and a derivative d. add is done. Finish mul (the product rule) and sin (the chain rule), so that f(variable(x)).d is exactly f'(x).One solution:
The derivative part of a product is , and of of something is of the value times the inner derivative, never of the derivative. With those two rules every composition differentiates itself, exactly, to the last digit: no , no rounding trade-off. C++ lets you go one step further and name them operator* and operator+, so that x * sin(x) on Duals reads like the maths; C++ autodiff libraries work that way. Machine learning libraries do the same, in reverse mode, for tensors with billions of entries.
20. Rigour and the frontier · Automatic differentiation: the chain rule as code · ProblemPush the dual number through by hand, with . What are the value part and the part of the result?Value part pi^2/4 ≈ 2.4674; part pi ≈ 3.14159
The part is . By the product rule, , which is there.
20. Rigour and the frontier · Problems that mix everything · QuizWhat is ?A. Taylor: , so . L'Hôpital three times gives the same, more slowly. Series are often the fastest way through a .
20. Rigour and the frontier · Problems that mix everything · QuizWhat is ?A. By parts, . Since exponentials beat powers, , leaving 1. It is the mean waiting time for the exponential density with , and it is : the gamma function extends factorials this way.
20. Rigour and the frontier · Problems that mix everything · QuizWhat is ?A. With , the fundamental theorem gives , and the integral is . The chain rule: . You never need the antiderivative, which does not exist in elementary form anyway.
20. Rigour and the frontier · Problems that mix everything · QuizWhat is ? (Hint: differentiate and multiply by .)A. Differentiating gives , so for . At : . The ratio test said it converges; power series tell you to what.
20. Rigour and the frontier · Practice problems that mix everything · ProblemEvaluate .2
As the first term goes to 0, and (the problem set above), so the integral is . It is .
20. Rigour and the frontier · Practice problems that mix everything · ProblemFor , find .The derivative 9*x^2*ln(x) - ln(x)
20. Rigour and the frontier · Practice problems that mix everything · ProblemWhich makes as large as possible, and what is that largest value? 2; Largest value 4
, positive for and negative after: is largest at , where the curve dips below the axis.
20. Rigour and the frontier · More practice problems that mix everything · ProblemThe solution of with has no simple formula. Find and from the equation, and use the Taylor polynomial at 0 to estimate . 1; 3; 1.115
A careful numerical solution gives . The next term, , accounts for most of the difference.
20. Rigour and the frontier · More practice problems that mix everything · ProblemWhat is the average value of over the unit disc ?1/2 ≈ 0.5
Not the you get by averaging over : the outer rings are bigger, so they count for more.