IB Maths AA & A-Level

Differentiation From First Principles: A Step-by-Step Guide

IB Demystified maths teamEvery diagram drawn, not photographed14 min read

You already know a quick way to differentiate. For y = x2 you bring the power down and take one off, and you get 2x. That shortcut works, but where did it come from?

Differentiating from first principles means working out the answer from the definition of a gradient, without using any shortcut. It is the proof behind the rule. This page walks through it slowly, with a picture of what is really happening, and then shows you the four steps you use in an exam.

The Problem We Are Trying to Solve

Start with something easy. On a straight line, the gradient is the same everywhere, and you find it like this:

gradient = change in y ÷ change in x

pick any two points on the line, and you always get the same answer

Now try the same thing on a curve. Here is the problem. A curve does not have one gradient. It is steep in some places and flat in others, so the gradient depends on where you are standing.

What we want is the gradient at a single point — the steepness of the curve exactly there. But to find a gradient you need two points, and we only have one. That is the whole difficulty.

The question

How do you find a gradient at one point, when the formula for gradient needs two points?

The Trick: Use Two Points Instead of One

Since we need two points, we will use two. We take the point we care about, and then a second point a little way along the curve. We join them with a straight line.

A straight line joining two points on a curve is called a chord. We can find the gradient of a chord easily, because a chord is straight.

The gradient of a chordxyPQhf(x+h)− f(x)xx + h
P is the point we care about. Q is a little way along. The gold line joining them is the chord.

Scroll the diagram sideways.

Look at the two steps drawn under and beside the chord. To get from P to Q you move:

  • Across by h. We call the small horizontal step h. P is at x, so Q is at x + h.
  • Up by f(x + h) − f(x). The height at P is f(x) and the height at Q is f(x + h), so the vertical step is the difference between them.

Put those into “change in y divided by change in x” and you have the gradient of the chord:

gradient of chord = [ f(x + h) − f(x) ] ÷ h

the vertical step divided by the horizontal step

This is not the answer yet. It is the gradient of the chord, not the gradient at P. But it is close, and here is the clever bit: the smaller we make h, the closer it gets.

Watch the Chord Become the Tangent

Slide Q down towards P. As the gap h gets smaller, the chord swings round until it is lying almost flat against the curve at P. The line that just touches the curve at a point is called the tangent, and the gradient of the tangent is what we are after.

Below is the curve y = x2 with P at x = 1. The dashed grey line is the real tangent. Watch the gold chord close in on it.

chord with h = 1h = 1gradient = 3chord with h = 0.5h = 0.5gradient = 2.5chord with h = 0.1h = 0.1gradient = 2.1
As h shrinks from 1 to 0.5 to 0.1, the gradient of the chord falls from 3 to 2.5 to 2.1. It is heading for 2.

Scroll the diagrams sideways.

You can see where it is going. Let us check it with numbers. Here is the gradient of the chord on y = x2 at x = 3, for smaller and smaller values of h.

The gradient of the chord as h gets smaller
hGradient of the chord
17
0.56.5
0.16.1
0.016.01
0.0016.001
0.00016.0001

The answers are closing in on 6. They never quite reach it, but they get as near as you like. That is what we mean when we say the gradient tends to 6, and we write it using the word limit.

What a limit means, in plain words

  • A limit is the value something is heading towards.
  • It does not have to ever arrive. In the table above, no row says 6 exactly — but 6 is clearly where it is going.
  • lim with h → 0 underneath means “the value this heads towards as h gets closer and closer to zero”.

The Formula, Explained Piece by Piece

Everything above now fits into one line. This is the definition of the derivative, and it is the formula you quote in an exam.

f′(x) = limh→0 [ f(x + h) − f(x) ] ÷ h

the gradient at a point is the limit of the gradient of a chord, as the chord shrinks to nothing

It looks heavy, so take it one symbol at a time.

