Quadratic Function Graph Calculator

Quadratic Function Graph Calculator

Enter the coefficients for the quadratic function: y = ax² + bx + c

Graph Properties:

function calculateQuadratic() { 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'); var functionEquationElem = document.getElementById('functionEquation'); var vertexElem = document.getElementById('vertex'); var axisOfSymmetryElem = document.getElementById('axisOfSymmetry'); var yInterceptElem = document.getElementById('yIntercept'); var xInterceptsElem = document.getElementById('xIntercepts'); var openingDirectionElem = document.getElementById('openingDirection'); resultDiv.style.display = 'block'; // Show the result div if (isNaN(a) || isNaN(b) || isNaN(c)) { functionEquationElem.innerHTML = "Please enter valid numbers for all coefficients."; vertexElem.innerHTML = ""; axisOfSymmetryElem.innerHTML = ""; yInterceptElem.innerHTML = ""; xInterceptsElem.innerHTML = ""; openingDirectionElem.innerHTML = ""; return; } if (a === 0) { functionEquationElem.innerHTML = "Error: Coefficient 'a' cannot be zero for a quadratic function. This would be a linear function."; vertexElem.innerHTML = ""; axisOfSymmetryElem.innerHTML = ""; yInterceptElem.innerHTML = ""; xInterceptsElem.innerHTML = ""; openingDirectionElem.innerHTML = ""; return; } // Display the function equation var equationString = "Function: y = "; if (a !== 0) equationString += a + "x²"; if (b > 0) equationString += " + " + b + "x"; else if (b 0) equationString += " + " + c; else if (c < 0) equationString += " – " + Math.abs(c); if (a === 0 && b === 0 && c === 0) equationString = "Function: y = 0"; // Edge case for all zeros else if (a !== 0 && b === 0 && c === 0) equationString = "Function: y = " + a + "x²"; else if (a === 0 && b !== 0 && c === 0) equationString = "Function: y = " + b + "x"; else if (a === 0 && b === 0 && c !== 0) equationString = "Function: y = " + c; functionEquationElem.innerHTML = equationString; // Vertex var vertexX = -b / (2 * a); var vertexY = a * Math.pow(vertexX, 2) + b * vertexX + c; vertexElem.innerHTML = "Vertex: (" + vertexX.toFixed(3) + ", " + vertexY.toFixed(3) + ")"; // Axis of Symmetry axisOfSymmetryElem.innerHTML = "Axis of Symmetry: x = " + vertexX.toFixed(3); // Y-intercept yInterceptElem.innerHTML = "Y-intercept: (0, " + c.toFixed(3) + ")"; // X-intercepts (Roots) var discriminant = Math.pow(b, 2) – 4 * a * c; if (discriminant > 0) { var x1 = (-b + Math.sqrt(discriminant)) / (2 * a); var x2 = (-b – Math.sqrt(discriminant)) / (2 * a); xInterceptsElem.innerHTML = "X-intercepts (Roots): (" + x1.toFixed(3) + ", 0) and (" + x2.toFixed(3) + ", 0)"; } else if (discriminant === 0) { var x = -b / (2 * a); xInterceptsElem.innerHTML = "X-intercept (Repeated Root): (" + x.toFixed(3) + ", 0)"; } else { xInterceptsElem.innerHTML = "X-intercepts (Roots): No real x-intercepts (complex roots)"; } // Opening Direction if (a > 0) { openingDirectionElem.innerHTML = "Opens: Upwards (Parabola opens up)"; } else { openingDirectionElem.innerHTML = "Opens: Downwards (Parabola opens down)"; } }

Understanding Quadratic Functions and Their Graphs

A quadratic function is a polynomial function of degree two. It is typically written in the standard form:

y = ax² + bx + c

where 'a', 'b', and 'c' are real numbers, and 'a' cannot be zero. The graph of a quadratic function is a U-shaped curve called a parabola.

Key Properties of a Quadratic Graph:

1. Coefficients (a, b, c):

  • Coefficient 'a': This determines the direction and width of the parabola.
    • If a > 0, the parabola opens upwards (like a smile).
    • If a < 0, the parabola opens downwards (like a frown).
    • A larger absolute value of 'a' makes the parabola narrower; a smaller absolute value makes it wider.
  • Coefficient 'b': Along with 'a', 'b' influences the position of the vertex and the axis of symmetry.
  • Coefficient 'c': This is the y-intercept of the graph. The parabola always crosses the y-axis at the point (0, c).

2. Vertex:

The vertex is the turning point of the parabola. It's either the lowest point (minimum) if the parabola opens upwards, or the highest point (maximum) if it opens downwards.

  • The x-coordinate of the vertex is given by the formula: x = -b / (2a)
  • To find the y-coordinate, substitute this x-value back into the original quadratic equation.

Example: For y = x² – 2x – 3, a=1, b=-2, c=-3.
x-vertex = -(-2) / (2*1) = 2/2 = 1.
y-vertex = (1)² – 2(1) – 3 = 1 – 2 – 3 = -4.
So, the vertex is (1, -4).

3. Axis of Symmetry:

This is a vertical line that passes through the vertex, dividing the parabola into two symmetrical halves. Its equation is always x = (x-coordinate of the vertex).

Example: For y = x² – 2x – 3, the axis of symmetry is x = 1.

4. Y-intercept:

This is the point where the parabola crosses the y-axis. It occurs when x = 0. By substituting x=0 into the equation y = ax² + bx + c, we get y = c.

Example: For y = x² – 2x – 3, the y-intercept is (0, -3).

5. X-intercepts (Roots):

These are the points where the parabola crosses the x-axis. They occur when y = 0. To find them, we solve the quadratic equation ax² + bx + c = 0 using the quadratic formula:

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

The term b² - 4ac is called the discriminant (Δ), which tells us about the nature of the roots:

  • If Δ > 0: Two distinct real roots (the parabola crosses the x-axis at two different points).
  • If Δ = 0: One real root (a repeated root, meaning the parabola touches the x-axis at exactly one point, which is its vertex).
  • If Δ < 0: No real roots (the parabola does not cross or touch the x-axis; it lies entirely above or below it).

Example: For y = x² – 2x – 3, a=1, b=-2, c=-3.
Discriminant = (-2)² – 4(1)(-3) = 4 + 12 = 16.
Since 16 > 0, there are two real roots.
x = [ -(-2) ± sqrt(16) ] / (2*1) = [ 2 ± 4 ] / 2.
x1 = (2 + 4) / 2 = 6 / 2 = 3.
x2 = (2 – 4) / 2 = -2 / 2 = -1.
So, the x-intercepts are (3, 0) and (-1, 0).

Use the calculator above to quickly find these properties for any quadratic function you input!

Leave a Reply

Your email address will not be published. Required fields are marked *