Free access until 31 December 2026 · Physics and Maths questions and notes, updated continuously · Build a test

ExaminerPrep › IB Maths AA › Notes

IB Maths AA · Topic 5 · 5.18 · HL only

First order differential equations

This note covers first order differential equations: equations linking \(y\), \(x\) and \(\tfrac{dy}{dx}\). You will solve them by separating variables, by a substitution for homogeneous equations and by an integrating factor, and approximate solutions with Euler's method. They model growth, cooling, mixing and many other changing quantities.

Key ideas

A first order differential equation contains \(\tfrac{dy}{dx}\) but no higher derivatives. A general solution contains an arbitrary constant. A particular solution uses a given condition, such as \(y=2\) when \(x=0\), to find that constant.

1. Separation of variables. If the equation can be written \(\tfrac{dy}{dx}=f(x)\,g(y)\), move all \(y\) terms to one side and all \(x\) terms to the other:

\[\int \frac{1}{g(y)}\,dy=\int f(x)\,dx\]

Integrate both sides, add one constant, then use the condition. Solve for \(y\) if the question asks for \(y\) in terms of \(x\).

2. Homogeneous equations. If \(\tfrac{dy}{dx}\) can be written as a function of \(\tfrac{y}{x}\) only, substitute \(y=vx\), where \(v\) is a function of \(x\). By the product rule \(\tfrac{dy}{dx}=v+x\tfrac{dv}{dx}\). The equation then becomes separable in \(v\) and \(x\). At the end replace \(v\) by \(\tfrac{y}{x}\).

3. Integrating factor. An equation of the form

\[\frac{dy}{dx}+P(x)\,y=Q(x)\]

is solved by multiplying through by \(I(x)=e^{\int P(x)\,dx}\). The left side then becomes the derivative of a product:

\[\frac{d}{dx}\bigl(I\,y\bigr)=I\,Q\]

Integrate both sides, then divide by \(I\). The constant of integration in \(\int P\,dx\) is not needed.

4. Euler's method. When no exact solution is wanted, step along the curve using the gradient. With step size \(h\) and \(\tfrac{dy}{dx}=f(x,y)\):

\[x_{n+1}=x_n+h,\qquad y_{n+1}=y_n+h\,f(x_n,y_n)\]

Smaller steps usually give a better estimate. The method follows tangent lines, so it drifts away from a curved solution.

Checking a solution. You can always test an answer by differentiating it and substituting back into the original equation, and by confirming it satisfies the given condition. This takes under a minute and catches most slips.

Using a model. In context questions, the sign of the constant tells you what is happening. In \(\tfrac{dT}{dt}=-k(T-20)\) with \(k\gt0\), the temperature falls when \(T\gt20\) and rises when \(T\lt20\), levelling off at 20. Always state the final answer with its units and, for cooling or growth, check that it is sensible.

Euler accuracy. The estimate uses the gradient at the start of each step. If the true curve bends upwards, as in Example 3 where the exact value is about 2.04, Euler's method underestimates. Halving \(h\) roughly halves the error, at the cost of twice as many steps.

Definitions and formulae

Term or formulaMeaning / when to use
\(\tfrac{dy}{dx}=f(x)g(y)\)Separable equation. Rearrange to \(\int\tfrac{1}{g(y)}dy=\int f(x)dx\).
\(y=vx\)Substitution for an equation where \(\tfrac{dy}{dx}\) depends only on \(\tfrac{y}{x}\). Gives \(\tfrac{dy}{dx}=v+x\tfrac{dv}{dx}\).
\(\tfrac{dy}{dx}+P(x)y=Q(x)\)Linear first order form, solved with an integrating factor.
\(I(x)=e^{\int P\,dx}\)Integrating factor. Then \(Iy=\int IQ\,dx\).
\(y_{n+1}=y_n+h f(x_n,y_n)\)Euler step. Use it with \(x_{n+1}=x_n+h\).
General / particular solutionWith the constant / with the constant fixed by a condition.

Worked examples

Example 1 A cup of coffee at \(90^\circ\text{C}\) cools in a room at \(20^\circ\text{C}\). Its temperature \(T\) after \(t\) minutes satisfies \(\tfrac{dT}{dt}=-k(T-20)\), where \(k\gt 0\). After 5 minutes the temperature is \(60^\circ\text{C}\). Find the temperature after 10 minutes.

Separate the variables: \(\int\tfrac{1}{T-20}\,dT=\int -k\,dt\).

Integrate: \(\ln|T-20|=-kt+c\), so \(T-20=Ae^{-kt}\) where \(A=\pm e^{c}\). Since \(T\gt 20\), \(T=20+Ae^{-kt}\).

At \(t=0\), \(T=90\): \(90=20+A\), so \(A=70\).

At \(t=5\), \(T=60\): \(40=70e^{-5k}\), so \(e^{-5k}=\tfrac{4}{7}\), giving \(k=\tfrac15\ln\tfrac74\approx 0.112\).