Every part of the formula
PartHow you say itWhat it means
f′(x)“f dash of x”The gradient of the curve at the point x. This is the answer we want.
h“h”The small step along the x-axis to the second point.
f(x + h)“f of x plus h”The height of the curve at the second point. You get it by writing (x + h) everywhere the rule has an x.
f(x + h) − f(x)“the difference in height”How far up you go from the first point to the second.
limh→0“the limit as h tends to zero”Squeeze the gap down to nothing and see what number the answer settles on.

Keep writing “lim” until the very last line

The limit sign is part of the maths, not decoration. It must appear on every line until the moment you actually let h go to zero. Dropping it early is one of the most common reasons students lose method marks on this question.

The Four Steps

Every first principles question is the same four steps. Learn the pattern once and you can do any of them.

Write down f(x + h). Take the rule for the curve and replace every x with (x + h). Keep the brackets. Then expand.
Subtract f(x). Work out f(x + h) − f(x). Everything without an h in it should cancel. If it does not, check your expanding.
Divide by h. Every term left should have an h in it, so every term loses one h. The h on the bottom disappears.
Let h go to zero. Now it is safe. Cross out every term that still has an h in it. What is left is f′(x).

Step 2 is where the magic happens. The whole method works because the constant terms cancel, which leaves every surviving term carrying an h — and that is exactly what lets you divide by h in step 3.

Worked Examples

Example 1: differentiate x2 from first principles

Prove, from first principles, that if f(x) = x2 then f′(x) = 2x.

Step 1. Replace x with (x + h) and expand

f(x + h) = (x + h)² = x² + 2xh + h²

Step 2. Subtract f(x). The x² terms cancel

f(x + h) − f(x) = x² + 2xh + h² − x²

= 2xh + h²

Step 3. Divide by h. Every term has an h, so every term loses one

(2xh + h²) / h = 2x + h

Step 4. Let h go to zero

f′(x) = limh→0 (2x + h) = 2x

f′(x) = 2x

Check it against the shortcut: bring the 2 down, take one off the power, and you get 2x. Same answer. The shortcut was never magic — it was this calculation, done once, for everybody.

Example 2: differentiate x3 from first principles

Find f′(x) from first principles when f(x) = x3.

Step 1. Expand (x + h)³

f(x + h) = x³ + 3x²h + 3xh² + h³

Step 2. Subtract f(x). The x³ terms cancel

f(x + h) − f(x) = 3x²h + 3xh² + h³

Step 3. Divide by h

= 3x² + 3xh + h²

Step 4. Let h go to zero. Both terms with an h vanish

f′(x) = 3x²

Expanding (x + h)3 without panicking

  • Do it in two goes: (x + h)² = x² + 2xh + h² first.
  • Then multiply that by (x + h) term by term.
  • Or use the binomial pattern 1, 3, 3, 1: x³ + 3x²h + 3xh² + h³.

Example 3: a full quadratic

Differentiate f(x) = 3x2 + 2x from first principles.

Step 1. Replace both x’s

f(x + h) = 3(x + h)² + 2(x + h)

= 3(x² + 2xh + h²) + 2x + 2h

= 3x² + 6xh + 3h² + 2x + 2h

Step 2. Subtract f(x) = 3x² + 2x

= 6xh + 3h² + 2h

Step 3. Divide by h

= 6x + 3h + 2

Step 4. Let h go to zero

f′(x) = 6x + 2

Notice what happened to the + 2x. It produced + 2h, which divided down to a plain + 2 and survived to the end. Terms in x always leave behind a constant.

Example 4: a fraction (harder)

Differentiate f(x) = 1/x from first principles.

Step 1 and 2 together

f(x + h) − f(x) = 1/(x + h) − 1/x

Put the two fractions over a common denominator

= [ x − (x + h) ] / [ x(x + h) ]

= −h / [ x(x + h) ]

Step 3. Divide by h, which means multiply by 1/h

= −1 / [ x(x + h) ]

Step 4. Let h go to zero, so (x + h) becomes x

f′(x) = −1/x²

Example 5: a square root (hardest)

