function toggleInputs() {
var isLinear = document.getElementById("typeLinear").checked;
document.getElementById("linearInputs").style.display = isLinear ? "block" : "none";
document.getElementById("quadraticInputs").style.display = isLinear ? "none" : "block";
}
function calculateGraph() {
var isLinear = document.getElementById("typeLinear").checked;
var output = document.getElementById("outputContent");
var tableDiv = document.getElementById("pointTable");
var resDiv = document.getElementById("results");
var html = "";
var pointsHtml = "";
if (isLinear) {
var m = parseFloat(document.getElementById("linearM").value);
var b = parseFloat(document.getElementById("linearB").value);
if (isNaN(m) || isNaN(b)) {
alert("Please enter valid numbers for slope and intercept.");
return;
}
var xIntercept = m !== 0 ? (-b / m).toFixed(2) : "None (Parallel to X-axis)";
html += "Standard Form: y = " + m + "x + " + b + "";
html += "Slope: " + m + "";
html += "Y-Intercept: (0, " + b + ")";
html += "X-Intercept: (" + xIntercept + ", 0)";
html += "Direction: " + (m > 0 ? "Increasing (Upward)" : (m 0) {
var r1 = ((-b + Math.sqrt(discriminant)) / (2 * a)).toFixed(2);
var r2 = ((-b – Math.sqrt(discriminant)) / (2 * a)).toFixed(2);
roots = "(" + r1 + ", 0) and (" + r2 + ", 0)";
} else if (discriminant === 0) {
var r = (-b / (2 * a)).toFixed(2);
roots = "(" + r + ", 0) [One Real Root]";
} else {
roots = "No Real Roots (Complex)";
}
html += "Standard Form: y = " + a + "x² + " + b + "x + " + c + "";
html += "Vertex: (" + vx.toFixed(2) + ", " + vy.toFixed(2) + ")";
html += "Y-Intercept: (0, " + c + ")";
html += "X-Intercepts (Roots): " + roots + "";
html += "Parabola Opens: " + (a > 0 ? "Upward (Minimum)" : "Downward (Maximum)") + "";
html += "Discriminant (Δ): " + discriminant.toFixed(2) + "";
pointsHtml = generateTable(function(x) { return (a * x * x) + (b * x) + c; });
}
output.innerHTML = html;
tableDiv.innerHTML = pointsHtml;
resDiv.style.display = "block";
}
function generateTable(func) {
var table = "
Example Data Points
";
table += "
";
table += "
x
y = f(x)
";
for (var x = -3; x <= 3; x++) {
var y = func(x);
table += "
" + x + "
" + y.toFixed(2) + "
";
}
table += "
";
return table;
}
Understanding Graph Equations
A graph equation is a mathematical statement that defines the relationship between two variables, typically x (the independent variable) and y (the dependent variable). When plotted on a Cartesian coordinate plane, these equations form distinct shapes like straight lines or curves.
1. Linear Equations (y = mx + b)
A linear equation represents a straight line. The two key components are:
m (Slope): This determines the steepness and direction of the line. A positive slope goes up from left to right, while a negative slope goes down.
b (Y-Intercept): This is the point where the line crosses the vertical y-axis (at x = 0).
2. Quadratic Equations (y = ax² + bx + c)
A quadratic equation forms a U-shaped curve known as a parabola. Key features include:
Vertex: The highest or lowest point (peak or valley) of the curve.
Roots: The points where the curve crosses the x-axis (where y = 0).
Direction: If 'a' is positive, the parabola opens upward like a smile. If 'a' is negative, it opens downward like a frown.
Practical Example
Imagine you have the equation y = 2x + 1. This is a linear equation where the slope is 2 and the y-intercept is 1. To find points on the graph:
If x = 0, y = 2(0) + 1 = 1. Point: (0, 1)
If x = 1, y = 2(1) + 1 = 3. Point: (1, 3)
If x = 2, y = 2(2) + 1 = 5. Point: (2, 5)
Connecting these points results in a straight line that rises sharply.
Why Use a Graph Equation Calculator?
Manually calculating intercepts, vertices, and discriminants can be time-consuming and prone to errors. This tool helps students and professionals quickly visualize the properties of a function, check homework, or model real-world scenarios like trajectory paths or financial growth trends.