Graphing a Line Calculator (y = mx + b)
Use this calculator to find the equation, intercepts, and example points for a straight line given its slope and y-intercept. The calculator uses the common slope-intercept form: y = mx + b.
Example Points on the Line:
"; pointsTable += "| x | y |
|---|---|
| " + x + " | " + y + " |
Line Properties:
" + "Equation of the Line:" + equation + "" +
"Y-intercept: " + yIntCoords + "" +
"X-intercept: " + xIntCoords + "" +
pointsTable;
}
.calculator-container {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f9f9f9;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
max-width: 600px;
margin: 20px auto;
border: 1px solid #ddd;
}
.calculator-container h2 {
color: #333;
text-align: center;
margin-bottom: 20px;
font-size: 1.8em;
}
.calculator-container h3 {
color: #555;
margin-top: 20px;
margin-bottom: 10px;
font-size: 1.3em;
}
.calculator-container p {
color: #666;
line-height: 1.6;
margin-bottom: 10px;
}
.calc-input-group {
margin-bottom: 15px;
display: flex;
flex-direction: column;
}
.calc-input-group label {
margin-bottom: 5px;
color: #333;
font-weight: bold;
}
.calc-input-group input[type="number"] {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1em;
width: 100%;
box-sizing: border-box;
}
.calc-button {
background-color: #007bff;
color: white;
padding: 12px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1.1em;
width: 100%;
box-sizing: border-box;
transition: background-color 0.3s ease;
}
.calc-button:hover {
background-color: #0056b3;
}
.calc-result {
margin-top: 25px;
padding: 15px;
background-color: #e9f7ef;
border: 1px solid #d4edda;
border-radius: 5px;
color: #155724;
}
.calc-result p {
margin-bottom: 8px;
}
.calc-result code {
background-color: #e0e0e0;
padding: 2px 5px;
border-radius: 3px;
font-family: 'Courier New', Courier, monospace;
color: #c7254e;
}
.calc-result table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}
.calc-result table th,
.calc-result table td {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
}
.calc-result table th {
background-color: #f2f2f2;
font-weight: bold;
}
.calc-result .error {
color: #dc3545;
font-weight: bold;
}
Understanding the Slope-Intercept Form: y = mx + b
Graphing a straight line is a fundamental concept in algebra and geometry. One of the most intuitive ways to represent and graph a line is using the slope-intercept form, which is expressed as y = mx + b.
What Do 'm' and 'b' Represent?
- m (Slope): The slope of a line, denoted by 'm', measures its steepness and direction. It's defined as the "rise over run" – the change in the y-coordinate divided by the change in the x-coordinate between any two distinct points on the line.
- A positive slope (m > 0) indicates the line rises from left to right.
- A negative slope (m < 0) indicates the line falls from left to right.
- A slope of zero (m = 0) indicates a horizontal line.
- An undefined slope indicates a vertical line (which cannot be represented in y = mx + b form).
- b (Y-intercept): The y-intercept, denoted by 'b', is the point where the line crosses the y-axis. At this point, the x-coordinate is always zero. So, the y-intercept is the point
(0, b).
How to Graph a Line Using Slope-Intercept Form
Once you have the equation in y = mx + b form, graphing the line becomes straightforward:
- Plot the Y-intercept: Start by plotting the point
(0, b)on the y-axis. This is your starting point. - Use the Slope to Find More Points: From the y-intercept, use the slope 'm' (rise over run) to find at least one more point.
- If
m = 2, it means2/1. From your y-intercept, go up 2 units (rise) and right 1 unit (run) to find a new point. - If
m = -3/4, it means-3/4. From your y-intercept, go down 3 units (rise of -3) and right 4 units (run of 4) to find a new point.
- If
- Draw the Line: Connect the plotted points with a straight line, extending it in both directions with arrows to indicate it continues infinitely.
Finding the X-intercept
The x-intercept is the point where the line crosses the x-axis. At this point, the y-coordinate is always zero. To find the x-intercept, set y = 0 in the equation y = mx + b and solve for x:
0 = mx + b
-b = mx
x = -b / m (provided m is not zero)
The x-intercept is the point (-b/m, 0).
Example: Graphing y = 2x + 3
Let's use the calculator's default values: m = 2 and b = 3.
- Y-intercept: The line crosses the y-axis at
(0, 3). Plot this point. - Slope: The slope is
m = 2, which can be written as2/1. From(0, 3), move up 2 units and right 1 unit to find another point,(1, 5). - X-intercept: Set
y = 0:0 = 2x + 3-3 = 2xx = -3/2 = -1.5
So, the x-intercept is(-1.5, 0).
Connecting these points will give you the graph of the line y = 2x + 3.
Use the calculator above to experiment with different slopes and y-intercepts to see how they affect the line's equation, intercepts, and points.