Skip to content
Math

Line Equation from Two Points Calculator

Enter two points on the coordinate plane and this calculator instantly gives you the line through them in every standard form: slope-intercept (y = mx + b), standard form (Ax + By + C = 0), point-slope, and parametric. You also get the slope, x-intercept, y-intercept, angle of inclination, the distance between the two points, and the midpoint. A step-by-step panel shows the full working, and a chart plots the line for you.

Your details

The x-coordinate of the first point.
The y-coordinate of the first point.
The x-coordinate of the second point.
The y-coordinate of the second point.
Slope-intercept form
y = 2x + 0

y = mx + b

Slope (m)2
y-intercept (b)0
Standard form6x - 3y = 0
Point-slope form (P₁)y - 2 = 2(x - 1)
Point-slope form (P₂)y - 8 = 2(x - 4)
Parametric formx(t) = 1 + 3t, y(t) = 2 + 6t
x-intercept0
Angle of inclination63.43deg
Distance between points6.7082
Midpoint(2.5, 5)
Parallel line slope2
Perpendicular line slope-0.5
-7517-339
x

Line equation: y = 2x + 0

  • The line has a positive slope (rises left to right) of 2.
  • It crosses the x-axis at x = 0 and the y-axis at y = 0.
  • The two points are 6.7082 units apart, with midpoint at (2.5, 5).
  • The line makes an angle of 63.4349° with the positive x-axis.
  • Any perpendicular line to this one has slope -0.5.

Next stepUse the standard form (Ax + By + C = 0) when you need to work with systems of equations, or the parametric form for vectors and physics problems.

Formula

m=y2y1x2x1,y=mx+b,b=y1mx1,d=(x2x1)2+(y2y1)2m = \dfrac{y_2 - y_1}{x_2 - x_1}, \quad y = mx + b, \quad b = y_1 - mx_1, \quad d = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}

Worked example

Given P1 = (1, 2) and P2 = (4, 8): slope m = (8-2)/(4-1) = 6/3 = 2. Then b = 2 - 2*1 = 0. Slope-intercept form: y = 2x. Standard form: 2x - y = 0. Distance = sqrt(3^2 + 6^2) = sqrt(45) = 6.708. Midpoint = (2.5, 5). Angle = arctan(2) = 63.43 degrees.

How to find the equation of a line from two points

To find the equation of a line through two points (x1, y1) and (x2, y2), start by calculating the slope: m = (y2 - y1) / (x2 - x1). If x1 equals x2 the line is vertical and its equation is simply x = x1. Otherwise, substitute the slope and one point into y = mx + b and solve for the y-intercept b: b = y1 - m * x1. The complete slope-intercept form is then y = mx + b. For example, given (1, 2) and (4, 8), the slope is (8 - 2)/(4 - 1) = 2, and the y-intercept is 2 - 2 * 1 = 0, giving y = 2x.

The four standard forms of a line equation

Every non-vertical line can be written in several equivalent forms depending on the context. The slope-intercept form y = mx + b is the most common and makes it easy to read off the slope and y-intercept at a glance. The standard form Ax + By + C = 0 (sometimes called the general form) is preferred in algebra and systems of equations because it avoids fractions and treats x and y symmetrically. The point-slope form y - y1 = m(x - x1) is useful when you know the slope and one point on the line. The parametric form writes x and y as functions of a parameter t: x(t) = x1 + (x2 - x1) * t, y(t) = y1 + (y2 - y1) * t. At t = 0 you get point P1 and at t = 1 you get point P2, making the parametric form ideal for vectors, physics, and computer graphics.

Intercepts, angle of inclination, and special lines

The y-intercept is where the line crosses the y-axis (set x = 0 in the equation). The x-intercept is where it crosses the x-axis (set y = 0 and solve, which gives x = -b/m for a non-horizontal line). The angle of inclination is the angle the line makes with the positive x-axis, calculated as arctan(m) in degrees. A horizontal line has slope 0, angle 0, and no x-intercept. A vertical line has undefined slope and angle 90 degrees, with no y-intercept.

Parallel and perpendicular lines

Two lines are parallel if and only if they have the same slope. Any line parallel to y = mx + b has the same slope m but a different y-intercept. Two lines are perpendicular if their slopes are negative reciprocals of each other: m1 * m2 = -1, so the perpendicular slope is -1/m. For example, a line with slope 2 is perpendicular to any line with slope -1/2. A horizontal line is perpendicular to a vertical line (and vice versa), with slopes 0 and undefined respectively.

Common line equation forms at a glance

FormEquationBest used for
Slope-intercepty = mx + bGraphing, reading slope and y-intercept
Standard (general)Ax + By + C = 0Systems of equations, integer coefficients
Point-slopey - y1 = m(x - x1)When slope and one point are known
Parametricx = x0 + dx*t, y = y0 + dy*tVectors, physics, computer graphics
Vertical linex = cLines with undefined slope
Horizontal liney = cLines with slope 0

Each form is mathematically equivalent for any non-vertical, non-horizontal line.

Frequently asked questions

What is the slope-intercept form of a line?

The slope-intercept form is y = mx + b, where m is the slope (rise over run) and b is the y-intercept (where the line crosses the y-axis). It is the most widely used form because you can read off the slope and intercept directly from the equation without solving anything.

How do I find the equation of a line through two points?

First compute the slope: m = (y2 - y1) / (x2 - x1). Then substitute the slope and either point into y = mx + b and solve for b. Finally write the full equation y = mx + b. If x1 = x2 the line is vertical and its equation is x = x1. This calculator does all three steps for you and shows the working.

What is the standard form of a line equation?

Standard form (also called general form) is Ax + By + C = 0, where A, B, and C are constants and A is typically positive. It is equivalent to slope-intercept form but avoids having y isolated on one side, which can be convenient when working with systems of linear equations.

What is the point-slope form?

Point-slope form is y - y1 = m(x - x1), where m is the slope and (x1, y1) is any known point on the line. It is especially useful as an intermediate step when you know the slope and one point but have not yet calculated the y-intercept.

What does the parametric form of a line mean?

The parametric form writes x and y as separate functions of a parameter t: x(t) = x1 + dx*t and y(t) = y1 + dy*t, where (dx, dy) is the direction vector from P1 to P2. At t = 0 you get point P1, at t = 1 you get point P2, and other values of t trace the rest of the line. This form is standard in physics (trajectory of a particle), computer graphics (ray-line intersection), and linear algebra.

How do I find the x-intercept of a line?

Set y = 0 in the slope-intercept equation and solve for x: 0 = mx + b, so x = -b/m. This only works for non-horizontal lines. A horizontal line (slope = 0) never crosses the x-axis unless it is y = 0 itself (in which case every point is an x-intercept). This calculator computes the x-intercept automatically.

What is the angle of inclination of a line?

The angle of inclination is the angle, measured in degrees, between the line and the positive x-axis. It equals arctan(m), where m is the slope. A horizontal line has angle 0 degrees, a line sloping upward at 45 degrees has slope 1, and a vertical line has angle 90 degrees with an undefined slope.

What slope does a line perpendicular to this one have?

If the original line has slope m, any perpendicular line has slope -1/m (the negative reciprocal). For example, a line with slope 3 is perpendicular to one with slope -1/3. A horizontal line (m = 0) is perpendicular to a vertical line, which has an undefined slope.

Sources

Written by Dr. Rajiv Menon, PhD Applied Mathematician · Bengaluru, India

Applied mathematician bridging algebraic theory and computational tools for students, engineers, and everyday problem-solvers.

Search 3,500+ calculators

Loading search…