Sign up
∂

Differential Equation Solver

Solve first-order ODEs numerically using Runge-Kutta 4.

ODE Setup

Pick an ODE and set initial conditions.

Analytic: y = e^x

Must be positive. Direction is derived from x_end − x₀.

Solve ordinary differential equations using numerical methods.

About this topic

What is an ODE? An equation involving a function and its derivatives.

An Ordinary Differential Equation (ODE) relates a function to its derivatives with respect to a single variable. Solving it means finding the function that satisfies the equation.

Key formulas & rules

  • •Order = highest derivative present
  • •Linear if no products of y and its derivatives
  • •Homogeneous if RHS = 0
  • •General solution has arbitrary constants
  • •Particular solution requires initial conditions
  • •Existence & uniqueness guaranteed under mild conditions

Examples

Input Output Note
dy/dx = y y = Ce^x First order
y″ + y = 0 y = A·sin x + B·cos x Second order
dy/dx = −y, y(0)=5 y = 5e^(−x) With IC
dy/dx = 2x y = x² + C Simple integration

Real-world uses

Population growth Radioactive decay Spring-mass systems
Euler Method Simplest numerical method — one step at a time.

Euler's method approximates the solution by following the tangent line at each step. It's easy to implement but has limited accuracy.

Key formulas & rules

  • •y_{n+1} = y_n + h·f(x_n, y_n)
  • •First-order accuracy: error ∝ h
  • •Small h → higher accuracy
  • •Unstable for stiff equations
  • •Fast but imprecise
  • •Basis for more advanced methods

Examples

Input Output Note
dy/dx = y, y(0)=1, h=0.1 y(1) ≈ 2.59 vs exact e ≈ 2.718
h = 0.01 y(1) ≈ 2.70 Better with smaller h
h = 1 y(1) = 2 Very rough
dy/dx = x, y(0)=0 Parabola Approximation

Real-world uses

Quick simulations Teaching tool Real-time systems
Runge-Kutta 4 (RK4) Industry-standard numerical ODE solver.

RK4 takes four slope estimates per step and combines them with weighted averages. It achieves fourth-order accuracy with only four function evaluations per step.

Key formulas & rules

  • •k₁ = f(x, y)
  • •k₂ = f(x + h/2, y + h·k₁/2)
  • •k₃ = f(x + h/2, y + h·k₂/2)
  • •k₄ = f(x + h, y + h·k₃)
  • •y_{n+1} = y_n + (h/6)(k₁ + 2k₂ + 2k₃ + k₄)
  • •Fourth-order accuracy: error ∝ h⁴

Examples

Input Output Note
dy/dx = y, y(0)=1, h=0.1 y(1) ≈ 2.718 Matches e
dy/dx = y², y(0)=1, h=0.1 Blow-up near x=1 Finite-time blow-up
RK4 vs Euler at h=0.1 RK4 much closer Superior accuracy
dy/dx = -y, y(0)=10 Decay curve Exponential decay

Real-world uses

Physics simulations Orbital mechanics Chemical kinetics
Applications of ODEs ODEs model change in almost every science.

Anything that changes over time can be modeled by an ODE. From bacteria growth to planetary orbits to electrical circuits, ODEs are the workhorse of applied mathematics.

Key formulas & rules

  • •Physics: F = ma → m·x″ = F(x)
  • •Biology: dP/dt = rP(1 − P/K)
  • •Chemistry: rate laws d[A]/dt = −k[A]
  • •Economics: Solow growth model
  • •Epidemiology: SIR model
  • •Circuits: L·I″ + R·I′ + I/C = V(t)

Examples

Input Output Note
Bacteria growth dP/dt = rP Exponential
Cooling (Newton) dT/dt = −k(T − Tₐ) Approaches ambient
SIR epidemic 3 coupled ODEs S, I, R compartments
Radioactive decay dN/dt = −λN Half-life

Real-world uses

Weather forecasting Drug dosage Traffic flow

Modes & formulas

1

RK4 Numerical Solver

• Choose a preset ODE (e.g., dy/dx = y, dy/dx = x − y, logistic growth). • Enter initial conditions (x₀, y₀), the endpoint (x_end), and a step size h. • The solver integrates using RK4 and plots the solution curve.
y_{n+1} = y_n + (h/6)(k₁ + 2k₂ + 2k₃ + k₄)

RK4 takes four slope estimates per step and combines them with weights (1, 2, 2, 1). The local error is O(h⁵) and the global error is O(h⁴) — fourth-order accuracy.

2

Backward Integration

• If x_end < x₀, the solver integrates in the negative direction. • The step size remains positive; only the direction of integration flips. • The final result y(x_end) is still correct.
h_step = direction × h | direction = sign(x_end − x₀)

Backward integration is useful for finding past states of a system given a current state. The RK4 weights stay the same; only the sign of the step changes.

How to use it

Pick a preset ODE, set initial conditions and step size, and click Calculate. The solution curve is plotted, and the final value is displayed.

Frequently asked questions

What is the difference between Euler and RK4?
Euler uses one slope estimate per step (first-order accuracy). RK4 uses four weighted estimates (fourth-order accuracy), so it is dramatically more accurate for the same step size.
How do I choose a step size h?
Smaller h gives higher accuracy but more computation. Start with h = 0.05 and halve it if the solution looks unstable.
What is an ODE?
An Ordinary Differential Equation is an equation that contains one or more functions of one independent variable and its derivatives.
What is the Runge-Kutta 4th order (RK4) method?
It is a numerical technique used to solve ODEs. It evaluates the slope at four different points within each step to achieve high accuracy.
Why use RK4 instead of the Euler method?
Euler’s method uses only one slope estimate per step and accumulates error quickly. RK4 uses four weighted estimates, achieving vastly better accuracy for the same step size.
What are initial conditions?
The starting point of the system, typically given as x₀ and y₀. Without an initial condition, a differential equation has infinite solutions.

Related calculators

Read the full Differential Equation Solver guide — examples & 18 FAQs