🧮
🧮 Math & statistics

Equation of a Line from Two Points

Results update as you type.

Your numbers

Understanding the line equation from two points — concept and principle

Two distinct points determine exactly one straight line. This calculator turns two points into the line's equation in slope-intercept form (y = mx + b) and in standard form (Ax + By = C), and also gives the slope, the line's direction angle and the slope of any perpendicular line. It is used in algebra and analytic geometry, for linear interpolation between two data points, for straight-line trends and for road or ramp gradients.

Line through (1, 3) and (4, 9) drawn as a staircaseBetween (1, 3) and (4, 9) the line rises 6 over a run of 3, so each step is 1 right and 2 up: slope 2. Going back one step from (1, 3) lands on the y-axis at 1, so y = 2x + 1. The angle is about 63.43°, and a perpendicular line has slope −0.5.Climb the stairs: 1 right, 2 up01234501357912(1, 3)(4, 9)b = 1slope (9 − 3) ÷ (4 − 1) = 6 ÷ 3m = 2b = 3 − 2 × 1 = 1y = 2x + 1angle = arctan 2≈ 63.43°perpendicular: −1 ÷ 2slope −0.5standard form: 2x − y = −1
Slope = rise ÷ run; then b = y₁ − m·x₁.

How it is calculated

If x₁ = x₂, the line is vertical and its equation is x = x₁.

The principle

On a straight line, the ratio of vertical change to horizontal change is the same between any two of its points. That constant ratio is the slope. Once you know m, any known point fixes where the line sits: substituting (x₁, y₁) into y = mx + b gives b. The standard form comes from cross-multiplying the two-point form (y − y₁)(x₂ − x₁) = (x − x₁)(y₂ − y₁), which also works for vertical lines. The slope equals tan θ, so the angle is its arctangent. Two non-vertical lines are perpendicular when the product of their slopes is −1, because rotating a direction (Δx, Δy) by 90° gives (−Δy, Δx).

Worked example

  1. Inputs: (x₁, y₁) = (1, 3), (x₂, y₂) = (4, 9).
  2. Slope: (9 − 3) ÷ (4 − 1) = 6 ÷ 3 = 2.
  3. Intercept: 3 − 2 × 1 = 1, so y = 2x + 1.
  4. Standard form: cross-multiplying gives 6x − 3y = −3; dividing by 3 gives 2x − y = -1.
  5. Angle: arctan(2) ≈ 63.43494882°; perpendicular slope: −1 ÷ 2 = -0.5.

How to read the result

A slope of 2 means y rises 2 for every 1 unit of x. As a gradient, slope × 100 is the percent grade, so 2 is a 200% grade, about 63.4°. The intercept 1 is where the line crosses the y-axis. You can check the equation by substituting both points: 2 × 4 + 1 = 9.

Common mistakes

Keep in mind: For a horizontal line (slope 0), the perpendicular is vertical and has no finite slope, and for a vertical line the slope-based outputs are undefined. Interpret those values with care.

Frequently asked questions

How do I write the line in point-slope form?

Use y − y₁ = m(x − x₁). For the example, y − 3 = 2(x − 1).

How do I find the x-intercept?

Set y = 0: x = −b ÷ m. For y = 2x + 1, x = −0.5.

How do I tell if two lines are parallel?

Non-vertical lines are parallel when their slopes are equal and their intercepts differ.

Sources: R. Descartes, La Géométrie (1637), foundation of analytic geometry · J. Stewart, L. Redlin and S. Watson, Precalculus: Mathematics for Calculus, Cengage, chapter on lines

Checked 8 Nov 2026. Standard formulas, computed in your browser with double-precision numbers.

🧮 All math & statistics tools →🌍 Calculators by country →