Slope & Line Equation Calculator
Solve and visualize a straight line from two points, slope and intercept, slope and a point, or standard-form coefficients. Compare exact slope-intercept, point-slope and standard equations, including horizontal and vertical cases. Add a probe point to construct a parallel and a perpendicular through it. The graph shows where the perpendicular meets the original line and why that segment gives the shortest distance. Inspect the exact coordinates and export the results as CSV.
Line equation workspace
Find the exact equation, then explore how a point projects onto the line.
Line and probe inputs
Each form keeps its own entries. Use signed decimals or fractions such as -3/4.
Line equation y = 2x + 1. Distance 2.236068.
Line equation
y = 2x + 1
- Slope
- 2
- Direction
- increasing
- X-intercept
- -1/2
- Y-intercept
- 1
Standard form
2x − y = −1
Point-slope form
y − 3 = 2(x − 1)
Parallel through P
y = 2x − 4
Perpendicular through P
y = −(1/2)x + 6
Perpendicular distance 2.236068 units. Squared distance 5.
Coordinate graph
Equal scale on both axes. Each side spans 9.1 units. The center is (2, 3.5).
Exact coordinates
| Point | x | y |
|---|---|---|
| A · Reference point | 1 | 3 |
| B · Second input point | 3 | 7 |
| P · Probe point | 4 | 4 |
| F · Perpendicular foot | 2 | 5 |
How to use this calculator
- Choose an Input form based on what you know. For Two points, enter First point x and y and Second point x and y. The two coordinate pairs must differ.
- For Slope and intercept, enter Slope (m) and Y-intercept (b). For Point and slope, enter the first point and its slope. Type vertical in Slope (m) for a vertical line in this mode. For Standard form, enter X coefficient (A), Y coefficient (B) and Right-hand side (C) from Ax + By = C.
- Set Probe point x and y to locate the point through which both comparison lines pass. The perpendicular foot is where the perpendicular meets the original line.
- Use the graph and exact equation results together. Inspect the intercepts, compare the three lines and check the point-to-line distance against the plotted perpendicular segment.
- Use Download line CSV to retain the exact values and coordinates with the calculated distance. Show selectable CSV displays the same data for copying.
The Formula
The mathematical logic powering this calculation is:
For distinct points (x₁, y₁) and (x₂, y₂), let Δx = x₂ − x₁ and Δy = y₂ − y₁. When Δx ≠ 0, the slope is m = Δy/Δx. The point-slope equation is y − y₁ = m(x − x₁). Expanding gives slope-intercept form y = mx + b, with b = y₁ − mx₁. If Δx = 0, the line is x = x₁ and slope is undefined.
Standard form is Ax + By = C. The calculator clears fractional denominators, divides A, B and C by their common factor, and chooses the sign so the first nonzero coefficient among A and B is positive. For B ≠ 0 the slope is −A/B and the y-intercept is (0, C/B). For A ≠ 0 the x-intercept is (C/A, 0). An axis can have no intersection or infinitely many intersections with the line. A single intercept is shown only when it is unique.
For a probe point P = (p, q), write K = Ap + Bq. The same-direction line through P is Ax + By = K. It coincides with the original when K = C. A perpendicular through P is −Bx + Ay = −Bp + Aq. These formulas also handle horizontal and vertical lines.
The normal vector (A, B) points perpendicular to the original line. With s = (K − C)/(A² + B²), subtract s(A, B) from P to get the perpendicular foot H = (p − sA, q − sB). Substituting H into the original equation gives C. The shortest distance from P to the infinite line is |K − C|/√(A² + B²), and its square is (K − C)²/(A² + B²).
Coordinates, slopes and coefficients accept signed plain decimals with at most nine decimal places or integer fractions such as −3/4 (type -3/4). Each fraction component is limited to 12 digits and the denominator must be positive. Editable values must fall within ±1,000,000. Calculations use exact fractions for equations and coordinates. Distance is shown as a numerical approximation and squared distance remains exact. The graph uses numerical coordinates for display.Worked Example
If you input:
- Input form: Two points
- First point x: 1
- First point y: 3
- Second point x: 3
- Second point y: 7
- Probe point x: 4
- Probe point y: 4
Result:
From (1, 3) to (3, 7), the rise is 4 and the run is 2, giving slope 2. The point-slope equation y − 3 = 2(x − 1) expands to y = 2x + 1. In standard form this is 2x − y = −1. The intercepts are (−1/2, 0) and (0, 1). Through the probe point (4, 4), the parallel is 2x − y = 4 and the perpendicular is x + 2y = 12. Solving the original and perpendicular together gives the foot (2, 5). The probe is two units right and one unit below the foot, so the distance is √5 ≈ 2.23607 coordinate units.
Frequently Asked Questions
How do I find slope-intercept form from two points?
Divide the change in y by the change in x to find m. Substitute either point into b = y − mx to find b, then write y = mx + b. For two distinct points with the same x-coordinate, write the vertical equation x = x₁ instead.
Can a line have zero slope or undefined slope?
A horizontal line has zero slope because y stays fixed as x changes. A vertical line has undefined slope because the change in x is zero. Its equation is x = constant, since a single x-coordinate corresponds to every y-coordinate.
Why do the standard-form coefficients change?
Multiplying all three coefficients by the same nonzero number preserves the solutions. The calculator uses the smallest integer triple with its first nonzero normal coefficient positive, so equivalent inputs yield a consistent equation.
What if A and B are both zero?
The equation reduces to 0 = C. When C is zero, every point satisfies the equation. Otherwise, no point satisfies it. Both cases lack a unique line. Two identical input points also fail to fix a unique line, since infinitely many lines pass through that one point.
What if the parallel through the probe overlaps the original?
A probe on the original line makes the same-direction line coincide with it. In that case the perpendicular foot is the probe itself and the distance is zero. A probe off the line gives a distinct parallel.
Can a line have infinitely many intercepts?
For each axis, the calculator looks for a unique point of intersection. If a line coincides with an axis, every point of that axis is shared. If it is parallel to an axis and separate, there is no intersection with that axis. Both cases lack a unique intercept.
Does the distance depend on the two points I used to enter the line?
Any two distinct points on the same line give the same perpendicular distance. The calculator measures distance to the entire line, so the perpendicular foot may fall outside the segment between your two points.
Similar Calculators
System of Equations Calculator
Solve 2–4 simultaneous linear equations with exact fractions, elimination steps, a two-variable graph, and checks for unique, infinite or no solutions.
Linear Regression Calculator
Fit a least-squares line, inspect scatter and residual plots, and calculate Student-t confidence and prediction intervals. Paste paired data and export the full ledger.
Vector Calculator
Explore 2D and 3D vectors: dot and cross products, angles, addition, projections and area, with interactive geometry, exact arithmetic and CSV.
