Line Equation Calculator
Equation of a line from two points or from a point and a slope: y = mx + n, general form ax + by + c = 0, slope angle and axis intercepts.
What is the equation of a line?
A line in the plane is fixed by two pieces of information: two points on it, or one point and its slope. The most common way to write it is y = mx + n, where m is the slope and n is where the line crosses the y axis.
Line through two points
Find the slope first: m = (y₂ − y₁) / (x₂ − x₁). Then substitute one of the points: n = y₁ − m × x₁.
Example: for the line through (1, 2) and (3, 6), m = (6 − 2) / (3 − 1) = 2 and n = 2 − 2 × 1 = 0. The equation is y = 2x.
Line from a point and a slope
Write y − y₀ = m × (x − x₀) and rearrange. For the line through (2, 3) with slope 0.5, n = 3 − 0.5 × 2 = 2 and the equation is y = 0.5x + 2.
General form
The same line can be written as ax + by + c = 0. This form also covers vertical lines, where b is zero and the equation becomes x = constant. From the general form the slope is −a / b, the y intercept is −c / b and the x intercept is −c / a.
Slope angle and intercepts
The slope angle is the angle between the line and the +x axis and follows from tan θ = m. A slope of 1 gives 45 degrees, and a negative slope gives an angle above 90 degrees. The line meets the y axis where x = 0 and the x axis where y = 0.
Where is it used?
Finding the level at an intermediate point of a ramp, pipe or slab from the levels at its two ends, interpolating linearly between two measurements, or finding where the extension of an edge lands on a drawing all use the equation of a line.
Limits
The calculator handles lines in the plane. Two identical points do not define a line. A vertical line has no defined slope.
Frequently asked questions
How do you find the equation of a line from two points?
For example, the two point slope formula gives slope 2 and equation y = 2x + 1 through (1, 3) and (3, 7). Substituting either point determines the intercept, and this method requires distinct points in a plane, with vertical lines having undefined slope.
Related calculators
-
Geometry
Intersection of Two Lines Calculator
The point where two lines meet and the angle between them. Enter the lines as y = mx + n, ax + by + c = 0 or by two points each. Parallel and coincident cases are flagged. -
Geometry
Distance Between Two Points Calculator
Distance between two points from their coordinates, in the plane and in space. Midpoint, coordinate differences, slope and direction angle, with working. -
Geometry
Slope Calculator: Percent, Degrees and Elevation Rise
Calculate slope from rise and horizontal run in percent, degrees and 1:n ratio. Find elevation change, end level or run. Free, with formulas and steps. -
Geometry
Circle and Tangent Calculator
Length and touch points of the tangents from an outside point to a circle, where a line cuts a circle, and the position and common tangent lengths of two circles. -
Mathematics
Trigonometry Calculator: Sin, Cos, Tan and Inverses
Calculate sin, cos, tan, cot, sec and csc in degrees, radians or gradians. Use inverse functions to find angles within one turn. Free, no account needed. -
Geometry
2D Transformation Matrix: Rotate and Translate Coordinates
Translate, rotate, scale and reflect a list of points. Chains the steps in order and gives the 3×3 transformation matrix, the new coordinates and a before and after sketch.
Found a mistake or something missing?
If a value looks wrong, a size is missing or you need a feature, write to us and we will fix it.