Equation of a Line from Two Points
This calculator finds the equation of a straight line that passes through two points on the coordinate plane. Just enter the coordinates of the first point (x₁, y₁) and the second point (x₂, y₂) and it instantly returns the slope m, the y-intercept b and the full slope-intercept equation y = mx + b. It is a handy tool for students working through algebra and analytic geometry homework, for teachers preparing examples, and for anyone who needs to describe a linear relationship between two variables. The result updates as you type, so you can experiment with different points and see how the line changes right away.
Equation of the line
Slope (m)
Y-intercept (b)
The slope is found with m = (y₂ − y₁) / (x₂ − x₁) and the equation is y = m·x + b. If x₁ = x₂ the line is vertical and its slope is undefined.
Publicidad
How it works
The slope measures how steep the line is and is calculated as the change in y divided by the change in x: m = (y₂ − y₁) / (x₂ − x₁). Once you know the slope you can write the point-slope form y − y₁ = m(x − x₁), and rearranging it gives the slope-intercept form y = mx + b, where b is the value of y when x equals zero. This calculator computes b directly as b = y₁ − m·x₁. When both points share the same x-coordinate (x₁ = x₂) the denominator becomes zero, so the slope is undefined: the line is vertical and its equation is simply x = x₁ rather than y = mx + b.
Publicidad
Preguntas frecuentes
- How do I find the slope from two points?
- Subtract the y-coordinates and divide by the difference of the x-coordinates: m = (y₂ − y₁) / (x₂ − x₁). For the points (0, 0) and (2, 4) the slope is (4 − 0) / (2 − 0) = 2, meaning y increases by 2 for every 1 unit that x increases.
- What is the y-intercept b?
- The y-intercept is the value of y where the line crosses the vertical axis, that is, where x = 0. It is calculated as b = y₁ − m·x₁. In the equation y = mx + b it is the constant term, and it tells you the starting height of the line.
- What does the slope-intercept form y = mx + b mean?
- It is the most common way to write a line: m is the slope (how steep it is) and b is the y-intercept (where it crosses the y-axis). Given any x, you multiply it by m and add b to get the corresponding y on the line.
- Why can the slope be undefined?
- If the two points have the same x-coordinate (x₁ = x₂), the denominator (x₂ − x₁) is zero and division by zero is not defined. Geometrically the line is vertical, so it has no y = mx + b form; its equation is simply x = x₁.
- Can the slope be negative or zero?
- Yes. A negative slope means the line goes down from left to right, a positive slope means it goes up, and a slope of zero means the line is perfectly horizontal (y stays constant). This happens when the two points have the same y-coordinate.