Instant PDF download, name-and-email checkout. Complete Book Bundle: every Economics, Statistics, Mathematics, Econometrics and Research Methods book
Mathematics

Euler’s Method and Slope Fields: Solving Differential Equations Step by Step

Learn Euler's method step by step with slope fields, a drug-dosage case, error checks and over- or underestimate reasoning, plus exam practice.

In 30 seconds
  • Euler’s method builds an approximate solution to a differential equation by taking small straight-line steps along the slope the equation gives you.
  • The update rule is \(y_{n+1} = y_n + h\,f(x_n, y_n)\): new value = old value + step size × slope.
  • A slope field draws those slopes as short segments, so you can see the shape of every solution before you solve anything.
  • In our case, a drug infused at 20 mg per hour and cleared at 25% per hour gives about 54.7 mg after 4 hours with Euler (step 1 hour); the exact answer is 50.6 mg.
  • Exam point: show a table of \(x_n\), \(y_n\) and the slope at each step, and say whether your estimate is too high or too low using concavity.

The case: how much drug is in the bloodstream after four hours?

A patient is given a drug through an intravenous drip. The drip delivers the drug at a steady 20 milligrams per hour. At the same time, the body clears the drug: the liver and kidneys remove about 25% of whatever is in the blood each hour. If \(A\) is the amount of drug in the bloodstream, in milligrams, after \(t\) hours, then

\[ \frac{dA}{dt} = 20 – 0.25A, \qquad A(0) = 0. \]

The first term is the inflow from the drip. The second term is the outflow, which grows as the amount grows. (The figures are illustrative; real dosing is set by clinicians using measured data for each drug.)

The nurse wants to know roughly how much drug is in the blood after 4 hours. A doctor also wants to know the level the drug is heading towards if the drip runs all day. This differential equation can be solved exactly, but many equations cannot. So we will first answer the question with a method that works for any first-order equation, Euler’s method, and then use the exact answer to judge how good the approximation is.

A different situation, a savings balance that earns interest while the saver adds a fixed sum each year, follows the same kind of equation. We will use it as a second worked example.

The concept: follow the slope, one small step at a time

A first-order differential equation \(\frac{dy}{dx} = f(x, y)\) tells you the gradient of the solution curve at every point. It does not tell you the curve directly. But if you know one point on the curve, you know the gradient there, and the tangent line at that point is a good guide to where the curve goes next, at least for a short distance.

Euler’s method uses exactly this idea. Start at the known point \((x_0, y_0)\). Move a small horizontal distance \(h\) along the tangent line. That gives a new point, which is close to the curve. Work out the slope again at the new point and take another step. Repeat until you reach the \(x\)-value you need.[3]

A slope field (also called a direction field) is the picture behind this. At a grid of points you draw a short segment with the gradient \(f(x, y)\). Solution curves must run along these segments, so the field shows the shape of every possible solution at once. Euler’s method is like walking across the slope field, always heading in the direction of the nearest segment.

Key termEuler’s method: a numerical method for approximating the solution of \(\frac{dy}{dx} = f(x, y)\) with \(y(x_0) = y_0\). From each point it moves a fixed step \(h\) in \(x\) along the tangent line, so each new \(y\)-value is the old one plus step size times the slope.
\[ x_{n+1} = x_n + h, \qquad y_{n+1} = y_n + h\,f(x_n, y_n) \]

Here \(x_n\) and \(y_n\) are the coordinates after \(n\) steps, \(h\) is the step size, and \(f(x_n, y_n)\) is the slope given by the differential equation at the current point. The term \(h\,f(x_n, y_n)\) is the rise along the tangent line: run times gradient. For the drug model, \(x\) is time \(t\), \(y\) is the amount \(A\) and \(f(t, A) = 20 – 0.25A\).

Mathematics Made Simple textbook coverMathematics Made Simple explains Euler’s method and slope fields with worked examples and graphs.Get the textbook · $12

