IV. Differential equations and advanced analysis
40. Numerical methods
Numerical methods are on the home screen in the “Applications” section, the field Numerical methods: roots of equations (bisection, Newton's, secant, regula falsi, fixed-point iteration), numerical integrals (the trapezoidal, Simpson's and Romberg's methods), numerical derivatives by difference quotients, differential equations (Euler's, Heun's and the Runge–Kutta methods), linear systems (Jacobi's and the Gauss–Seidel methods, the LU decomposition), interpolation (Lagrange's and Newton's polynomial, a cubic spline) and least squares. An integral and a derivative can be computed from a table of measured values too.
Differential equations also by multistep methods – Adams–Bashforth and the Adams–Bashforth–Moulton predictor-corrector (started by Runge–Kutta) –, the adaptive RK45 method (Dormand–Prince, a table of the steps accepted and rejected by the error estimate, the notation tol=…) and implicit methods for stiff equations: the implicit Euler method and the trapezoidal rule (Crank–Nicolson) with Newton's method in every step. For an equation with ∂f/∂y < 0 the steps show the method's stability: hλ and the amplification |R(hλ)|; if it is above 1, an explicit method diverges and the computation says so.
Boundary value problems y″ = f(x, y, y′) with the conditions y(a), y(b): by the shooting method (the initial slope found by the secant method, each shot solved by Runge–Kutta) and by finite differences (a linear equation as a tridiagonal system solved by the Thomas algorithm with tables of the forward sweep and the back substitution); where the ODE solver finds the exact solution, it is compared at the nodes. The equation of motion x″ = a(x) is solved by the symplectic Verlet method beside RK4, showing how the total energy's error evolves for each.
The steps show the method's formula, the table of the iterations or of the values at the nodes, the stopping condition (the default tolerance ε = 10⁻⁴, at most 50 iterations) and the error's estimate; where the exact value is known, the result is compared with it. The conditions of convergence are checked: a sign change on the interval, Fourier's condition for Newton's start, |g′(x)| < 1 for the fixed-point iteration, the diagonal dominance and the spectral radius for systems. The graph shows the tangents or secants, trapezoids or parabolas, a differential equation's numerical solution against the exact one, and the fitted polynomial with the points.
On an ordinary problem – an equation in one unknown, a definite integral, a differential equation with an initial condition – the app offers the chips “Solve by a numerical method” under the result; the form is prefilled with the problem. Where there's no exact way or it is needlessly complicated (x = cos x, Cardano's formulas), the offer is highlighted, and an equation that can't be solved algebraically is solved by Newton's method at once. The applications that compute a number silently (the internal rate of return, the APR, a bond's yield, a polyprotic acid's pH, Runge–Kutta in the models) have a collapsed line “The method” under the result with a short table of the iterations.
How to enter it
newton(x = cos x; x0=0.7; tol=1e-4) | The method – its English name – and after semicolons the equation, the initial estimate x0, the tolerance tol, optionally max (iterations) and stop=fx. |
bisection(x^3 - x - 2; a=1; b=2) | A function f(x) (f(x) = 0 is solved) and the interval a, b. Without an interval or an estimate the roots are isolated automatically. |
simpson(e^(-x^2); a=0; b=1; n=10) | The integral of a function between a and b with n subintervals; also trapezoid and romberg (tol). |
trapezoid(x=0 1 2 3; y=0 2 3 5) | The integral of measured values – x and y a space apart. |
finitediff(sin x; at=1; h=0.1) | The derivative at the point at with the step h; from a table x=…; y=… (at optional). |
rk4(y' = x + y; y(0)=1; h=0.1; to=1) | A first-order differential equation with its initial condition, the step h and the interval's end to; also euler and heun. |
gaussseidel(10x + y + z = 12; x + 10y + z = 12; x + y + 10z = 12) | A system – the equations after semicolons or on lines; also jacobi and lu. |
lagrange(x=0 1 2 3; y=1 3 2 5; at=1.5) | The points x, y and the point at; also newtonpoly and spline. |
leastsquares(x=0 1 2 3 4; y=1 1.8 3.3 4.5 6.3; degree=2) | A least-squares polynomial of the degree degree. |
Examples
x = cos x


newton(x^3 - x - 2)


bisection(x^3 - x - 2; a=1; b=2)


secant(x^3 - 2x - 5; x0=2; x1=3)


fixedpoint(x = cos x; x0=0.7)


simpson(e^(-x^2); a=0; b=1; n=10)


romberg(sin x / x; a=1; b=2)


trapezoid(x=0 10 20 30 40 50 60; y=0 4.2 7.5 9.8 11.1 11.6 11.8)


finitediff(sin x; at=1; h=0.1)


rk4(y' = x + y; y(0)=1; h=0.1; to=1)


euler(y' = x^2 + y^2; y(0)=0; h=0.1; to=1)


abm(y' = x + y; y(0)=1; h=0.1; to=1)


rk45(y' = x + y; y(0)=1; h=0.5; to=2; tol=1e-6)


euler(y' = -50(y - cos x); y(0)=0; h=0.05; to=1)


beuler(y' = -50(y - cos x); y(0)=0; h=0.05; to=1)



shooting(y'' = -y^2; y(0)=1; y(1)=1)



fdm(y'' = 6x; y(0)=0; y(1)=1; n=4)


fem(y'' = -x; y(0) = 0; y(1) = 0; n = 4)


verlet(x'' = -sin(x); x(0)=1; x'(0)=0; h=0.5; to=500)


gaussseidel(x + 3y = 7; 4x + y = 6)


lu(2x + y + z = 5; 4x + 3y + 3z = 13; 2x + 3y + 4z = 13)


lagrange(x=0 1 2 3; y=1 3 2 5; at=1.5)


newtonpoly(x=0 1 2 3; y=1 3 2 5)


spline(x=0 1 2 3; y=0 1 0 1; at=1.5)


leastsquares(x=0 1 2 3 4 5; y=1.1 1.9 3.2 5.1 7.4 10.2; degree=2)


model(npv; find=irr[one]; CF=-1000 300 400 500 200[one]; r=10[pct]; cur=CZK)![model(npv; find=irr[one]; CF=-1000 300 400 500 200[one]; r=10[pct]; cur=CZK)](img/num-irr.png)
![model(npv; find=irr[one]; CF=-1000 300 400 500 200[one]; r=10[pct]; cur=CZK)](img/num-irr-1.png)
![model(npv; find=irr[one]; CF=-1000 300 400 500 200[one]; r=10[pct]; cur=CZK)](img/num-irr-2.png)
Known limitations
- Roots: one equation in one unknown, real roots; at most three roots in ⟨−50; 50⟩ are isolated automatically.
- Differential equations: a single first-order equation y′ = f(x, y) only, at most 2,000 steps; systems and higher orders not yet.
- Systems: 2 to 6 equations; interpolation at most 12 points, a least-squares polynomial of degree 5 at most.
- Simpson's and Romberg's methods from a table need equal steps (Romberg 2, 4, 8, … subintervals).
- Boundary value problems only of the 2nd order with the values y(a), y(b) (not a derivative at an end); finite differences only for an equation linear in y and y′. The Verlet method only for motion x″ = a(x) in one coordinate – a planet's orbit in the plane not yet.