James Ashton MathsFREE MATHEMATICS. OPEN TO EVERYONE.
HomeIB DiplomaA levelAbout
IB Diploma › Maths AA HL › Topic 5: Calculus › Integrating factors & Euler

Integrating factors & Euler’s method

Solving linear first-order equations dydx+P(x)y=Q(x) exactly with an integrating factor, and approximating solutions of any first-order equation numerically with Euler’s method.

AHL 5.18HL onlyPaper 1Paper 2≈ 75 min to work through
Before you start: separable differential equations and integration by parts. See Separable and homogeneous DEs and Substitution and parts.

1What you need to know

Tick these off as you go. By the end of the page you should be able to do all of them without notes.

  • Recognise a linear first-order equation and put it in standard formAHL 5.18
  • Find the integrating factor e∫P(x)dx and use it to solve the equationAHL 5.18
  • Apply Euler’s method by hand and with a GDCAHL 5.18
  • Explain whether Euler’s method over- or underestimates, and how to improve itAHL 5.18

2Notes & worked examples

Each idea is followed by a worked example. Try the question yourself first, then reveal the solution one step at a time.

The big idea

The left side of xdydx+y is exactly ddx(xy) by the product rule, so xdydx+y=x3 integrates at once to xy=x44+C. An integrating factor is a multiplier chosen to make any linear equation look like that. When no exact method works, Euler’s method follows the slope field in small straight steps to approximate the solution.

2.1 Linear equations and the integrating factor

Integrating factor In formula booklet

For dydx+P(x)y=Q(x), multiply through by I(x)=e∫P(x)dx. Then

ddx(I(x)y)=I(x)Q(x)⇒I(x)y=∫I(x)Q(x)dx
Why does it work?

We want Idydx+IPy to equal ddx(Iy)=Idydx+I′y. That needs I′=IP, a separable equation with solution I=e∫Pdx. No constant is needed in ∫Pdx: any one integrating factor works.

The equation must be in standard form first: coefficient of dydx equal to 1, and the y term on the left.

Worked example 1Paper 1
Solve dydx+yx=x2, x>0.
P=1x: I=e∫1xdx=elnx=x
ddx(xy)=x·x2=x3⇒xy=x44+C
y=x34+Cx
Worked example 2Paper 1
Solve dydx−2y=ex, given y=1 when x=0.
P=−2: I=e−2x
Keep the sign of P.
ddx(ye−2x)=e−x⇒ye−2x=−e−x+C
y=−ex+Ce2x. y(0)=1⇒C=2: y=2e2x−ex
Worked example 3Paper 1
Solve xdydx+2y=x2, x>0, given y=1 when x=1.
Standard form: dydx+2xy=x
Divide by x first: the coefficient of dydx must be 1.
I=e2lnx=x2: ddx(x2y)=x3⇒x2y=x44+C
1=14+C⇒C=34: y=x24+34x2
Worked example 4Paper 1
Solve dydx+ytanx=cosx, 0<x<π2.
I=e∫tanxdx=e−lncosx=secx
∫tanxdx=−ln|cosx|.
ddx(ysecx)=cosxsecx=1⇒ysecx=x+C
y=(x+C)cosx
Worked example 5 (faded)Paper 1
Solve dydx+2y=4x, given y=0 when x=0.
I=e2x; ye2x=∫4xe2xdx=2xe2x−e2x+C (by parts), so y=2x−1+Ce−2x and C= 1  ← you work this out

2.2 Euler’s method

Euler’s method In formula booklet

For dydx=f(x,y) with y(x0)=y0 and step length h:

xn+1=xn+hyn+1=yn+hf(xn,yn)

Each step moves along the tangent at the current point for a horizontal distance h. It works for any first-order equation, including ones with no exact solution.

Worked example 6Paper 2
dydx=x+y, y(0)=1. Use Euler’s method with h=0.1 to estimate y(0.3).
n=0: f(0,1)=1, y1=1+0.1(1)=1.1
n=1: f(0.1,1.1)=1.2, y2=1.1+0.12=1.22
n=2: f(0.2,1.22)=1.42, y3=1.22+0.142=1.362
y(0.3)≈1.362. The exact solution y=2ex−x−1 gives 1.3997.
The exact solution comes from an integrating factor: try it.

Accuracy. The error comes from following the tangent instead of the curve. If the solution is concave up (d2ydx2>0), tangents lie below the curve, so Euler underestimates; if concave down, it overestimates. Halving h roughly halves the error, at the cost of twice as many steps.