Why this method fits the case

The drug question has the two things Euler’s method needs: a differential equation that gives the rate of change, and a starting value, \(A(0) = 0\). The nurse needs a number, not a formula, and Euler’s method delivers numbers directly. Each step is a single line of arithmetic, which you can do by hand, in a spreadsheet or on a calculator.

Euler’s method also works when no exact method exists. Equations such as \(\frac{dy}{dx} = x^2 – y^2\) or \(\frac{dy}{dx} = \sin(xy)\) cannot be solved with the separation of variables or integrating factors you learn at school. Numerical methods are the only way to get answers, and Euler’s method is the simplest of them. Because our drug equation can be solved exactly, it is a perfect test case: we can measure the error.

Euler’s method is not the right tool when you need high accuracy with few steps. Its error shrinks only in proportion to \(h\), so halving the step roughly halves the error. Professional software uses better methods, such as Runge–Kutta, that are far more accurate for the same effort. It is also a poor tool for very long time spans with a large step, where small errors can pile up. And when an exact solution is easy to find, as with a simple separable equation, use it.

Setting it up

Here are the quantities in the drug model.

QuantitySymbolValueMeaning
Time\(t\)hours from the start of the dripIndependent variable
Amount of drug\(A\)mg in the bloodstreamDependent variable
Infusion rate\(r\)20 mg per hourConstant inflow
Elimination rate\(k\)0.25 per hourFraction cleared each hour
Slope function\(f(t, A)\)\(20 – 0.25A\)Gradient at any point
Start\((t_0, A_0)\)\((0, 0)\)No drug at the start
Step size\(h\)1 hour (then 0.5)Width of each step

Before doing any arithmetic, read the slope field. When \(A = 80\), the slope is \(20 – 0.25(80) = 0\), so the segments are flat. Below 80 the slopes are positive; above 80 they are negative. Every solution is drawn towards \(A = 80\) mg. That is the steady level the doctor asked about: the point where inflow equals outflow.

Solving it

Worked example

Use Euler’s method with step size \(h = 1\) to estimate the amount of drug after 4 hours.

Step 1Start at \(t_0 = 0\), \(A_0 = 0\). Slope \(f = 20 – 0.25(0) = 20\). So \(A_1 = 0 + 1 \times 20 = 20\).
Step 2At \(t_1 = 1\), \(A_1 = 20\). Slope \(= 20 – 5 = 15\). So \(A_2 = 20 + 15 = 35\).
Step 3At \(t_2 = 2\), \(A_2 = 35\). Slope \(= 20 – 8.75 = 11.25\). So \(A_3 = 35 + 11.25 = 46.25\).
Step 4At \(t_3 = 3\), \(A_3 = 46.25\). Slope \(= 20 – 11.5625 = 8.4375\). So \(A_4 = 46.25 + 8.4375 = 54.6875\).

Euler’s method with \(h = 1\) estimates about 54.7 mg after 4 hours.

It is good practice to lay the working out as a table. Exam mark schemes reward this layout because each line can be checked.

\(n\)\(t_n\)\(A_n\)Slope \(20 – 0.25A_n\)\(A_{n+1} = A_n + h \times \text{slope}\)
0002020
11201535
223511.2546.25
3346.258.437554.6875
Worked example

Solve the equation exactly, find \(A(4)\), and compare it with Euler estimates using \(h = 1\), \(h = 0.5\) and \(h = 0.25\).

