Visualize quadratic functions and calculate key parabolic properties instantly.
Analysis Results
Function:
Vertex:
Y-Intercept:
Roots (x-intercepts):
Direction:
How to Use the Graph the Function Calculator
This calculator is designed to visualize quadratic equations in the standard form: y = ax² + bx + c. Understanding how these coefficients affect the shape, position, and properties of a parabola is fundamental to algebra and calculus.
Understanding the Inputs
Coefficient a: Determines the steepness and direction of the parabola. If a is positive, it opens upward; if negative, it opens downward.
Coefficient b: Shifts the parabola along both the x and y axes simultaneously.
Coefficient c: The y-intercept, indicating where the curve crosses the vertical axis.
Key Features Calculated
Beyond plotting the points, this tool provides critical algebraic data:
The Vertex: The highest or lowest point of the function, calculated using the formula x = -b / 2a.
The Roots: Also known as zeros or x-intercepts, these are the points where the function equals zero. They are found using the quadratic formula: x = (-b ± √(b² – 4ac)) / 2a.
Discriminant (D): Calculated as b² – 4ac. If D > 0, there are two real roots; if D = 0, one real root; and if D < 0, no real roots (complex).
Practical Example
Let's graph the function: f(x) = 1x² – 4x + 3
Enter 1 for a, -4 for b, and 3 for c.
The calculator will determine the vertex is at (2, -1).
The y-intercept is 3.
The roots are found to be x = 1 and x = 3.
The resulting graph is a parabola opening upwards with its bottom point at (2, -1).
function calculateGraph() {
var a = parseFloat(document.getElementById('coeffA').value);
var b = parseFloat(document.getElementById('coeffB').value);
var c = parseFloat(document.getElementById('coeffC').value);
if (isNaN(a) || isNaN(b) || isNaN(c)) {
alert("Please enter valid numbers for all coefficients.");
return;
}
if (a === 0) {
alert("The coefficient 'a' cannot be zero for a quadratic function.");
return;
}
var resultsDiv = document.getElementById('resultsDisplay');
resultsDiv.style.display = 'block';
// Function String
var funcStr = "y = " + a + "x² " + (b >= 0 ? "+ " + b : "- " + Math.abs(b)) + "x " + (c >= 0 ? "+ " + c : "- " + Math.abs(c));
document.getElementById('resFunction').innerText = funcStr;
// Vertex calculation
var vx = -b / (2 * a);
var vy = (a * vx * vx) + (b * vx) + c;
document.getElementById('resVertex').innerText = "(" + vx.toFixed(2) + ", " + vy.toFixed(2) + ")";
// Y-Intercept
document.getElementById('resYInt').innerText = "(0, " + c.toFixed(2) + ")";
// Roots
var discriminant = (b * b) – (4 * a * c);
if (discriminant > 0) {
var r1 = (-b + Math.sqrt(discriminant)) / (2 * a);
var r2 = (-b – Math.sqrt(discriminant)) / (2 * a);
document.getElementById('resRoots').innerText = r1.toFixed(2) + " and " + r2.toFixed(2);
} else if (discriminant === 0) {
var r = -b / (2 * a);
document.getElementById('resRoots').innerText = r.toFixed(2);
} else {
document.getElementById('resRoots').innerText = "No real roots";
}
// Direction
document.getElementById('resDirection').innerText = a > 0 ? "Opens Upward" : "Opens Downward";
// Drawing logic
drawParabola(a, b, c, vx, vy);
}
function drawParabola(a, b, c, vx, vy) {
var canvas = document.getElementById('graphCanvas');
var ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
var width = canvas.width;
var height = canvas.height;
var centerX = width / 2;
var centerY = height / 2;
var scale = 20; // Pixels per unit
// Draw Grid
ctx.strokeStyle = '#f0f0f0';
ctx.lineWidth = 1;
for(var x = 0; x <= width; x += scale) {
ctx.beginPath(); ctx.moveTo(x, 0); ctx.lineTo(x, height); ctx.stroke();
}
for(var y = 0; y <= height; y += scale) {
ctx.beginPath(); ctx.moveTo(0, y); ctx.lineTo(width, y); ctx.stroke();
}
// Draw Axes
ctx.strokeStyle = '#333';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(0, centerY); ctx.lineTo(width, centerY); // X-axis
ctx.moveTo(centerX, 0); ctx.lineTo(centerX, height); // Y-axis
ctx.stroke();
// Draw Parabola
ctx.strokeStyle = '#e74c3c';
ctx.lineWidth = 3;
ctx.beginPath();
var first = true;
for (var px = -20; px = 0 && canvasY <= height) {
if (first) {
ctx.moveTo(canvasX, canvasY);
first = false;
} else {
ctx.lineTo(canvasX, canvasY);
}
}
}
ctx.stroke();
// Mark Vertex
ctx.fillStyle = '#2980b9';
ctx.beginPath();
ctx.arc(centerX + (vx * scale), centerY – (vy * scale), 5, 0, Math.PI * 2);
ctx.fill();
}
// Run once on load
window.onload = function() {
calculateGraph();
};