Differentiate f(x) = √x from first principles.

Step 1 and 2

f(x + h) − f(x) = √(x + h) − √x

Step 3. Dividing by h gets stuck. Multiply top and bottom by √(x + h) + √x

top = [√(x+h) − √x]

      × [√(x+h) + √x]

    = (x + h) − x = h

That h cancels the h on the bottom

= 1 / [ √(x + h) + √x ]

Step 4. Let h go to zero

= 1 / ( √x + √x )

f′(x) = 1 / (2√x)

The trick to remember here

  • When you get stuck with a fraction, combine it over one denominator.
  • When you get stuck with a square root, multiply top and bottom by the same expression with the sign flipped. That is called rationalising, and it turns the roots into something that cancels.
  • In both cases the aim is identical: get a single h on the top so it can cancel with the h on the bottom.

Why You Cannot Just Put h = 0

This is the question almost every student asks, and it is a good one. If we want the gap to be zero, why not set h = 0 at the start and save all the work?

Try it on f(x) = x2:

Putting h = 0 straight into the formula

[ f(x + 0) − f(x) ] / 0 = ( x² − x² ) / 0

= 0 / 0

Zero divided by zero has no value. It is not 0, it is not 1, and it is not infinity. It tells you nothing at all. In maths this is called an indeterminate form, which is a formal way of saying “this expression has not got an answer”.

That makes sense if you go back to the picture. Setting h = 0 means P and Q are the same point — and you cannot draw a line through one point. There are infinitely many lines through a single point, so there is no gradient to find.

So what do we do instead

  • We never set h to zero while it is on the bottom of a fraction.
  • First we do the algebra that cancels the h off the bottom. That is steps 1 to 3.
  • Once the h is only on the top, it is completely safe to let it go to zero. That is step 4.
  • This is why the four steps are in that order. They are not a ritual — each one is there to make the next one legal.

The question almost nobody answers

Here is the bit that quietly bothers thoughtful students, and most pages skip it. In step 3 we cancelled the h. You are only allowed to cancel h if h is not zero. But then in step 4 we let h go to zero. Is that not cheating?

No, and here is why. Look at the two expressions from Example 1:

The same two expressions, compared
ExpressionWhen h is not zeroWhen h is zero
(2xh + h²) / hEqual to 2x + hNo value. It is 0/0.
2x + hEqual to the fraction aboveEqual to 2x. Perfectly fine.

The two expressions agree at every single value of h except zero. And a limit only cares about what happens near zero, never at zero. So the limit of the messy fraction is the same as the limit of the tidy one — and the tidy one we can just read off.

In one sentence

We are not putting h = 0 into the original fraction. We are replacing the fraction with a tidier expression that matches it everywhere that matters, and then reading off where that is heading.

A sentence worth memorising

We do not ask what happens when h equals zero. We ask what the answer is heading towards as h gets closer and closer to zero. Those are different questions, and only the second one has an answer.

The Other Notation You Will See

Different books and different exam boards write the same idea with different letters. Nothing changes except the symbols, but you need to recognise all of them.

Three ways of writing the same formula
Written asWhere you see itWhat is different
f′(x) = limh→0 [f(x+h) − f(x)]/hIB Maths AA and most A-level textbooksThe standard version. Use this unless told otherwise.
dy/dx = limδx→0 δy/δxOlder A-level books, and some physics coursesδx (“delta x”) is just another name for h. δy is the change in y.
f′(a) = limx→a [f(x) − f(a)]/(x − a)University courses, and occasionally IB HLInstead of a step h, the second point slides towards a fixed point a. Same idea, different bookkeeping.

If a question asks for first principles and uses δx, write δx in your answer. Matching the notation in the question is free marks.

What the IB and A-Level Actually Ask

Before you revise this, check whether your course examines it at all. A lot of students lose time on first principles when their paper will never ask for it.

