Intermediate Value Theorem Calculator

.ivt-container { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; max-width: 800px; margin: 20px auto; padding: 25px; border: 1px solid #ddd; border-radius: 12px; background-color: #f9fbfd; color: #333; box-shadow: 0 4px 6px rgba(0,0,0,0.05); } .ivt-container h2 { color: #2c3e50; text-align: center; margin-top: 0; } .ivt-input-group { margin-bottom: 20px; } .ivt-input-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #444; } .ivt-input-group input { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 6px; box-sizing: border-box; font-size: 16px; } .ivt-input-group small { display: block; margin-top: 5px; color: #666; font-style: italic; } .ivt-btn { width: 100%; padding: 15px; background-color: #3498db; color: white; border: none; border-radius: 6px; font-size: 18px; font-weight: bold; cursor: pointer; transition: background-color 0.3s; } .ivt-btn:hover { background-color: #2980b9; } #ivt-result { margin-top: 25px; padding: 20px; border-radius: 8px; display: none; } .success { background-color: #d4edda; border: 1px solid #c3e6cb; color: #155724; } .warning { background-color: #fff3cd; border: 1px solid #ffeeba; color: #856404; } .error { background-color: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; } .ivt-article { margin-top: 40px; line-height: 1.6; color: #444; } .ivt-article h3 { color: #2c3e50; border-bottom: 2px solid #3498db; padding-bottom: 5px; } .math-box { background: #eee; padding: 10px; border-radius: 4px; font-family: "Courier New", Courier, monospace; margin: 10px 0; }

Intermediate Value Theorem (IVT) Calculator

Use 'x' as the variable. Supported: x^n, +, -, *, /
The value you want to check if the function crosses.

What is the Intermediate Value Theorem?

The Intermediate Value Theorem (IVT) is a fundamental principle in calculus. It states that if a function f is continuous on a closed interval [a, b], and k is any number between f(a) and f(b), then there exists at least one number c in the interval (a, b) such that f(c) = k.

Conditions for IVT

  1. The function must be continuous on the closed interval [a, b].
  2. The target value k must lie strictly between f(a) and f(b).

Practical Example

Suppose you have the function f(x) = x² – 4 and you want to know if there is a root (where f(x) = 0) between x = 1 and x = 3.

  • f(1) = 1² – 4 = -3
  • f(3) = 3² – 4 = 5

Since 0 is between -3 and 5, and the function is a polynomial (which is continuous), the IVT guarantees that there is at least one c between 1 and 3 where f(c) = 0.

How This Calculator Works

This tool evaluates your function at the endpoints of the interval. If the target value k is between the results, it applies the Bisection Method to estimate the exact value of c where the function hits your target.

function evaluateFunction(expr, x) { try { // Clean expression for JS evaluation var cleanExpr = expr.replace(/\^/g, "**"); // Safe evaluation context var fn = new Function('x', 'return ' + cleanExpr); return fn(x); } catch (e) { return NaN; } } function calculateIVT() { var expr = document.getElementById("functionInput").value; var a = parseFloat(document.getElementById("valA").value); var b = parseFloat(document.getElementById("valB").value); var k = parseFloat(document.getElementById("targetK").value); var resultDiv = document.getElementById("ivt-result"); if (isNaN(a) || isNaN(b) || isNaN(k)) { resultDiv.style.display = "block"; resultDiv.className = "error"; resultDiv.innerHTML = "Error: Please enter valid numbers for the interval and target value."; return; } if (a >= b) { resultDiv.style.display = "block"; resultDiv.className = "error"; resultDiv.innerHTML = "Error: Interval Start (a) must be less than Interval End (b)."; return; } var fa = evaluateFunction(expr, a); var fb = evaluateFunction(expr, b); if (isNaN(fa) || isNaN(fb)) { resultDiv.style.display = "block"; resultDiv.className = "error"; resultDiv.innerHTML = "Error: Invalid function expression. Please check your syntax."; return; } var minF = Math.min(fa, fb); var maxF = Math.max(fa, fb); var html = "f(a) = " + fa.toFixed(4) + ""; html += "f(b) = " + fb.toFixed(4) + ""; if (k >= minF && k <= maxF) { resultDiv.className = "success"; html += "IVT Condition Met: Since " + k + " is between " + fa.toFixed(4) + " and " + fb.toFixed(4) + ", a value c exists such that f(c) = " + k + "."; // Bisection Method to find c var low = a; var high = b; var c = 0; var iterations = 0; // Target is to find f(x) – k = 0 while (iterations < 100) { c = (low + high) / 2; var fc = evaluateFunction(expr, c); if (Math.abs(fc – k) < 0.0001) break; // Adjust based on whether fa or fb is the lower end relative to k var valLow = evaluateFunction(expr, low) – k; var valMid = fc – k; if (valLow * valMid < 0) { high = c; } else { low = c; } iterations++; } html += "Estimated Value: c ≈ " + c.toFixed(6) + " where f(c) ≈ " + k; } else { resultDiv.className = "warning"; html += "IVT Does Not Guarantee a Value: The target value " + k + " is NOT between f(a) and f(b). A value c may or may not exist, but the theorem does not guarantee it for this interval."; } resultDiv.style.display = "block"; resultDiv.innerHTML = html; }

Leave a Comment