Differential Equation Calculator for First-Order ODEs

Approximate an initial-value problem in the form y′ = f(x,y), y(x₀) = y₀. Choose RK4, improved Euler, or Euler to calculate the value at a target x, inspect solution points, and export the data. Everything runs locally in your browser.

Enter the initial-value problem

Use ^ for powers. Functions include sin, cos, exp, ln, sqrt, and abs. Trigonometric inputs use radians.

Initial condition y(x₀) = y₀
Try an example

Keyboard shortcut: Ctrl/ + Enter.

Advertisement

Numerical solution

Enter an equation and calculate.
y(—) ≈ —
The initial-value problem summary will appear here.
Step size h
Steps
Error estimate

This is a numerical approximation, not a symbolic general solution. The estimate compares the selected step count with twice as many steps.

Solution graph

The graph connects the numerical solution points from the initial x to the target x.

View numerical solution points

The table will show the calculated points. Long results are sampled on screen; the CSV contains every point.

Step nxₙyₙf(xₙ,yₙ)
Calculate to generate the table.

Scope, precision, and privacy

Problem type
Explicit first-order initial-value problems y′=f(x,y) with one condition y(x₀)=y₀.
Input limits
Expressions up to 300 characters, finite input values from −1 trillion to 1 trillion, and 1 to 50,000 requested steps.
Accuracy
Step doubling gives a practical estimate under smooth, stable behavior. It is not a rigorous error bound.
Privacy
Your equation, initial values, and solution remain on your device; no solving API receives them.
Numerical limits
Singularities, stiffness, sharp changes, unstable equations, or a large step size can make a result unreliable or stop the calculation.
Units
Use one consistent unit system. The calculator treats x, y, and f(x,y) as numeric quantities and does not convert units.

How the first-order ODE calculator works

The interval from x₀ to the target x is split into N equal steps. The signed step size is:

h = (x_target − x₀) / N

A target below x₀ produces a negative h, so the same formulas integrate backward. Each method estimates the next y value from slopes supplied by f(x,y).

Euler method

yₙ₊₁ = yₙ + h f(xₙ,yₙ)

Euler uses the slope at the beginning of each step. It is first-order, transparent, and useful for learning, but often needs small steps.

Improved Euler (Heun)

yₙ₊₁ = yₙ + h(k₁+k₂)/2

Here k₁=f(xₙ,yₙ) and k₂=f(xₙ+h,yₙ+hk₁). Averaging the predicted endpoint slope makes it second-order.

RK4

yₙ₊₁ = yₙ + h(k₁+2k₂+2k₃+k₄)/6

RK4 combines one starting slope, two midpoint slopes, and one endpoint slope. It is fourth-order and the recommended general-purpose option here.

Understanding the error estimate

The calculator solves the problem once with N steps and again with 2N steps. For the displayed N-step result, it reports 2ᵖ|y₂N−yN|/(2ᵖ−1), where p is 1 for Euler, 2 for Heun, and 4 for RK4. This estimate assumes the solution and numerical method are behaving regularly over the interval. Reduce the step size and check that the answer stabilizes.

Worked first-order ODE examples

Exponential growth

For y′=y and y(0)=1, the exact comparison value is y(1)=e≈2.71828. RK4 approaches it rapidly as the step count increases.

Linear equation

For y′=x+y and y(0)=1, the exact solution is y=2eˣ−x−1. At x=1, the value is about 3.43656.

Newton cooling model

y′=−0.2(y−20) models a value moving toward ambient level 20. With y(0)=90, the numerical curve decays toward 20.

First-order differential equation FAQs

What differential equations can this calculator solve?

It numerically approximates explicit first-order initial-value problems written as y′=f(x,y) with one initial condition y(x₀)=y₀. It does not directly accept implicit equations, systems, boundary-value problems, or derivatives above first order.

Which numerical method should I choose?

RK4 is the best general-purpose choice here. Improved Euler is useful for learning a second-order method. Euler shows the basic tangent-step idea, but it usually needs more steps for similar accuracy.

Is the result an exact solution?

No. The displayed value is a numerical approximation using the selected method and step count. The error estimate compares it with a calculation using twice as many steps; it is not a guaranteed bound.

How many steps should I use?

Start with RK4 and 20 to 100 steps for a smooth classroom problem. Then double the count and check whether the digits you need remain stable. Difficult or stiff equations can require a specialized adaptive or implicit solver.

Can the calculator integrate backward?

Yes. Enter a target x smaller than the initial x. The calculator automatically uses a negative step size and lists the points in integration order.

Why did the calculation stop near a particular x?

The expression may be undefined there, the numerical solution may have grown beyond the supported range, or the chosen step size may be too large. Check the equation's domain and try a shorter interval or more steps.

Does the calculator find symbolic general solutions?

No. It solves one numerical initial-value problem over one interval. It does not derive a symbolic family containing an arbitrary constant. Use the numerical graph and table only over the interval you entered.

Are my equation and initial values uploaded?

No. Expression parsing, numerical integration, graphing, copying, permalink creation, and CSV generation all run locally in your browser.

Explore more mathematical tools

Explore more tools