Updated Math

Differential Equation Calculator

Solve and model ODEs with Euler and RK4 for y′=f(x,y), linear first-order ODEs, separable forms, and second-order constant-coefficient equations with optional initial conditions.

IVP Solver RK4 Linear ODE 2nd Order

Differential Equations Solver & Numeric Table Builder

Choose a mode to solve an ODE numerically (Euler/RK4), compute linear first-order solutions, solve separable forms, or compute closed-form solutions for second-order constant coefficients.

What a Differential Equation Is

A differential equation is an equation that relates a function to one or more of its derivatives. Instead of asking “what is y when x equals 3,” a differential equation asks a deeper question: “how does y change as x changes,” and how that change depends on x, y, and sometimes higher derivatives like y″. This is why differential equations are the natural language of motion, growth, diffusion, circuits, control systems, and many models in science and engineering.

In the most common ordinary differential equation (ODE) setting, you have a single independent variable (often x or time t) and one dependent variable y(x). A first derivative y′ describes slope or rate of change. A second derivative y″ describes curvature or acceleration. Many real-world laws are stated as relationships between these derivatives and the current state.

ODEs vs PDEs

Ordinary differential equations involve derivatives with respect to one variable, such as dy/dx. Partial differential equations (PDEs) involve partial derivatives with respect to multiple variables, such as ∂u/∂t and ∂u/∂x. This tool is designed for ODEs and common ODE workflows: initial value problems, numeric integration tables, separable and linear first-order equations, and classic second-order constant-coefficient equations.

Initial Value Problems and Why They Matter

Many differential equations represent not one curve but a family of curves. A first-order ODE typically has infinitely many solutions that differ by a constant. To select a unique solution, you provide an initial condition like y(x₀)=y₀. Together, the ODE and the initial condition form an initial value problem (IVP). For second-order equations, you usually need two conditions, such as y(x₀)=y₀ and y′(x₀)=v₀, because the general solution includes two constants.

This calculator emphasizes IVP-solving because it matches how differential equations are used in practice. You usually know an initial state (starting position, initial population, initial voltage) and want the predicted evolution as x or time moves forward.

Numeric Solvers: Euler and Runge–Kutta (RK4)

Many differential equations cannot be solved in a simple closed form, and even when they can, a numeric table is often still useful for plotting or simulation. Numeric methods approximate the solution by stepping forward from the initial condition.

Euler’s method is the simplest approach. At each step, it uses the slope at the current point: yn+1 = yn + h f(xn, yn). Euler is intuitive but may require very small step sizes h for accuracy or stability.

RK4 (the classical fourth-order Runge–Kutta method) is a common default because it samples the slope multiple times inside the step and blends the information to produce a more accurate update. It usually achieves far better accuracy than Euler at the same step size, which is why many engineering and scientific tools treat RK4 as the baseline general-purpose solver.

Choosing a Step Size

Step size h controls the tradeoff between speed and accuracy. Smaller h usually improves accuracy, but it increases the number of steps and the amount of computation. Too large a step size can cause oscillations, drift, or entirely incorrect behavior, especially in stiff systems where the true solution changes rapidly in one regime but slowly in another. If your results look unstable, reduce h. If your table is too large, increase h carefully and compare.

Linear First-Order ODEs: y′ + P(x)y = Q(x)

Linear first-order equations form one of the most important solvable families. The key idea is the integrating factor. If the equation is written as y′ + P(x)y = Q(x), you define an integrating factor μ(x) = e^{∫P(x)dx}. Multiplying the entire equation by μ(x) turns the left side into a derivative: (μy)′ = μQ. Then you integrate to get μy = ∫ μQ dx + C and finally y(x) = (1/μ(x))(∫ μ(x)Q(x)dx + C).

In many classroom problems, you can compute the integrals symbolically. In applied problems, P(x) and Q(x) may be complicated and require numerical integration anyway. This tool uses the integrating factor structure while building μ(x) and the accumulated integral numerically across a grid, producing a solution table anchored to your initial condition.

Separable ODEs: y′ = g(x)h(y)

Separable equations are another classic family. If y′ = g(x)h(y), you can rearrange terms to separate y and x: dy/h(y) = g(x)dx. Integrating both sides gives an implicit relation ∫ dy/h(y) = ∫ g(x)dx + C. Depending on h(y), you may be able to solve explicitly for y(x). Even when you cannot isolate y neatly, the implicit equation still defines the solution curve.

