What is a line equation from two points?
Any two distinct points that are not stacked vertically determine exactly one straight line. This calculator takes the coordinates of those two points, and , and returns the line’s equation in slope-intercept form:
where is the slope (how steep the line is) and is the y-intercept (where the line crosses the vertical axis). The calculator reports the slope, the y-intercept, and the assembled equation.
How does it work?
The calculation happens in two steps.
Step 1 — the slope. The slope is the ratio of the vertical change to the horizontal change between the two points:
Step 2 — the y-intercept. Once the slope is known, substitute either point back into and solve for :
With and in hand, the equation is simply .
Worked examples
Example 1: a line through the origin
For the points and :
The equation is . Because the y-intercept is zero, the line passes through the origin.
Example 2: a positive slope with a negative intercept
For the points and :
The equation is . The line crosses the y-axis two units below the origin.
Example 3: a horizontal line
For the points and :
The equation is , more simply written . A zero slope means the line is flat.
What about vertical lines?
If the two points share the same x-coordinate (), the run is zero and the slope is undefined — you cannot divide by zero. Such a line is vertical and its equation is , which cannot be written in the form . In this case the calculator leaves the slope, y-intercept, and equation empty.
Notes
- The slope alone tells you the direction of the line; pair this tool with the slope calculator if that is all you need.
- The order of the two points does not matter. Swapping them negates both the numerator and denominator of the slope, leaving unchanged, and the y-intercept comes out the same.
- The midpoint calculator finds the point halfway between the two coordinates, which always lies on this same line.
FAQ
What is the equation of the line through (1,1) and (3,7)?
The slope is and the y-intercept is , so the equation is .
How do I find the y-intercept from two points?
First compute the slope , then plug one point into . For with , that gives .
Why is there no equation for two vertical points?
When both points have the same x-coordinate the line is vertical, its slope is undefined, and it cannot be expressed as . Its equation is instead.