# How do I use Euler's method?

Approximates the solution of a differential equation y′ = f(x, y) with y(x₀) = y₀ by Euler’s method, in n equal steps from x₀ to a target x.

- Page: https://www.acalculator.org/math/eulers-method-calculator
- JSON spec: https://www.acalculator.org/math/eulers-method-calculator.json
- Version: 1c4ea9f559da

## Default answer

Example with the default inputs (y′ = f(x, y) 2x - 3, Starting x (x₀) 0, Starting y (y₀) 3, Target x 3, Number of steps (n) 6): Euler's method with 6 steps of h = 0.5 gives y(3) ≈ 1.5.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| f | y′ = f(x, y) | The right side of the differential equation, in x and y, for example 2x - 3 or x + y. |
| x0 | Starting x (x₀) | The x value where y is known. |
| y0 | Starting y (y₀) | The known value y(x₀). |
| x | Target x | The x value where you want y; it must differ from x₀. |
| n | Number of steps (n) | How many equal steps from x₀ to the target x; the step size is h = (target x − x₀) ÷ n. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| y | y at the target x | The Euler approximation of y at the target x. |
| h | Step size h | (target x − x₀) ÷ n, exactly from the typed decimals. |
| first | First step | y₁ = y₀ + h × f(x₀, y₀), written out. |

## Method

h = (target x − x₀) ÷ n; x_k = x₀ + k h; y_k = y_(k−1) + h × f(x_(k−1), y_(k−1)), for k = 1 to n.

## Assumptions

- Euler’s method follows the tangent line for one step at a time, so the error grows with h; halving h roughly halves it.
- x values are x₀ + n h, exactly from the typed decimals; y values are worked in double precision.
- 1 to 1,000 steps; each number from −10⁹ to 10⁹. The target x may be below x₀ (then h is negative).

## Worked examples

1. f = 2x - 3, x0 = 0, y0 = 3, x = 3, n = 6 gives y = 1.5, h = 0.5, first = y₁ = 3 + 0.5 × -3 = 1.5. Source: OpenStax, Calculus Volume 2, §4.2 Direction Fields and Numerical Methods: x_n = x₀ + nh, y_n = y_(n−1) + h f(x_(n−1), y_(n−1)) (https://openstax.org/books/calculus-volume-2/pages/4-2-direction-fields-and-numerical-methods, retrieved 2026-10-02): the table gives y₁ = 1.5, y₂ = 0.5, y₃ = 0, y₄ = 0, y₅ = 0.5, y₆ = 1.5.
2. f = y, x0 = 0, y0 = 1, x = 1, n = 4 gives y = 2.441406, h = 0.25. Source: OpenStax, Calculus Volume 2, §4.2 Direction Fields and Numerical Methods: x_n = x₀ + nh, y_n = y_(n−1) + h f(x_(n−1), y_(n−1)) (https://openstax.org/books/calculus-volume-2/pages/4-2-direction-fields-and-numerical-methods, retrieved 2026-10-02).
3. f = x + y, x0 = 0, y0 = 1, x = 0.3, n = 3 gives y = 1.362, h = 0.1. Source: OpenStax, Calculus Volume 2, §4.2 Direction Fields and Numerical Methods: x_n = x₀ + nh, y_n = y_(n−1) + h f(x_(n−1), y_(n−1)) (https://openstax.org/books/calculus-volume-2/pages/4-2-direction-fields-and-numerical-methods, retrieved 2026-10-02).

## FAQ

### What is Euler's method?

A way to approximate the solution of a differential equation y′ = f(x, y) with a known starting value y(x₀) = y₀. From each point it follows the tangent line for one short step: y_new = y + h × f(x, y), x_new = x + h.

### How do I use Euler's method by hand?

For y′ = 2x − 3, y(0) = 3 and h = 0.5: the slope at (0, 3) is −3, so y₁ = 3 + 0.5 × (−3) = 1.5 at x = 0.5. The slope there is −2, so y₂ = 1.5 + 0.5 × (−2) = 0.5 at x = 1. Repeat until you reach the target x.

### How do I choose the step size?

Smaller steps give a better answer but take more of them. Here you choose the number of steps n, and the step size is h = (target x − x₀) ÷ n. For y′ = y from 0 to 1, 4 steps give 2.441 and 100 steps give 2.705, against the exact e = 2.718.

### Why is Euler's method not exact?

It assumes the slope stays the same across each step, but the true solution curves. The error at the target shrinks roughly in proportion to h, so halving the step about halves the error.

### What can I type for f(x, y)?

Numbers, x and y, + − × ÷ and ^ for powers, brackets, and functions such as sin, cos, tan, exp, ln (natural log), sqrt and abs. 2x means 2 × x. Angles in sin and cos are in radians.

### Can the target x be smaller than x₀?

Yes. Then h is negative and the method walks backwards from x₀.

## Sources

- OpenStax, Calculus Volume 2, §4.2 Direction Fields and Numerical Methods (Euler’s method x_n = x₀ + nh, y_n = y_(n−1) + h f(x_(n−1), y_(n−1)); worked table for y′ = 2x − 3, y(0) = 3, h = 0.5), CC BY 4.0, retrieved 2026-10-02. https://openstax.org/books/calculus-volume-2/pages/4-2-direction-fields-and-numerical-methods
