Second-Order ODE Solver screenshot

Second-Order ODE Solver

Solve y″ = f(x, y, y′) with RK4 or Euler on the state (y, y′), printing both columns and the step count.

Privacy First
0 Runs
Updated 2026-11-22
Runs in your browser
No sign-up, no upload
Numeric table

Second-Order ODE Solver

Solve y″ = f(x, y, y′) with RK4 or Euler on the state (y, y′), printing both columns and the step count.

How this page computes

A second-order equation is integrated as a pair of first-order equations: y′ = v and v′ = f(x, y, v). The page prints both columns at every tabulated step.

For y″ = −y with y(0) = 1 and y′(0) = 0, the exact solution is cos x, so y(1) is 0.540302305868; RK4 with ten steps reaches 0.540302967117. The error is visible because the exact value is a familiar one.

The right-hand side may use x, y and v, where v is y′. Anything else is refused by name, and a non-finite slope or state stops the walk with the step named.

The calculation runs entirely in this browser tab; nothing is uploaded.

The page solves y″ = f(x, y, y′) numerically by carrying y and y′ together. For y″ = −y from (1, 0), RK4 with ten steps gives y(1) ≈ 0.540302967117, close to cos 1 = 0.540302305868.

The state form is printed so the conversion is not a hidden trick: the pair (y, y′) has derivative (y′, f). Euler and RK4 both advance that pair, and the table shows both columns.

How to use Second-Order ODE Solver

Type the right-hand side f(x, y, v). Use v for y′, since y′ is not a variable the parser can name.

Set y(0), y′(0), the step and the number of steps, then choose RK4 or Euler.

Press Run. Read the table's y and y′ columns and the final line, which repeats both endpoint values.

How the method works

Any second-order equation can be written as two first-order equations by naming y′. That is what makes a first-order integrator applicable, and it is why the page needs an initial value for y′ as well as for y.

RK4's fourth-order accuracy comes from averaging four slope evaluations per step. On a smooth oscillator the difference from Euler is visible within ten steps, which is why both methods are offered rather than only the better one.

What to Expect

Best for

  • A numeric solution table for a second-order equation
  • An oscillator or a projectile with stated initial values
  • Comparing Euler and RK4 on the same step

Not ideal for

  • A boundary-value problem, which needs two endpoint conditions
  • A stiff equation that needs an implicit method
  • A symbolic closed form

What this tool keeps

  • The right-hand side and all initial values exactly as typed

What may need cleanup

  • Nothing when the walk is finite; the refusal names the step when it is not

Common errors

  • A right-hand side using another variable is refused by name
  • A non-finite intermediate slope is refused
  • A zero step is refused

Example use cases

  • Solve y″ = -y from (1, 0)
  • Solve a damped oscillator y″ = -0.2y′ - y
  • Compare RK4 and Euler on cos x

Sample input

y″ = -y, y(0) = 1, y′(0) = 0, h = 0.1, 10 steps, RK4

Sample output

final y(1) ≈ 0.540302967117 and y′ ≈ -0.8414704778, against cos 1 and -sin 1

Who this is for

  • Students meeting second-order equations
  • Readers checking a numerical oscillator

Frequently asked questions

Why does it ask for y′(0)?

A second-order equation needs two initial conditions to pick one solution. The page carries y and y′ as a pair, so both starting values are part of the state.

What is v?

v is the page's name for y′. The right-hand side may use it, so an equation such as y″ = −0.2v − y can be typed directly.

Why is the answer slightly below cos 1?

RK4 has a small truncation error at a step of 0.1. Halving the step reduces it sharply, which is the fourth-order claim made visible.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.