At \(t=10\): \(e^{-10k}=\left(\tfrac47\right)^{2}=\tfrac{16}{49}\), so \(T=20+70\times\tfrac{16}{49}=20+22.857\ldots\)

Answer: \(T\approx 42.9^\circ\text{C}\).

Example 2 Solve \(\tfrac{dy}{dx}+\tfrac{2}{x}y=x^{2}\) for \(x\gt 0\), given that \(y=2\) when \(x=1\). Find \(y\) when \(x=2\).

Here \(P(x)=\tfrac2x\). Then \(\int P\,dx=2\ln x\), so \(I=e^{2\ln x}=x^{2}\).

Multiply through by \(x^{2}\): \(\tfrac{d}{dx}(x^{2}y)=x^{4}\).

Integrate: \(x^{2}y=\tfrac{x^{5}}{5}+C\), so \(y=\tfrac{x^{3}}{5}+\tfrac{C}{x^{2}}\).

Use \(y=2\) at \(x=1\): \(2=\tfrac15+C\), so \(C=\tfrac95\).

\[y=\frac{x^{3}}{5}+\frac{9}{5x^{2}}\]

At \(x=2\): \(y=\tfrac85+\tfrac{9}{20}=1.6+0.45\).

Answer: \(y=2.05\).

Example 3 Given \(\tfrac{dy}{dx}=x+y\) and \(y=1\) when \(x=0\), use Euler's method with step size \(h=0.2\) to estimate \(y\) when \(x=0.6\).

Start: \(x_0=0,\ y_0=1\). Gradient \(=x_0+y_0=1\).

\(y_1=1+0.2(1)=1.2\), at \(x_1=0.2\).

Gradient \(=0.2+1.2=1.4\). \(y_2=1.2+0.2(1.4)=1.48\), at \(x_2=0.4\).

Gradient \(=0.4+1.48=1.88\). \(y_3=1.48+0.2(1.88)=1.856\), at \(x_3=0.6\).

Answer: \(y(0.6)\approx 1.86\).

Common errors

  • Common error: Forgetting the constant of integration until the end, or adding one on each side. Add a single constant straight after integrating.
  • Common error: Using the integrating factor on an equation whose \(\tfrac{dy}{dx}\) has a coefficient other than 1. Divide first so the equation is in the form \(\tfrac{dy}{dx}+Py=Q\).
  • Common error: Forgetting to multiply the right-hand side by the integrating factor. The right side becomes \(I\,Q\), not \(Q\).
  • Common error: In the substitution \(y=vx\), writing \(\tfrac{dy}{dx}=\tfrac{dv}{dx}\). The product rule gives \(v+x\tfrac{dv}{dx}\).
  • Common error: In Euler's method, using the new \(y\)-value to find the gradient for the same step, or forgetting to update \(x\) each step.

Exam tip: Decide the type first. Can you separate the variables? Is the right side a function of \(\tfrac yx\)? Is it of the form \(\tfrac{dy}{dx}+Py=Q\)? In Euler questions, set out a small table of \(x_n\), \(y_n\) and gradient.

Check yourself

  1. Solve \(\tfrac{dy}{dx}=3x^{2}y\) given \(y=2\) when \(x=0\).
    Answer\(\int\tfrac1y\,dy=\int 3x^{2}\,dx\) gives \(\ln|y|=x^{3}+c\), so \(y=Ae^{x^{3}}\). With \(y(0)=2\), \(A=2\), so \(y=2e^{x^{3}}\).
  2. Given \(\tfrac{dy}{dx}=2x+y\) and \(y=1\) at \(x=1\), use Euler's method with \(h=0.5\) to estimate \(y\) at \(x=2\).
    AnswerGradient at \((1,1)\) is 3, so \(y=1+0.5(3)=2.5\) at \(x=1.5\). Gradient is \(3+2.5=5.5\), so \(y=2.5+0.5(5.5)=5.25\) at \(x=2\).
  3. Solve \(\tfrac{dy}{dx}-y=e^{2x}\) given \(y=3\) when \(x=0\).
    Answer\(P=-1\), so \(I=e^{-x}\). Then \(\tfrac{d}{dx}(e^{-x}y)=e^{x}\), so \(e^{-x}y=e^{x}+C\) and \(y=e^{2x}+Ce^{x}\). With \(y(0)=3\): \(3=1+C\), \(C=2\). So \(y=e^{2x}+2e^{x}\).
  4. Use \(y=vx\) to solve \(\tfrac{dy}{dx}=\tfrac{x+y}{x}\), given \(y=0\) when \(x=1\), for \(x\gt 0\). Find \(y\) when \(x=e\).
    AnswerThe equation is \(\tfrac{dy}{dx}=1+\tfrac yx=1+v\). Then \(v+x\tfrac{dv}{dx}=1+v\), so \(x\tfrac{dv}{dx}=1\) and \(v=\ln x+C\). Hence \(y=x\ln x+Cx\). With \(y(1)=0\): \(C=0\). So \(y=x\ln x\) and at \(x=e\), \(y=e\).