Step 1Separate: \(\frac{dA}{20 – 0.25A} = dt\). Integrate: \(-4\ln|20 – 0.25A| = t + C\).
Step 2At \(t = 0\), \(A = 0\): \(C = -4\ln 20\). So \(\ln\frac{20 – 0.25A}{20} = -0.25t\), giving \(20 – 0.25A = 20e^{-0.25t}\).
Step 3Rearrange: \(A(t) = 80\left(1 – e^{-0.25t}\right)\). At \(t = 4\): \(A(4) = 80(1 – e^{-1}) \approx 50.57\) mg.
Step 4Euler with \(h = 0.5\) (8 steps): the update is \(A_{n+1} = A_n + 0.5(20 – 0.25A_n) = 0.875A_n + 10\). This gives 10, 18.75, 26.41, 33.11, 38.97, 44.10, 48.58, 52.51.
Step 5Errors at \(t = 4\): \(h = 1\) gives \(54.69 – 50.57 = 4.12\); \(h = 0.5\) gives \(52.51 – 50.57 = 1.94\); \(h = 0.25\) gives \(51.51 – 50.57 = 0.94\).

Each halving of the step roughly halves the error, and every Euler estimate is too high.

Worked example

Savings balance. A saver has $5,000. The account pays 4% a year, compounded continuously, and the saver adds $1,200 a year in small regular amounts, so \(\frac{dB}{dt} = 0.04B + 1200\) with \(B(0) = 5000\). Use Euler’s method with \(h = 1\) year to estimate the balance after 3 years.

Step 1At \(t = 0\): slope \(= 0.04(5000) + 1200 = 1400\). \(B_1 = 5000 + 1400 = 6400\).
Step 2At \(t = 1\): slope \(= 256 + 1200 = 1456\). \(B_2 = 6400 + 1456 = 7856\).
Step 3At \(t = 2\): slope \(= 314.24 + 1200 = 1514.24\). \(B_3 = 7856 + 1514.24 = 9370.24\).
Step 4The exact solution is \(B(t) = 35000e^{0.04t} – 30000\), so \(B(3) = 35000e^{0.12} – 30000 \approx 9462.39\).

Euler estimates about $9,370, which is $92 too low. Here the curve bends upwards, so the tangent lines fall below it.

Mathematics Made Simple Practice Questions coverMake Euler’s method and slope fields automatic with the Practice Questions book: 1,565 questions, all fully worked.Get 1,565 questions · $9

What the answer tells us

After 4 hours of the drip, the patient has roughly 50 to 55 mg of the drug in the blood. Euler’s method with one-hour steps says 54.7 mg; the exact solution says 50.6 mg. For a quick estimate, the method did its job. For a clinical decision, you would use a smaller step or the exact formula.

Figure 1 shows the slope field for \(\frac{dA}{dt} = 20 – 0.25A\), the exact solution curve, and the Euler points with \(h = 1\). The segments flatten as they approach the dashed line at 80 mg, and the Euler points sit above the true curve.

Slope field, exact solution and Euler steps for the drug model mg of drug
Exact A(t) = 80(1 − e^(−0.25t))Euler steps, h = 1Steady level 80 mgSlope field
020406080100120024681012Euler 54.7exact 50.6steady level 80 mgTime since the drip started, t (hours)Amount of drug, A (mg)
Figure 1. Short segments show the slope 20 − 0.25A at each point. The Euler path (gold) overshoots the exact curve (blue) because the curve is concave down. Both approach the steady level of 80 mg. (Illustrative figures.)

Why Euler overshoots here. The exact curve is concave down: its gradient falls as \(A\) rises. A tangent line to a concave-down curve lies above the curve, so every Euler step lands a little too high. In the savings example the curve is concave up, so the tangent lines lie below and Euler underestimates. You can check concavity from the equation itself: for the drug, \(\frac{d^2A}{dt^2} = -0.25\frac{dA}{dt}\), which is negative while \(A\) is rising.

Reasonableness check. In the first hour the drip adds 20 mg, and clearance takes away less than 5 mg, because there is less than 20 mg in the blood. So \(A(1)\) should lie between 15 and 20 mg. The exact value is 17.7 mg, and the Euler value of 20 mg is at the top of that range, as expected for one big step that ignores clearance.