What you are expected to do on each course
CourseIs it examinedWhat comes up
IB Maths AA HLYes — syllabus point AHL 5.12, “first principles, higher derivatives”.Powers such as x2 and x3, short polynomials, and at the top end sin x using the compound angle formula.
IB Maths AA SLNo — “AHL” means additional higher level, so it is HL content only.SL meets the idea informally under 5.1, as the gradient of a chord approaching a tangent, but is not asked to prove a derivative.
IB Maths AINo, at either level.AI uses differentiation but never asks you to derive it.
A-level mathsYes — AQA, Edexcel and OCR all examine it, usually for 4 or 5 marks.Powers up to x3, short polynomials, and occasionally 1/x. Trig from first principles is Further Maths.

Where the marks actually are

  • Quoting the definition correctly at the start. Write the full formula with the limit sign before you touch any algebra.
  • Expanding and simplifying without losing a sign.
  • Showing the h cancel. Do not skip from the big fraction straight to the answer.
  • Taking the limit explicitly on the final line, so the examiner can see you know when it is allowed.
  • Answering a “prove that” with the shortcut rule scores nothing, even though the answer is right. The method is the question.

Differentiating sin x (IB AA HL)

This is the hardest one that comes up, and it is HL only. You need two things first: the compound angle formula, and one limit that you have to know.

The limit you need

As h gets small, (sin h) / h gets close to 1. That is not obvious, so look at the numbers. Your calculator must be in radians for this.

Two limits you need, as h gets small (h in radians)
h(sin h) / h(cos h − 1) / h
10.84147−0.45970
0.50.95885−0.24483
0.10.99833−0.04996
0.010.99998−0.00500
0.0010.99999 98−0.00050
heading for10

Radians, not degrees

In degrees, (sin h)/h heads towards 0.01745, not 1, and the whole derivation collapses. This is the real reason calculus always uses radians. It is not a convention someone picked — the derivative of sin x is only equal to cos x when the angle is measured in radians.

The derivation

Prove from first principles that if f(x) = sin x then f′(x) = cos x.

Step 1. Expand sin(x + h) with the compound angle formula

sin(x + h)

= sin x cos h + cos x sin h

Step 2. Subtract sin x and group the sin x terms

= sin x cos h + cos x sin h

    − sin x

= sin x (cos h − 1) + cos x sin h

Step 3. Divide by h, splitting it into two pieces

= sin x × (cos h − 1)/h

    + cos x × (sin h)/h

Step 4. Let h go to zero, using the two limits from the table

→ sin x × 0 + cos x × 1

f′(x) = cos x

Notice that sin x and cos x are treated as constants here, because x is not the thing changing. Only h is changing. That is why they can be pulled outside the limit.

The same method gives cos x

  • Expand cos(x + h) = cos x cos h − sin x sin h.
  • Group it as cos x (cos h − 1) − sin x sin h.
  • Divide by h and take the limit: cos x × 0 − sin x × 1.
  • So the derivative of cos x is −sin x. The minus sign comes from the compound angle formula, not from anywhere else.

Common Mistakes

Seven slips that cost marks
The mistakeWhat goes wrongDo this instead
Using the power ruleScores zero on a “prove from first principles” question, even with the right answer.Start from the definition every time the words “first principles” appear.
Writing (x + h)² = x² + h²The 2xh term goes missing, and that term is the derivative.(x + h)² = x² + 2xh + h². Expand properly, every time.
Dropping the limit signThe lines are no longer true statements, and method marks go.Write lim on every line until the final step.
Setting h = 0 too earlyYou get 0/0, which means nothing.Cancel the h off the bottom first, then let h go to zero.
Forgetting to subtract f(x)The constant terms never cancel, so nothing divides by h cleanly.Always do f(x + h) minus f(x), in that order.
Only replacing some of the x’sIn 3x² + 2x students often change the first x and forget the second.Every single x becomes (x + h). Count them before you expand.
Cancelling only one term’s hDividing 2xh + h² by h and writing 2x + h².Every term on the top loses one h. So it is 2x + h.

Practice Questions

