Calculator Symbolab

Quadratic Equation Solver

Enter the coefficients (a, b, c) for a quadratic equation in the form ax² + bx + c = 0 to find its roots.

function calculateQuadraticRoots() { var a = parseFloat(document.getElementById("coefficientA").value); var b = parseFloat(document.getElementById("coefficientB").value); var c = parseFloat(document.getElementById("coefficientC").value); var resultDiv = document.getElementById("quadraticResult"); resultDiv.innerHTML = ""; // Clear previous results if (isNaN(a) || isNaN(b) || isNaN(c)) { resultDiv.innerHTML = "Please enter valid numbers for all coefficients."; return; } if (a === 0) { // Not a quadratic equation if (b === 0) { if (c === 0) { resultDiv.innerHTML = "This is the equation 0 = 0, which has infinitely many solutions."; } else { resultDiv.innerHTML = "This is the equation " + c + " = 0, which has no solution."; } } else { // Linear equation: bx + c = 0 => x = -c/b var x = -c / b; resultDiv.innerHTML = "This is a linear equation (a=0). The single root is: x = " + x.toFixed(4) + ""; } return; } var discriminant = b * b – 4 * a * c; if (discriminant > 0) { var x1 = (-b + Math.sqrt(discriminant)) / (2 * a); var x2 = (-b – Math.sqrt(discriminant)) / (2 * a); resultDiv.innerHTML = "The equation has two distinct real roots:" + "x₁ = " + x1.toFixed(4) + "" + "x₂ = " + x2.toFixed(4) + ""; } else if (discriminant === 0) { var x = -b / (2 * a); resultDiv.innerHTML = "The equation has one real root (repeated):" + "x = " + x.toFixed(4) + ""; } else { // discriminant < 0 var realPart = -b / (2 * a); var imaginaryPart = Math.sqrt(Math.abs(discriminant)) / (2 * a); resultDiv.innerHTML = "The equation has two complex conjugate roots:" + "x₁ = " + realPart.toFixed(4) + " + " + imaginaryPart.toFixed(4) + "i" + "x₂ = " + realPart.toFixed(4) + " – " + imaginaryPart.toFixed(4) + "i"; } } .calculator-container { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f9f9f9; padding: 25px; border-radius: 10px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); max-width: 600px; margin: 30px auto; border: 1px solid #e0e0e0; } .calculator-container h2 { color: #333; text-align: center; margin-bottom: 20px; font-size: 28px; } .calculator-container p { color: #555; margin-bottom: 15px; line-height: 1.6; } .form-group { margin-bottom: 18px; display: flex; flex-direction: column; } .form-group label { margin-bottom: 8px; color: #444; font-weight: bold; font-size: 16px; } .form-group input[type="number"] { width: calc(100% – 20px); padding: 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 16px; box-sizing: border-box; transition: border-color 0.3s ease; } .form-group input[type="number"]:focus { border-color: #007bff; outline: none; box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25); } .calculator-container button { display: block; width: 100%; padding: 14px 20px; background-color: #007bff; color: white; border: none; border-radius: 6px; font-size: 18px; cursor: pointer; transition: background-color 0.3s ease, transform 0.2s ease; margin-top: 20px; } .calculator-container button:hover { background-color: #0056b3; transform: translateY(-2px); } .calculator-container button:active { transform: translateY(0); } .result { margin-top: 25px; padding: 15px; background-color: #e9f7ef; border: 1px solid #d4edda; border-radius: 8px; color: #155724; font-size: 17px; line-height: 1.8; } .result p { margin: 5px 0; color: #155724; } .result strong { color: #004085; } .result .error { color: #721c24; background-color: #f8d7da; border-color: #f5c6cb; padding: 10px; border-radius: 5px; }

Understanding Quadratic Equations and Their Solutions

A quadratic equation is a polynomial equation of the second degree, meaning it contains at least one term in which the unknown variable is raised to the power of two. The standard form of a quadratic equation is written as:

ax² + bx + c = 0

Where:

  • x represents the unknown variable.
  • a, b, and c are coefficients, with a not equal to zero.

These equations are fundamental in various fields, including physics (e.g., projectile motion), engineering, economics, and computer graphics. Finding the values of x that satisfy the equation (known as the "roots" or "solutions") is a common mathematical task.

The Quadratic Formula

The most common method for solving quadratic equations is using the quadratic formula. This formula provides the roots of any quadratic equation, regardless of whether they are real or complex numbers. The formula is:

x = [-b ± √(b² - 4ac)] / 2a

The term inside the square root, (b² - 4ac), is called the discriminant (often denoted by the Greek letter Delta, Δ). The value of the discriminant determines the nature of the roots:

  • If Δ > 0: There are two distinct real roots. This means the parabola (the graph of a quadratic equation) intersects the x-axis at two different points.
  • If Δ = 0: There is exactly one real root (also called a repeated root or a double root). The parabola touches the x-axis at exactly one point.
  • If Δ < 0: There are two complex conjugate roots. The parabola does not intersect the x-axis.

How to Use the Quadratic Equation Solver

Our Quadratic Equation Solver simplifies the process of finding these roots. Follow these steps:

  1. Identify Coefficients: Look at your quadratic equation and identify the values for a, b, and c. Remember that if a term is missing, its coefficient is 0 (e.g., in x² + 5 = 0, b = 0). If a term like has no number in front, its coefficient is 1 (e.g., means 1x², so a = 1).
  2. Enter Values: Input the numerical values for 'Coefficient a', 'Coefficient b', and 'Coefficient c' into the respective fields in the calculator above.
  3. Calculate: Click the "Calculate Roots" button.
  4. View Results: The calculator will instantly display the roots of your equation, indicating whether they are real or complex, and their precise values.

Examples of Quadratic Equations

Let's look at some examples to illustrate how the calculator works:

Example 1: Two Distinct Real Roots

Equation: x² - 3x + 2 = 0

  • a = 1
  • b = -3
  • c = 2

Using the calculator with these values will yield: x₁ = 2.0000, x₂ = 1.0000

(Discriminant: (-3)² – 4*1*2 = 9 – 8 = 1, which is > 0)

Example 2: One Real Root (Repeated)

Equation: x² + 4x + 4 = 0

  • a = 1
  • b = 4
  • c = 4

Using the calculator with these values will yield: x = -2.0000

(Discriminant: (4)² – 4*1*4 = 16 – 16 = 0)

Example 3: Two Complex Conjugate Roots

Equation: x² + 2x + 5 = 0

  • a = 1
  • b = 2
  • c = 5

Using the calculator with these values will yield: x₁ = -1.0000 + 2.0000i, x₂ = -1.0000 – 2.0000i

(Discriminant: (2)² – 4*1*5 = 4 – 20 = -16, which is < 0)

Example 4: Linear Equation (a=0)

Equation: 0x² + 5x - 10 = 0 (or simply 5x - 10 = 0)

  • a = 0
  • b = 5
  • c = -10

The calculator will identify this as a linear equation and provide: x = 2.0000

Leave a Comment