Sensitivity. The steady level is \(\frac{r}{k} = \frac{20}{0.25} = 80\) mg. Doubling the drip rate doubles it to 160 mg. If the patient’s kidneys work less well, so the elimination rate falls to 0.2 per hour, the steady level rises to 100 mg and it takes longer to get there. The time to reach 75% of the steady level is \(\frac{\ln 4}{k}\), which is about 5.5 hours when \(k = 0.25\). Slope fields make this kind of “what if” reasoning visual, which is why AP Calculus teaches slope fields (with Euler’s method in BC) and IB Mathematics: analysis and approaches HL teaches both, while Cambridge 9709 focuses on solving separable equations exactly.[1][2][4]

Common mistakeUsing the slope at the new point instead of the old one. Euler’s method always uses the slope at the start of the step, \(f(x_n, y_n)\). If you work out the slope at \(x_{n+1}\), you are doing a different method and will lose the method mark.
Common mistakeForgetting to multiply by \(h\). With \(h = 0.5\), the drug update is \(A_{n+1} = A_n + 0.5 \times \text{slope}\), not \(A_n + \text{slope}\). Adding the full slope makes every step twice as big as it should be, so your table drifts away fast. Also keep enough decimal places at each step and round only at the end.
Exam tipSet your working out as a table with columns for \(x_n\), \(y_n\), the slope and \(y_{n+1}\). Many exam questions then ask whether the estimate is an over- or underestimate. Answer with concavity: find \(\frac{d^2y}{dx^2}\) at the start (or say whether the slopes decrease or increase), state “concave down, so tangent lines lie above the curve, so overestimate”, and you have the reasoning mark. For slope-field questions, sketch through the given point and follow the segments; never cross a horizontal equilibrium line.

For a full chapter on slope fields, Euler’s method and separable equations, with graphs like the one above, see the Mathematics Made Simple textbook. To build speed with Euler tables and concavity arguments, use the Mathematics Made Simple Practice Questions book.

Mathematics Made Simple bundle coverMaster differential equations with both Mathematics Made Simple books for $16.Both books · $16

Practice questions

Work each one by hand, then open the worked answer to check.

