Rate of Convergence Calculator

.roc-calculator-container { padding: 25px; background-color: #f9fbfd; border: 2px solid #e1e8ed; border-radius: 12px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: #333; max-width: 700px; margin: 20px auto; box-shadow: 0 4px 6px rgba(0,0,0,0.05); } .roc-calculator-container h2 { margin-top: 0; color: #1a365d; font-size: 24px; text-align: center; } .roc-input-group { margin-bottom: 20px; } .roc-input-group label { display: block; font-weight: 600; margin-bottom: 8px; color: #2d3748; } .roc-input-group input { width: 100%; padding: 12px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 16px; box-sizing: border-box; } .roc-calc-btn { width: 100%; background-color: #3182ce; color: white; padding: 15px; border: none; border-radius: 6px; font-size: 18px; font-weight: bold; cursor: pointer; transition: background-color 0.2s; } .roc-calc-btn:hover { background-color: #2b6cb0; } .roc-result-area { margin-top: 25px; padding: 20px; background-color: #fff; border: 1px solid #bee3f8; border-radius: 8px; display: none; } .roc-result-value { font-size: 22px; color: #2c5282; font-weight: bold; text-align: center; margin-bottom: 10px; } .roc-explanation { font-size: 14px; line-height: 1.6; color: #4a5568; } .roc-article { margin-top: 40px; line-height: 1.8; color: #2d3748; } .roc-article h3 { color: #1a365d; border-bottom: 2px solid #ebf8ff; padding-bottom: 10px; } .roc-table { width: 100%; border-collapse: collapse; margin: 15px 0; } .roc-table td, .roc-table th { border: 1px solid #e2e8f0; padding: 10px; text-align: left; } .roc-table th { background-color: #edf2f7; }

Rate of Convergence Calculator

What is the Rate of Convergence?

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) &approx; " + 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) + "."; } }

Leave a Comment