Slope and line equation from two points

Enter the coordinates of two points to get the slope and line equation. Vertical lines are handled too.

Loading the tool…

Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.

How to use it

  1. Enter x1, y1, x2 and y2.
  2. The result appears straight away and updates as you edit.
  3. Copy the result, or copy a link that keeps the same values to share it.

How it is calculated

Slope m = (y2 - y1) / (x2 - x1), y-intercept b = y1 - m·x1, angle θ = arctan(m). If x1 = x2 the line is vertical, x = x1, with undefined slope.

Example

Inputs: x1 = 1, y1 = 2, x2 = 3, y2 = 8. Result: Slope m: 3; Y-intercept b: -1; Angle of inclination: 71.5651 °.

Limits and caveats

  • The angle is measured from the positive x axis, between -90 and 90 degrees.
  • Long decimals are rounded in the equation.

Questions about this tool

What does a negative slope mean?

The line falls as you move right: y decreases as x increases.

Why is a vertical line's slope undefined?

Because x2 - x1 is zero and division by zero is undefined.

Does the order of the points matter?

No. Swapping the points gives the same slope and equation.