EasyQ1. Given \(\frac{dy}{dx} = y\) and \(y(0) = 1\), use Euler’s method with \(h = 0.25\) to estimate \(y(1)\). Show worked answer
Each step multiplies by \(1 + 0.25 = 1.25\).
\(y_1 = 1.25\), \(y_2 = 1.5625\), \(y_3 = 1.953125\), \(y_4 = 2.44140625\).
Estimate: \(y(1) \approx 2.441\). The exact value is \(e \approx 2.718\), so Euler underestimates (the curve is concave up).
EasyQ2. For \(\frac{dy}{dx} = x + y\), \(y(0) = 1\), use \(h = 0.1\) to estimate \(y(0.3)\). Show worked answer
\(x_0 = 0, y_0 = 1\): slope 1, \(y_1 = 1.1\).
\(x_1 = 0.1\): slope 1.2, \(y_2 = 1.22\).
\(x_2 = 0.2\): slope 1.42, \(y_3 = 1.362\).
Estimate: \(y(0.3) \approx 1.362\). (Exact: \(2e^{0.3} – 1.3 \approx 1.400\).)
MediumQ3. For \(\frac{dy}{dx} = xy\), \(y(0) = 2\), use Euler’s method with \(h = 0.5\) to estimate \(y(1)\). Compare with the exact solution. Show worked answer
\(x_0 = 0\): slope \(0 \times 2 = 0\), so \(y_1 = 2\).
\(x_1 = 0.5\): slope \(0.5 \times 2 = 1\), so \(y_2 = 2 + 0.5 = 2.5\).
Exact: separating gives \(y = 2e^{x^2/2}\), so \(y(1) = 2e^{0.5} \approx 3.297\).
Euler’s 2.5 is well below, because the slope grows fast and two big steps miss the upward bend.
MediumQ4. A slope field is drawn for \(\frac{dy}{dx} = y(3 – y)\). (a) Find the equilibrium solutions. (b) Describe the solution through \((0, 1)\). Show worked answer
(a) Slope is zero when \(y = 0\) or \(y = 3\): horizontal lines \(y = 0\) and \(y = 3\).
(b) At \(y = 1\) the slope is \(1 \times 2 = 2 > 0\), so the curve rises. Slopes stay positive for \(0 < y < 3\), so it increases towards \(y = 3\) but never crosses it.
It is steepest at \(y = 1.5\), where the slope is \(2.25\).
ExamQ5. The function \(y = f(x)\) satisfies \(\frac{dy}{dx} = x^2 – y\) with \(f(0) = 1\). (a) Use Euler’s method with two steps of equal size to estimate \(f(0.4)\). (b) Find \(\frac{d^2y}{dx^2}\) at \((0, 1)\) and hence say whether the estimate is likely to be an overestimate or an underestimate near \(x = 0\). [5 marks] Show worked answer
(a) \(h = 0.2\). At \((0, 1)\): slope \(= 0 – 1 = -1\), so \(y_1 = 1 – 0.2 = 0.8\). [M1]
At \((0.2, 0.8)\): slope \(= 0.04 – 0.8 = -0.76\), so \(y_2 = 0.8 – 0.152 = 0.648\). [M1 A1]
(b) \(\frac{d^2y}{dx^2} = 2x – \frac{dy}{dx} = 2x – x^2 + y\). At \((0, 1)\): \(0 – 0 + 1 = 1 > 0\). [B1]
Concave up, so tangent lines lie below the curve and Euler underestimates. [A1] (The exact value is \(f(0.4) \approx 0.690\), confirming this.)

Frequently asked questions

How small should the step size be?

Small enough that halving it again barely changes the answer. In exams the step size is given. In practice, run the method with \(h\) and then \(h/2\); if the two answers agree to the accuracy you need, stop. For Euler’s method the error is roughly proportional to \(h\), so halving the step roughly halves the error, as the drug example showed.

What is the difference between a slope field and a solution curve?

A slope field shows the gradient at many points, for every possible solution at once. A solution curve is one particular solution, fixed by an initial condition such as \(A(0) = 0\). Through each point there is exactly one solution curve (for the well-behaved equations you meet at school), and it follows the segments of the field.

Can Euler’s method be used for second-order equations?

Yes, by turning one second-order equation into two first-order equations. For example, position and velocity are stepped forward together, each using its own derivative. This is how simple physics simulations in games and engineering work, although they normally use more accurate methods.

Why learn Euler’s method if computers do it better?

Because every better method is built on the same idea: use the slope to predict the next point. Understanding Euler’s method, and why it overshoots or undershoots, explains what numerical software is doing and when to trust it. It also links calculus to linearisation, since each step is a tangent-line approximation.

References

  1. College Board. AP Calculus AB and BC Course and Exam Description. New York: College Board.
  2. International Baccalaureate Organization (2019). Mathematics: analysis and approaches guide. Cardiff: IBO.
  3. Strang, G. & Herman, E. (2016). Calculus Volume 2. Houston, TX: OpenStax. openstax.org
  4. Cambridge Assessment International Education. Cambridge International AS & A Level Mathematics 9709: Syllabus for examination in 2026 and 2027. cambridgeinternational.org
Mathematics Made Simple complete bundle cover
This topic has a full chapter in Mathematics Made Simple, with 1,565 fully worked practice questions in the bundle.Mathematics Made Simple Complete Bundle — Textbook + 1,565 Practice Questions
Get it for $16
E

The EconTutorials team writes clear, exam-focused lessons in economics and statistics for A-Level, IB, AP and university students, with more than 13 years of classroom teaching behind every guide and book in the Made Simple series.