nxnynf(xn,yn)yn+1
00111.1
10.11.11.21.22
20.21.221.421.362
On your TI-Nspire Calculator tricks →

In Lists & Spreadsheet: column A for x (=a1+0.1 filled down), column B for y with b1=1 and b2=b1+0.1*(a1+b1) filled down. Change the step in one cell to compare accuracies. Write down at least the first step and the final value in your working.

3Explore it

The navy curve is the exact solution; the red polyline is Euler’s method. Make the step length smaller and watch the error shrink.

4Common mistakes & exam tips

Common mistakes

  • Finding the integrating factor before putting the equation in standard form.
  • Writing I=e∫Pdx but losing the sign of P.
  • Forgetting to multiply the right-hand side Q(x) by I.
  • Forgetting the constant C after integrating IQ, or not dividing it by I at the end.
  • In Euler’s method, using the new x with the old y (or vice versa) when evaluating f.

Exam tips

  • Write the line ddx(Iy)=IQ explicitly: it is usually worth a mark.
  • Simplify elnx=x and e−lncosx=secx straight away.
  • For Euler on Paper 2, give answers to the accuracy asked; keep full accuracy in intermediate steps.
  • Comment on accuracy using concavity or by comparing with the exact solution.

5Practice

Fluency questions build the basics. Problem-solving questions make you think about which method to use.

FluencyP1
Find an integrating factor for dydx+3y=x.
e3x
FluencyP2
Solve dydx+yx=1, x>0.
xy=x22+C⇒y=x2+Cx
FluencyP3
Solve dydx+y=e−x, y(0)=2.
yex=x+C: y=(x+2)e−x
FluencyP4
Use Euler’s method with h=0.5 to estimate y(1) for dydx=y, y(0)=1.
1→1.5→2.25. (Exact e=2.718.)
Problem solvingP5
Solve cosxdydx+ysinx=1, 0<x<π2.
Standard form: y′+ytanx=secx, I=secx: ysecx=tanx+C⇒y=sinx+Ccosx
Problem solvingP6
For dydx=x2−y, y(1)=2, does Euler’s method with a small step over- or underestimate y(1.3)?
y′′=2x−y′=2x−x2+y, positive near (1,2): concave up, so it underestimates.

6Exam-style questions

Original questions in the style of the IB exam, with full markschemes. Give yourself about 1 minute per mark.

Question 1Paper 2[8 marks]

Consider the differential equation dydx=x2−y, with y=2 when x=1.

  • (a)Use Euler’s method with a step length of 0.1 to find an approximate value of y when x=1.3.[3]
  • (b)Use an integrating factor to show that y=x2−2x+2+e1−x.[4]
  • (c)Find the percentage error in your answer to (a).[1]
(a)
yn+1=yn+0.1(xn2−yn)(M1)
1.9, 1.831(A1)
y(1.3)≈1.79 (1.7919)A1
(b)
dydx+y=x2, I=exM1
yex=∫x2exdx=ex(x2−2x+2)+CM1A1
2=1+Ce−1⇒C=eA1AG
(c)
exact 1.8308; error 2.13%A1
Question 2Paper 1[6 marks]

Solve the differential equation xdydx+2y=x2, x>0, given that y=1 when x=1.

dydx+2xy=xM1
I=e2lnx=x2A1
ddx(x2y)=x3M1
x2y=x44+CA1
C=34A1
y=x24+34x2A1
Question 3Paper 1[6 marks]

Solve dydx+2y=4x, given that y=0 when x=0.

I=e2xA1
ye2x=∫4xe2xdxM1
by parts: 2xe2x−e2x+CM1A1
C=1A1
y=2x−1+e−2xA1

7Check yourself

Six quick questions, marked instantly. Aim for 6/6 before moving on. Fractions like 3/2 are accepted.

8Past-paper practice

Once you're scoring well above, try real IB questions. Your school or teacher will have these papers.

PaperQuestionFocusDifficulty
May 2024 · TZ2 · Paper 2Q12Euler’s method, then showing cotx is an integrating factor★★★
May 2023 · TZ1 · Paper 2Q12Euler’s method with step length 0.03★★
Nov 2025 · TZ3 · Paper 2Q12Euler’s method on a homogeneous equation★★★
May 2022 · TZ1 · Paper 2Q12Euler’s method with step length 0.1★★
Spotted a mistake on this page?Tell me and I'll fix it. The button opens an email with this page already named, or write to jamesashtonmaths@gmail.com.
Report a mistake