Mathematics
Equation of a line calculator
Find the equation of a straight line from two distinct points or from one point and a finite slope. Vertical lines are included, and exact and rounded values are shown separately.
Choose two points or a point and a finite slope. For two points, leave slope blank. For a point and slope, leave both second-point coordinates blank. All fields remain visible; changing mode does not clear entries. Use shared axes and consistent units.
Result
Formula / calculation:
An ideal straight line from two distinct points, including a vertical line, or a point and a finite slope. No default axis scale or units. This is not regression, a fitted trend, surveying, a graph, distance, intersection or parallel-line analysis. Exact values and rounded values are distinct; a bounded calculation may refuse a result rather than issue a partial equation.
Decimal results are approximate. Inputs stay in this browser tab.
How it works
Choose two points or a point and finite slope. Enter coordinates using shared axes and consistent units, and leave unused fields blank. Exact fractions and separate six-decimal displays are retained. A vertical line is shown as x = your entered x coordinate; its slope is undefined. Identical points cannot determine one line. No regression, fit, graph, surveying or intersection calculation is included.
Worked example
Points (1, 3) and (3, 7) give slope 2 and intercept 1, so y = 2x + 1. Points (2, 1) and (2, 3) give the vertical line x = 2. These are synthetic coordinates.
Frequently asked questions
How do I find the equation of a line through two points?
Enter two distinct points. For (1, 3) and (3, 7) the slope is 2 and the intercept 1, so y = 2x + 1.
Can I use a point and a slope?
Yes. Enter one point and a finite slope, and leave the second-point coordinates blank.
What about vertical lines?
A vertical line has no finite slope. Points (2, 1) and (2, 3) give x = 2.
What values can I enter?
Coordinates and slope from -1,000,000 to 1,000,000, with up to six decimal places and 15 characters. Use a decimal point, with no fractions or exponents.
What if the two points are identical?
Two identical points do not define one line.
Is this a regression tool?
No. It is not regression, a fitted trend, surveying, a graph, distance, intersection or parallel-line analysis.