Work each one on paper, using all four steps, then tap to check. Every answer below was verified.

1. Differentiate f(x) = 4x2 from first principles.

Step 1

f(x + h) = 4(x + h)²

= 4x² + 8xh + 4h²

Step 2. The 4x² terms cancel

= 8xh + 4h²

Step 3. Divide by h

= 8x + 4h

Step 4. Let h go to zero

f′(x) = 8x

2. Differentiate f(x) = x2 + 3x from first principles.

Step 1. Change both x’s

f(x + h) = (x + h)² + 3(x + h)

= x² + 2xh + h² + 3x + 3h

Step 2. Subtract x² + 3x

= 2xh + h² + 3h

Step 3. Divide by h

= 2x + h + 3

Step 4

f′(x) = 2x + 3

3. Differentiate f(x) = 5x2 − 4x + 1 from first principles.

Step 1

f(x + h) = 5(x + h)²

      − 4(x + h) + 1

= 5x² + 10xh + 5h²

    − 4x − 4h + 1

Step 2. The 5x², −4x and +1 all cancel

= 10xh + 5h² − 4h

Step 3. Divide by h

= 10x + 5h − 4

Step 4

f′(x) = 10x − 4

Note the +1 vanished completely. A constant never affects a gradient.

4. Differentiate f(x) = 2x3 − x from first principles.

Step 1. Expand (x + h)³ first

f(x + h) = 2(x + h)³ − (x + h)

= 2(x³ + 3x²h + 3xh² + h³)

    − x − h

Step 2. Subtract 2x³ − x

= 6x²h + 6xh² + 2h³ − h

Step 3. Divide by h

= 6x² + 6xh + 2h² − 1

Step 4

f′(x) = 6x² − 1

5. Why can you not simply substitute h = 0 into the definition at the start?

Because the top becomes f(x) − f(x) = 0 and the bottom is 0, giving 0/0, which has no value. In the picture, it means the two points have merged into one, and you cannot draw a line through a single point. You must cancel the h off the bottom first.

6. Use the table in this article to write down the gradient of y = x2 at x = 3, and check it with the rule.

The chord gradients were heading for 6. Checking with the derivative: f′(x) = 2x, so f′(3) = 6. They agree.

7. Differentiate f(x) = 1/x from first principles. (HL and A-level)

Steps 1 and 2, over a common denominator

1/(x + h) − 1/x

= [x − (x + h)] / [x(x + h)]

= −h / [x(x + h)]

Step 3. Divide by h

= −1 / [x(x + h)]

Step 4. (x + h) becomes x

f′(x) = −1/x²

8. A student writes (x + h)² = x² + h² and gets f′(x) = 0. Explain what went wrong.

They left out the 2xh term. With it missing, step 2 gives just h², step 3 gives h, and step 4 sends that to zero. The 2xh term is the derivative — it is the only term that survives. Losing it loses the whole answer.

9. Prove from first principles that f(x) = cos x has derivative −sin x. (HL)

Step 1. Compound angle formula

cos(x + h)

= cos x cos h − sin x sin h

Step 2. Subtract cos x and group

= cos x (cos h − 1) − sin x sin h

Step 3. Divide by h

= cos x × (cos h − 1)/h

    − sin x × (sin h)/h

Step 4. The two limits are 0 and 1

→ cos x × 0 − sin x × 1

f′(x) = −sin x

Frequently Asked Questions

What does differentiation from first principles mean?

It means finding a derivative using only the definition of a gradient, with no shortcut rules. You take two points on the curve a small distance h apart, find the gradient of the straight line joining them, and then see what that gradient heads towards as h shrinks to nothing. It is where the power rule and every other rule came from in the first place.

What is the formula for first principles?

f′(x) = limh→0 [f(x + h) − f(x)] / h. In words: the derivative is the limit, as the gap h shrinks to zero, of the change in height divided by the change in x.

Why can’t I just set h = 0?

