A line equation calculator turns two points into the equation of the line through them, in slope-intercept, point-slope and standard form, and gives the slope, the intercepts, the distance, the midpoint and the angle of the line. It also finds where two lines cross, and the second endpoint of a segment when you know one endpoint and the midpoint. Enter the numbers and press the button. The formulas are the two-point form shown on Wikipedia's page on linear interpolation and the line-line intersection formulas, and the work is done in your browser.
How to use the line equation calculator
- Choose what you want.
- For a line, enter point 1 and point 2 as x and y values.
- For two lines that cross, enter a, b and c for each line written as ax + by = c.
- For a missing endpoint, enter the known endpoint and the midpoint.
- For a point and slope, a standard form conversion or a parallel or perpendicular line, pick that job and fill in the boxes shown.
- Press Work out the result.
The equation of a line through two points
The slope is the change in y divided by the change in x: (y2 − y1) divided by (x2 − x1). The page on linear interpolation writes the line through two points as y minus y1 over x minus x1 equals the same slope [1]. For the points (0, 1) and (2, 5), the slope is 4 divided by 2, which is 2. Then the slope-intercept form is y = 2x + 1, the point-slope form is y − 1 = 2(x − 0), and the standard form is 2x − y = −1. The y-intercept is 1 and the x-intercept is −0.5, the value of x where y is 0. The calculator shows the three forms, the distance between the points, the midpoint (1, 3) and the angle of the line.
Horizontal and vertical lines
If the two points have the same y, the slope is 0 and the line is horizontal, such as y = 3. If they have the same x, the line is vertical, written x = 2. A vertical line has no slope, since the change in x is 0, and no y-intercept unless it is the y axis itself. The calculator writes these cases in their own form and leaves out the slope. If the two points are the same, no single line is defined and you see a message.
Where two lines cross
Write each line as ax + by = c. The determinant D is a1 times b2 minus a2 times b1. When D is not zero, the lines cross at one point, found with Cramer's rule: x is (c1 b2 − c2 b1) divided by D, and y is (a1 c2 − a2 c1) divided by D. This agrees with the line-line intersection formulas on Wikipedia [2]. For x + y = 2 and x − y = 0, D is −2, and the lines cross at (1, 1). If D is zero, the lines are either parallel or the same line, and the calculator tells you which by checking the constants.
Finding the other endpoint from a midpoint
The midpoint of a segment is the average of its endpoints, so the missing endpoint is twice the midpoint minus the known endpoint, for each coordinate. If one end is (1, 2) and the midpoint is (3, 4), the other end is (5, 6). The calculator also gives the length of the segment, which is the square root of 32 here, about 5.657.
The three forms of a line
The slope-intercept form, y = mx + b, shows the slope and where the line meets the y axis, which makes it good for graphing [3]. The point-slope form shows a point you know and the slope, which makes it the natural form when you start from data. The standard form, ax + by = c, handles vertical lines and is easy to combine with another equation. When the inputs are whole numbers, the calculator gives the standard form with whole-number coefficients that have no common factor.
A worked example with a negative slope
Take the points (0, 2) and (4, 0). The slope is (0 − 2) divided by (4 − 0), which is −0.5. The y-intercept is 2, so the slope-intercept form is y = −0.5x + 2, and the x-intercept is 4. Multiplying by 2 and moving terms gives the standard form x + 2y = 4, with whole-number coefficients. The midpoint is (2, 1) and the distance between the points is the square root of 20, about 4.472. The calculator shows all of these together.
Point and slope, standard form, parallel and perpendicular lines
With a point and a slope m, the point-slope form is y − y1 = m(x − x1). For the point (2, 8) and the slope 12, it expands to y = 12x − 16 [3]. For a line written ax + by = c with b not zero, the slope is −a divided by b and the y-intercept is c divided by b, which is our rearrangement of the slope and intercept formulas for ax + by + c = 0 [3]. The line 2x + 3y = 6 has slope −2/3, y-intercept 2 and x-intercept 3. With b equal to zero the line is vertical. Two lines are parallel when their slopes are equal or both are vertical, and perpendicular when the product of their slopes is −1, or one is horizontal and the other vertical [4]. Through the point (0, −2), the line parallel to y = −3x + 1 is y = −3x − 2, and the perpendicular one is y = x/3 − 2 [4]. In the crossing tool, parallel lines are reported as such instead of giving a point.
Common mistakes
- Swapping the order of subtraction. Use the same order for y and for x.
- Giving a vertical line a slope. It has none.
- Forgetting the sign in the standard form. Check the minus signs.
- Entering two equal points. They do not define one line.
- Writing lines in the wrong form for crossings. Use ax + by = c with the constant on the right.
What next
Use this often? Add Line Equatio to your Home screen.
Frequently asked questions
What is a line equation calculator?
A tool that finds the equation of a line from two points in several forms, and also finds where lines cross and a missing endpoint.
How do you find the equation of a line through two points?
Find the slope (y2 − y1)/(x2 − x1), then use y = mx + b or y − y1 = m(x − x1). Points (0, 1) and (2, 5) give y = 2x + 1.
What is the slope-intercept form?
y = mx + b, where m is the slope and b is the y-intercept, the value of y when x is 0.
How do you find where two lines intersect?
Solve the two equations together. For ax + by = c lines, x = (c1b2 − c2b1)/D and y = (a1c2 − a2c1)/D, with D = a1b2 − a2b1.
How do you find an endpoint from the midpoint?
Double the midpoint and subtract the known endpoint, for x and y. With endpoint (1, 2) and midpoint (3, 4), the other end is (5, 6).
How do you find a parallel or perpendicular line?
Keep the slope for a parallel line. For a perpendicular line, the slopes multiply to −1. Then use your point to find the intercept.
Sources
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.