In numerical analysis, the rate of convergence quantifies how quickly a sequence approaches its limit. This is a critical metric when evaluating the efficiency of iterative algorithms, such as Newton's method or the Bisection method. When we say an algorithm converges, we want to know if it reaches the desired precision in 5 iterations or 5,000.
Mathematical Formula
The order of convergence (p) is defined by the relationship between successive errors. If en = |xn – L| is the error at step n, the sequence converges with order p if:
lim (n → ∞) |en+1| / |en|p = C
Where C is the asymptotic error constant. Our calculator estimates p using three consecutive data points by calculating the ratio of the logarithms of the relative errors.
Common Types of Convergence
Linear Convergence (p=1): The error decreases by a constant factor in each step (e.g., Bisection Method).
Superlinear Convergence (1 < p < 2): Faster than linear, seen in the Secant Method.
Quadratic Convergence (p=2): The number of correct digits roughly doubles with each iteration (e.g., Newton's Method).
Example Calculation
Imagine you are solving f(x) = 0 and your sequence of guesses is:
Iteration
Value (x)
Error (e)
n
0.1000
0.1000
n+1
0.0100
0.0100
n+2
0.0001
0.0001
In this case, the calculator would yield an order of p = 2.00, indicating quadratic convergence, as the error is being squared at each step.
function calculateConvergence() {
var L = parseFloat(document.getElementById("limitVal").value);
var xn = parseFloat(document.getElementById("termN").value);
var xn1 = parseFloat(document.getElementById("termN1").value);
var xn2 = parseFloat(document.getElementById("termN2").value);
var resultDiv = document.getElementById("rocResultArea");
var rocValue = document.getElementById("rocValue");
var rocDesc = document.getElementById("rocDescription");
if (isNaN(L) || isNaN(xn) || isNaN(xn1) || isNaN(xn2)) {
alert("Please enter valid numeric values for all fields.");
return;
}
var e0 = Math.abs(xn – L);
var e1 = Math.abs(xn1 – L);
var e2 = Math.abs(xn2 – L);
if (e0 === 0 || e1 === 0 || e2 === 0) {
rocValue.innerHTML = "Result: Undefined";
rocDesc.innerHTML = "One of the errors is zero, meaning the sequence has already reached the limit. Convergence rate cannot be calculated from these points.";
resultDiv.style.display = "block";
return;
}
// Formula: p = log(e2/e1) / log(e1/e0)
var p = Math.log(e2 / e1) / Math.log(e1 / e0);
resultDiv.style.display = "block";
if (isNaN(p) || !isFinite(p)) {
rocValue.innerHTML = "Result: Calculation Error";
rocDesc.innerHTML = "The values provided do not allow for a logarithmic convergence calculation. Ensure the errors are strictly decreasing and positive.";
} else {
rocValue.innerHTML = "Order of Convergence (p) ≈ " + p.toFixed(4);
var type = "";
if (p >= 1.9) {
type = "This indicates Quadratic Convergence. This is highly efficient and typical of methods like Newton-Raphson near a root.";
} else if (p > 1.1) {
type = "This indicates Superlinear Convergence. The algorithm is faster than linear but not quite quadratic.";
} else if (p >= 0.9 && p <= 1.1) {
type = "This indicates Linear Convergence. The error reduces by a consistent percentage each step.";
} else if (p < 0.9) {
type = "This indicates Sublinear Convergence. The sequence is approaching the limit very slowly.";
}
rocDesc.innerHTML = type + " Based on your inputs, the asymptotic error constant (C) is approximately " + (e1 / Math.pow(e0, p)).toFixed(4) + ".";
}
}