Because you get 0/0, which has no value. The top becomes f(x) − f(x) = 0 and the bottom is already 0. You have to do the algebra that cancels the h off the bottom first. Once h is only on the top, letting it go to zero is perfectly safe.

If we cancel h assuming it isn’t zero, how can we then let it be zero?

Because the two expressions agree at every value of h except zero, and a limit only looks at what happens near a point, never at it. So the limit of the messy fraction equals the limit of the tidy expression, and the tidy one you can simply read off. We never actually evaluate the original fraction at zero.

What is a chord, and what is a tangent?

A chord is a straight line joining two points on a curve. A tangent is a straight line that touches the curve at just one point and has the same steepness as the curve there. First principles works by starting with a chord and squeezing it until it becomes the tangent. Some textbooks call the chord a secant; it means the same thing.

What is a limit, in simple terms?

A limit is the value something is heading towards. It does not have to arrive. If the gradients go 7, 6.5, 6.1, 6.01, 6.001, none of them is 6, but 6 is clearly where they are going, so the limit is 6.

What is the difference between h and δx?

Nothing — they are two names for the same small step along the x-axis. h is used by the IB and most modern A-level books; δx (“delta x”) is used by older textbooks and by Imperial-style university notes, often paired with δy for the change in height. Some books write Δx instead. Whichever the question uses, use the same in your answer.

Is first principles on the IB Maths AA SL syllabus?

No. It sits at AHL 5.12, and “AHL” means additional higher level, so it is HL content. SL students meet the idea informally under 5.1 — the gradient of a chord approaching a tangent — but are not asked to prove a derivative from the definition. Maths AI does not examine it at either level.

Is it on A-level maths?

Yes. AQA, Edexcel and OCR all examine it, typically as a 4 or 5 mark “prove from first principles” question using powers up to x3 or a short polynomial. Differentiating trig functions from first principles belongs to Further Maths.

Can I just use the power rule instead?

Not if the question says “from first principles” or “using the definition of the derivative”. The method is the question, so a right answer reached by the shortcut scores nothing. Use the shortcut afterwards to check your answer.

How do I do first principles with a fraction like 1/x?

Combine the two fractions over a common denominator before you try to divide by h. For 1/x that gives −h / [x(x + h)], and the h then cancels cleanly, leaving −1/x².

How do I do first principles with a square root?

Multiply the top and bottom by the same expression with the middle sign flipped — so for √(x + h) − √x you multiply by √(x + h) + √x. This is called rationalising. The roots disappear from the top, leaving a plain h that cancels, and you end up with 1 / (2√x).

Why does calculus use radians and not degrees?

Because the derivative of sin x is only cos x when the angle is in radians. The proof relies on (sin h)/h heading towards 1 as h shrinks, and that is only true in radians. In degrees it heads towards about 0.01745 instead, and every trig derivative would carry that awkward factor. Radians are not a convention someone picked — they are the measure that makes calculus work.

What is f′(x) and how do I say it?

You say it “f dash of x”, or “f prime of x”. It means the gradient of the curve y = f(x) at the point x. It is the same thing as dy/dx, just written differently.

How many marks is a first principles question worth?

Usually 4 or 5. The marks are spread across quoting the definition, expanding correctly, showing the h cancel, and taking the limit on the final line. Because the marks are for the method rather than the answer, writing out every step is worth far more here than in most questions.

Do I need to keep writing “lim” on every line?

Yes, until the line where you actually let h go to zero. Without it the lines are not true statements, and examiners take method marks off for dropping it. It is the easiest mark on the question to keep and the easiest to lose.

First principles is a proof. Proofs are where marks disappear.

Most students can get the right answer here. Far fewer write it in a way that collects all five marks — quoting the definition, keeping the limit sign, showing the cancelling. Our tutors teach IB and A‑level maths and work through your own past papers, so we fix the habits that are costing you marks rather than teaching topics you already know.

Book a free 30-minute meeting

Revising the whole subject? Our IB revision notes cover maths topic by topic at SL and HL, or read about our IB maths tutors.