{
  "id": "eulers-method",
  "version": "1c4ea9f559da",
  "status": "published",
  "name": "Euler's Method Calculator",
  "question": "How do I use Euler's method?",
  "summary": "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.",
  "category": "math",
  "subcategory": "calculus",
  "url": "https://www.acalculator.org/math/eulers-method-calculator",
  "markdown": "https://www.acalculator.org/math/eulers-method-calculator.md",
  "kind": "schedule",
  "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)."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "f": {
        "title": "y′ = f(x, y)",
        "description": "The right side of the differential equation, in x and y, for example 2x - 3 or x + y.",
        "type": "string",
        "maxLength": 200
      },
      "x0": {
        "title": "Starting x (x₀)",
        "description": "The x value where y is known.",
        "type": "number",
        "minimum": -1000000000,
        "maximum": 1000000000
      },
      "y0": {
        "title": "Starting y (y₀)",
        "description": "The known value y(x₀).",
        "type": "number",
        "minimum": -1000000000,
        "maximum": 1000000000
      },
      "x": {
        "title": "Target x",
        "description": "The x value where you want y; it must differ from x₀.",
        "type": "number",
        "minimum": -1000000000,
        "maximum": 1000000000
      },
      "n": {
        "title": "Number of steps (n)",
        "description": "How many equal steps from x₀ to the target x; the step size is h = (target x − x₀) ÷ n.",
        "type": "integer",
        "minimum": 1,
        "maximum": 1000
      }
    }
  },
  "outputs": {
    "y": {
      "label": "y at the target x",
      "description": "The Euler approximation of y at the target x.",
      "format": "number"
    },
    "h": {
      "label": "Step size h",
      "description": "(target x − x₀) ÷ n, exactly from the typed decimals.",
      "format": "number"
    },
    "first": {
      "label": "First step",
      "description": "y₁ = y₀ + h × f(x₀, y₀), written out.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "f": "2x - 3",
      "x0": 0,
      "y0": 3,
      "x": 3,
      "n": 6
    },
    "outputs": {
      "y": 1.5,
      "h": 0.5,
      "first": "y₁ = 3 + 0.5 × -3 = 1.5"
    },
    "text": "Euler's method with 6 steps of h = 0.5 gives y(3) ≈ 1.5."
  },
  "examples": [
    {
      "given": {
        "f": "2x - 3",
        "x0": 0,
        "y0": 3,
        "x": 3,
        "n": 6
      },
      "expect": {
        "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"
    },
    {
      "given": {
        "f": "y",
        "x0": 0,
        "y0": 1,
        "x": 1,
        "n": 4
      },
      "expect": {
        "y": 2.44140625,
        "h": 0.25
      },
      "source": "hand calculation in content.mdx: 1.25⁴ = 2.44140625 (the exact solution is e = 2.71828); 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)"
    },
    {
      "given": {
        "f": "x + y",
        "x0": 0,
        "y0": 1,
        "x": 0.3,
        "n": 3
      },
      "expect": {
        "y": 1.362,
        "h": 0.1
      },
      "source": "hand calculation in content.mdx: y₁ = 1.1, y₂ = 1.1 + 0.1 × 1.2 = 1.22, y₃ = 1.22 + 0.1 × 1.42 = 1.362; 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)"
    }
  ],
  "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"
  ],
  "related": [
    "derivative",
    "integral",
    "tangent-line",
    "linear-approximation"
  ],
  "changelog": []
}
