Type to search, in English or Thai

  1. Home
  2. Tools
  3. ODE solver

// Tools · Differential Equation Solver

Differential Equation Solver (ODE Solver): First and Second Order, With Every Step

Enter a, b and c, pick the forcing f(t), set the initial conditions and press Solve. The tool writes the characteristic equation, finds its roots, picks the form of the solution, finds the particular solution, applies the initial conditions and plots the result. Every answer is re-checked against a fourth-order Runge–Kutta integration before it is shown. It covers RC, RL and RLC circuits, springs and resonance.

By Ajarn ModUpdated

Solver

How to use it

  1. Pick the order, or press a preset button to start from a ready-made problem.
  2. Enter a, b and c. Fractions and constants work: 1/2, pi, sqrt(2).
  3. Choose f(t) and fill in A and ω (or k for an exponential).
  4. Enter y(0) and y′(0) and press Solve. The page URL updates with your inputs, so you can copy it and share the result.

How the solver works

  1. Homogeneous part: substitute y=erty = e^{rt} to get the characteristic equation ar2+br+c=0ar^2 + br + c = 0. Real, repeated or complex roots fix the form of yhy_h.
  2. Particular solution: guess a form that matches f(t) (undetermined coefficients). If the guess duplicates a term of yhy_h, multiply by t (resonance).
  3. Initial conditions: substitute y(0) and y′(0) into y=yh+ypy = y_h + y_p and solve for C₁ and C₂.
Roots of ar2+br+c=0ar^2 + br + c = 0Form of yhy_hPhysical behaviour
two real r1,r2r_1, r_2C1er1t+C2er2tC_1e^{r_1t} + C_2e^{r_2t}overdamped, no oscillation
repeated rr(C1+C2t)ert(C_1 + C_2t)e^{rt}critically damped, fastest without overshoot
complex α±jβ\alpha \pm j\betaeαt(C1cos⁡βt+C2sin⁡βt)e^{\alpha t}(C_1\cos\beta t + C_2\sin\beta t)underdamped, rings and decays

The complex case comes from Euler's formula ejβt=cos⁡βt+jsin⁡βte^{j\beta t} = \cos\beta t + j\sin\beta t: with real coefficients, the real and imaginary parts are separate solutions.

f(t)Guess for ypy_pIf it duplicates yhy_h
constant KAAmultiply by t
AektAe^{kt}BektBe^{kt}multiply by t, or t² if k is a repeated root
Acos⁡ωtA\cos\omega t or Asin⁡ωtA\sin\omega tPcos⁡ωt+Qsin⁡ωtP\cos\omega t + Q\sin\omega tmultiply by t (resonance)

Worked example: an underdamped spring

y′′+2y′+5y=0y'' + 2y' + 5y = 0, y(0)=1y(0) = 1, y′(0)=0y'(0) = 0 is the default problem.

  1. r2+2r+5=0⇒r=−1±2jr^2 + 2r + 5 = 0 \Rightarrow r = -1 \pm 2j, so y=e−t(C1cos⁡2t+C2sin⁡2t)y = e^{-t}(C_1\cos2t + C_2\sin2t).
  2. y(0)=C1=1y(0) = C_1 = 1 and y′(0)=−C1+2C2=0⇒C2=12y'(0) = -C_1 + 2C_2 = 0 \Rightarrow C_2 = \tfrac12.
  3. Combine into one wave with acos⁡θ+bsin⁡θ=Rcos⁡(θ−φ)a\cos\theta + b\sin\theta = R\cos(\theta - \varphi): R=52≈1.118R = \tfrac{\sqrt5}{2} \approx 1.118, tan⁡φ=12⇒φ≈26.57∘\tan\varphi = \tfrac12 \Rightarrow \varphi \approx 26.57^\circ.

y=e−t(cos⁡2t+12sin⁡2t)=1.118 e−tcos⁡(2t−26.57∘)y = e^{-t}\big(\cos2t + \tfrac12\sin2t\big) = 1.118\,e^{-t}\cos(2t - 26.57^\circ) · ζ = 1/√5 ≈ 0.447, ωₙ = √5

Second example, the "RLC with a DC source" preset: y′′+4y′+3y=3y'' + 4y' + 3y = 3 from rest gives yp=1y_p = 1, roots −1 and −3, and y=1−32e−t+12e−3ty = 1 - \tfrac32e^{-t} + \tfrac12e^{-3t}, which settles at 1 without overshoot (overdamped, ζ ≈ 1.155).

Frequently asked questions

Which differential equations does this solver handle?

Constant-coefficient linear equations: first order ay′ + by = f(t) and second order ay″ + by′ + cy = f(t), where f(t) is zero, a constant, an exponential Ae^{kt}, or a sinusoid A cos ωt or A sin ωt, with initial conditions. That covers RC, RL and RLC circuits, mass–spring–damper problems and resonance.

How reliable are the answers?

Every time you solve, the tool integrates the same equation numerically with fourth-order Runge–Kutta and compares it with the closed form over the whole time window. If they disagree, the formula is withheld and only the numerical curve is shown. The open circles on the graph are the RK4 values.

Why do complex roots give cosines and sines?

A complex root α ± jβ gives e^{(α+jβ)t} = e^{αt}(cos βt + j sin βt) by Euler's formula. Because the coefficients are real, the real and imaginary parts are separate solutions, so y = e^{αt}(C₁ cos βt + C₂ sin βt).

What does resonance look like here?

If the forcing frequency equals the natural frequency and there is no damping (b = 0), the particular solution picks up a factor t and the amplitude grows linearly. Press the resonance preset to see it.

Can I share a result?

Yes. Each time you solve, the inputs are written into the page URL. Copy the address bar and send it; the link opens with the same equation and the same steps.

More tools