This calculator focuses on the practical output you often need: a numerical solution table for y′ = g(x)h(y) with an initial condition. That table is compatible with plotting and scenario testing, and it also supports CSV export.

Second-Order Constant-Coefficient Equations

Many mechanical and electrical systems reduce to second-order homogeneous equations like ay″ + by′ + cy = 0. Examples include spring–mass–damper systems, RLC circuits, and linearized oscillators. The standard solution method uses the characteristic equation ar² + br + c = 0. The nature of the roots determines the solution type:

  • If the roots are real and distinct, the solution is a sum of exponentials.
  • If the root is repeated, the solution has an extra factor of x multiplying one exponential term.
  • If the roots are complex, the solution uses exponentials times sine and cosine, which naturally describes oscillation with damping.

This tool computes the root case automatically, displays the solution form, and uses your initial conditions y(x₀) and y′(x₀) to solve for the constants. It then builds a value table you can export to CSV.

Common Input Functions and Syntax

You can enter expressions using standard math functions: sin(x), cos(x), tan(x), exp(x), sqrt(x), abs(x), log(x) for natural log, and powers using ^. Variables are x and y depending on the mode. For example:

  • IVP: f(x,y) = x - y
  • IVP: f(x,y) = sin(x) - y^2
  • Linear: P(x)=1/(1+x), Q(x)=exp(x)
  • Separable: g(x)=x, h(y)=y*(1-y)

If you include discontinuities or singularities, numerical methods can break down. For example, 1/(x-1) is undefined at x=1, so do not step across that point. Instead, choose a domain that avoids singularities or reduce step size and stop before the singular point.

Interpreting Tables and Exporting Results

Tables show the computed x values, y values, and helpful intermediate terms like slopes or integrating factors. This is designed for transparency: you can see how the solution evolves step by step. Exporting to CSV lets you plot the curve, compare different step sizes, or run further analysis in a spreadsheet.

Limitations and Best Practices

Numerical solutions are approximations. When accuracy matters, compare results at multiple step sizes (for example, h and h/2). If the solution changes significantly when you halve the step size, you have not converged yet. For stiff problems, standard Euler or RK4 may require extremely small h, and specialized stiff solvers may be more appropriate. This tool is intended for planning, learning, and general numeric modeling rather than high-stakes simulation.

FAQ

Differential Equation Calculator – Frequently Asked Questions

Answers about ODE types, Euler vs RK4, linear and separable forms, second-order solutions, accuracy, and CSV export.

It estimates or solves equations involving derivatives, such as y′ or y″. Depending on the equation type, it can produce a symbolic-form solution (like for constant-coefficient ODEs) and/or a numerical solution table using methods such as Euler or Runge–Kutta (RK4).

An ordinary differential equation (ODE) has derivatives with respect to one independent variable (like x or t). A partial differential equation (PDE) has partial derivatives with respect to multiple variables (like x and t). This tool focuses on ODEs.

An IVP specifies a differential equation plus initial conditions such as y(x0)=y0 (and sometimes y′(x0)=v0). The calculator uses these conditions to produce a unique solution curve rather than a family of solutions.

Euler is simpler and faster but less accurate. RK4 is usually much more accurate for the same step size and is a common default for reliable numerical solutions.

A linear first-order ODE has the form y′ + P(x)y = Q(x). It is solved with an integrating factor μ(x)=e^{∫P(x)dx}, giving y(x) = (1/μ(x)) (∫ μ(x)Q(x)dx + C). This tool can compute a numerical solution curve using this structure.

A separable ODE can be written as y′ = g(x)h(y), allowing separation: dy/h(y) = g(x)dx. Many separable problems have an implicit closed form, and this calculator can also compute a numerical solution table.

For ay″+by′+cy=0, you form the characteristic equation ar^2+br+c=0. Its roots determine whether the solution uses exponentials, repeated-root forms, or exponentials with sine/cosine for complex roots. This calculator computes the form and constants from initial conditions when provided.

Numerical methods approximate derivatives and integrals using a finite step size. Smaller steps generally improve accuracy but increase computation. Stiff equations or rapidly changing solutions may require very small step sizes or specialized methods.

Yes. Each table mode supports exporting results to CSV so you can chart the solution or run further analysis in a spreadsheet.

Numerical results are approximations and depend on step size and equation behavior. Avoid stepping across singularities, and reduce step size if results appear unstable.