Algebra • Linear Equations

Equation of a Line Calculator

Calculate, transform, and visualize straight lines in the Cartesian plane. Convert effortlessly between two points, point-slope, slope-intercept, standard, and intercept representations with complete algebraic proofs and interactive geometric visualization.

|
Last Updated: September 2026
|
Verified Accurate: Analytic Geometry & Linear Systems
Universal Line Equation Solver (2D Plane)
Define Line by Two Known Coordinates
Point 1 (x₁, y₁)
Point 2 (x₂, y₂)
Associated Perpendicular & Parallel Lines
Perpendicular Line through Primary Point y = -0.5x + 4
Parallel Line through Origin (0,0) y = 2x
Primary Equation (Slope-Intercept) Oblique Line
Slope-Intercept Form (y = mx + b)
y = 2x - 1
Point-Slope Form
y - 3 = 2(x - 2)
Standard Form (Ax + By = C)
2x - y = 1
General Form (Ax + By + C = 0)
2x - y - 1 = 0
Slope (m)
2
Inclination (θ)
63.43°
y-Intercept
(0, -1)
x-Intercept
(0.5, 0)
Interactive 2D Cartesian Graph Auto-Scaled Grid
Primary Line Intercepts User Point
Slope Triangle: Rise / Run
Step-by-Step Algebraic Derivation
Direct Answer & Overview
Verified Educational Guide

Core Formulas: The Equations of a Straight Line

A straight line in two-dimensional Euclidean space ℝ² represents a continuous linear manifold with constant rate of change. Given two distinct coordinates (x₁, y₁) and (x₂, y₂), the slope is m = (y₂ - y₁) / (x₂ - x₁). Substituting into point-slope form yields y - y₁ = m(x - x₁), expanding into slope-intercept form y = mx + b and standard integer form Ax + By = C.

Primary Mathematical Formula Universal Linear Representations
Standard Equation
ƒ(x)
Q.E.D.
y=mx+bquadiffquady−y1=m(x−x1)quadiffquadAx+By=Cy = mx + b quad iff quad y - y_1 = m(x - x_1) quad iff quad Ax + By = C
Valid across all non-vertical lines • Ax + By = C accommodates vertical lines (B = 0)
Exact Formula
Input Parameters
Required
1
Coordinate Pair (x₁, y₁): First known point lying on the linear path.
2
Coordinate Pair (x₂, y₂) or Slope m: Second point or constant direction vector.
Expected Outputs
Calculated
Slope-Intercept Form: y = mx + b.
Point-Slope Form: y - y₁ = m(x - x₁).
Standard Form: Ax + By = C with integer coefficients.
Slope (m) & Inclination (θ): m = tan(θ).
Worked Numerical Example
Instant Verification
Find the equation of the line passing through (1, 3) and (3, 7)
→ Step 1: Compute slope m = (7 - 3) / (3 - 1) = 4 / 2 = 2. Step 2: Use point-slope y - 3 = 2(x - 1). Step 3: Expand to y = 2x + 1.
y = 2x + 1

Theoretical Foundations of Linear Equations in ℝ²

In analytic geometry, established by René Descartes in 1637, a straight line is the geometric locus of points whose coordinates (x, y) satisfy a first-degree polynomial equation. Unlike curves of higher degree (such as parabolas, ellipses, or cubic splines), a linear relationship is characterized by a single invariant property: a constant rate of change across its entire infinite length. For zero-slope configurations, explore our dedicated Equation of a Horizontal Line Calculator.

According to Euclid's first postulate, between any two distinct points in a plane, exactly one unique straight line can be constructed. Algebraically, this means that specifying two independent geometric conditions (such as two coordinates, one coordinate and a directional slope, or two orthogonal intercepts) completely and uniquely constrains the system, determining the exact linear equation that describes all points along the path.

The fundamental algebraic definition of a line in the real affine plane ℝ² is expressed through the general linear equation:

Ax + By + C = 0   [where (A, B) ≠ (0, 0)]

Here, A, B, and C are real parameters. The condition that A and B cannot both equal zero guarantees that the equation represents a true one-dimensional continuum rather than a null set or the entire plane. Geometrically, the vector n = [A, B] constitutes the normal vector perpendicular to the line, establishing a direct bridge between Cartesian coordinate geometry and linear algebra.

The Five Algebraic Forms of a Linear Equation

Depending on whether you are graphing, optimizing linear programs, writing computer graphics engines, or performing calculus tangent evaluations, linear equations are formatted in five distinct standard mathematical structures.

A. Slope-Intercept Form: y = mx + b

The slope-intercept form is universally utilized in introductory algebra and computer plotting because it is solved explicitly for the dependent variable y as a function of x: f(x) = mx + b.

  • m (Slope): Dictates the vertical displacement per unit of horizontal advance.
  • b (y-Intercept): The value of y when x = 0, representing the coordinate (0, b).
  • Limitation: Cannot represent vertical lines because the slope of a vertical line is undefined.

B. Point-Slope Form: y - y₁ = m(x - x₁)

Derived directly from the foundational slope formula, the point-slope form is the most efficient method for constructing an equation when you are given the slope m and an arbitrary known coordinate (x₁, y₁).

  • Eliminates the intermediate algebraic step of solving for the y-intercept b first.
  • Standard tool used in differential calculus for writing tangent lines: y - f(x₀) = f'(x₀)(x - x₀).
  • Requires m to be finite, thus excluding vertical lines.

C. Standard Form: Ax + By = C

In standard form, both variable terms reside on the left-hand side, while the constant scalar occupies the right-hand side. By mathematical convention, A, B, and C are simplified into relatively prime integers where A ≥ 0.

  • Universality: Capable of representing every straight line without exception, including vertical lines (when B = 0: Ax = C &implies; x = C/A) and horizontal lines (when A = 0: By = C &implies; y = C/B).
  • Intercept Calculation: Yields rapid mental computation of intercepts: x-intercept is (C/A, 0) and y-intercept is (0, C/B).
  • Matrix Systems: Standard form is the direct format required for setting up augmented matrices in Gaussian elimination and Cramer's rule.

D. Two-Intercept (Symmetric) Form: (x / a) + (y / b) = 1

When a line crosses both the abscissa axis at (a, 0) and the ordinate axis at (0, b) where a ≠ 0 and b ≠ 0, the equation can be expressed symmetrically:

x / a + y / b = 1

This form allows immediate geometric visualization of the triangle formed by the line and the two coordinate axes, where the bounded area is simply Area = (1/2)|a · b|.

E. Vector and Parametric Form: r(t) = r₀ + t·v

In linear algebra, physics kinematics, and 3D computer graphics, lines are treated as dynamic trajectories traced by a position vector r(t) as a scalar parameter t varies over all real numbers:

[x(t), y(t)] = [x₀, y₀] + t · [v_x, v_y]

This formulation generalizes seamlessly into 3-dimensional space ℝ³ and n-dimensional spaces ℝⁿ where traditional Cartesian slope-intercept representations fail completely.

Conversion Algorithms Between Linear Representations

Mastering linear algebra requires the ability to seamlessly manipulate and transform equations from any given representation into any other. Below are the formal algorithmic transformations connecting the three most prevalent forms.

Source Form Target Form Mathematical Transformation Procedure
Point-Slope: y - y₁ = m(x - x₁) Slope-Intercept: y = mx + b Distribute the slope m across parentheses: y - y₁ = mx - m·x₁.
Add y₁ to both sides: y = mx + (y₁ - m·x₁).
Identify the y-intercept: b = y₁ - m·x₁.
Slope-Intercept: y = mx + b Standard Form: Ax + By = C Rearrange to group variable terms: -mx + y = b.
Multiply through by the least common denominator (LCD) to eliminate fractional coefficients.
If the leading x-coefficient is negative, multiply through by -1 so that A ≥ 0.
Standard Form: Ax + By = C Slope-Intercept: y = mx + b Isolate the y-term: By = -Ax + C.
Divide every term by B (assuming B ≠ 0): y = (-A/B)x + (C/B).
Identify: Slope m = -A/B and y-Intercept b = C/B.
Standard Form: Ax + By = C Intercept Form: x/a + y/b = 1 Divide the entire equation by the constant C (assuming C ≠ 0): (A/C)x + (B/C)y = 1.
Invert coefficients to standard denominator position: x / (C/A) + y / (C/B) = 1.
Identify: a = C/A and b = C/B.

Trigonometry of Slope: Angle of Inclination & Direction Vectors

The slope m of a line encapsulates its directional orientation and rate of ascent. Geometrically, the slope represents the tangent of the angle of inclination θ, defined as the counterclockwise angle measured from the positive horizontal x-axis to the line (where 0° ≤ θ < 180°):

m = tan(θ) \iff θ = \arctan(m)

Based on the value of m, lines exhibit four distinct qualitative geometric behaviors:

  • Positive Slope (m > 0, 0° < θ < 90°): The line rises from lower-left to upper-right. As x increases, y increases monotonically. The larger the value of m, the steeper the incline.
  • Negative Slope (m < 0, 90° < θ < 180°): The line falls from upper-left to lower-right. As x increases, y decreases monotonically.
  • Zero Slope (m = 0, θ = 0°): The line is perfectly horizontal. There is zero vertical change (rise = 0), and y remains constant across all values of x (y = b).
  • Undefined Slope (m → ∞, θ = 90°): The line is strictly vertical. The horizontal run is zero (Δx = 0), leading to an arithmetic division by zero (x = h).

Parallel and Perpendicular Lines in Affine Space & Vector Orthogonality

Analyzing the relationship between two linear systems is central to analytic geometry, computer graphics raytracing, and vector physics.

A. Parallel Lines (Equidistant & Non-Intersecting)

Two distinct lines L₁ and L₂ in a Euclidean plane are defined as parallel (denoted L₁ ∥ L₂) if they share the exact same directional angle of inclination and never intersect at any point in the affine plane. Algebraically:

m₁ = m₂   and   b₁ ≠ b₂

If both m₁ = m₂ and b₁ = b₂, the equations are not merely parallel; they are coincident, representing the exact same line with infinitely many shared intersection coordinates.

B. Perpendicular Lines (Orthogonal at 90°)

Two lines L₁ and L₂ are perpendicular (denoted L₁ ⊥ L₂) if they intersect at a right angle (90° or π/2 radians). For non-vertical lines with slopes m₁ and m₂, their slopes are negative reciprocals of each other:

m₁ · m₂ = -1 ⇔ m₂ = -1 / m₁

This relation can be derived from the trigonometric tangent difference identity for 90°: tan(θ + 90°) = -cot(θ) = -1 / tan(θ) = -1 / m₁.

Comprehensive Step-by-Step Worked Examples

The five worked examples below demonstrate how to solve standard geometry problems spanning varied initial conditions.

Example 1: Line Through Two Points Two Points Method

Problem: Find the equation in slope-intercept and standard forms for the line passing through P₁(2, -3) and P₂(6, 5).

Step 1: Calculate slope m using the two-point difference quotient:

m = (y₂ - y₁) / (x₂ - x₁) = (5 - (-3)) / (6 - 2) = (5 + 3) / 4 = 8 / 4 = 2

Step 2: Substitute slope m = 2 and point P₁(2, -3) into point-slope form:

y - (-3) = 2(x - 2) ⟹ y + 3 = 2x - 4

Step 3: Isolate y for slope-intercept form:

y = 2x - 7

Step 4: Convert to standard form Ax + By = C:

-2x + y = -7 ⟹ 2x - y = 7

Example 2: Line Through a Point with Given Slope Point-Slope Method

Problem: Determine the equation of the line that has a slope of m = -3/4 and passes through (-4, 2).

Step 1: Set up the point-slope formula with (x₁, y₁) = (-4, 2) and m = -3/4:

y - 2 = -3/4(x - (-4)) ⟹ y - 2 = -3/4(x + 4)

Step 2: Distribute the fractional slope:

y - 2 = -3/4 x - 3

Step 3: Add 2 to both sides to obtain slope-intercept form:

y = -3/4 x - 1

Step 4: Multiply by 4 to obtain standard integer form:

4y = -3x - 4 ⟹ 3x + 4y = -4

Example 3: Perpendicular Line to an Existing Line Orthogonality

Problem: Find the equation of the line passing through (5, 1) that is perpendicular to the line 3x - 6y = 10.

Step 1: Find the slope of the original line by converting to slope-intercept form:

-6y = -3x + 10 ⟹ y = (-3/-6)x + (10/-6) ⟹ y = (1/2)x - 5/3

Original slope: m₁ = 1/2

Step 2: Determine the perpendicular slope m₂ using negative reciprocal:

m₂ = -1 / (1/2) = -2

Step 3: Substitute m₂ = -2 and point (5, 1) into point-slope form:

y - 1 = -2(x - 5) ⟹ y - 1 = -2x + 10

Slope-Intercept Form: y = -2x + 11

Standard Form: 2x + y = 11

Example 4: Perpendicular Bisector of a Segment Geometric Construction

Problem: Determine the equation of the perpendicular bisector of the line segment connecting A(-2, 4) and B(4, -2).

Step 1: Calculate the midpoint M of segment AB:

M = ((x₁ + x₂)/2, (y₁ + y₂)/2) = ((-2 + 4)/2, (4 + (-2))/2) = (2/2, 2/2) = (1, 1)

Step 2: Compute the slope of segment AB:

m_AB = (-2 - 4) / (4 - (-2)) = -6 / 6 = -1

Step 3: Find the perpendicular slope:

m_bisector = -1 / (-1) = +1

Step 4: Write the equation passing through midpoint M(1, 1) with slope m = 1:

y - 1 = 1(x - 1) ⟹ y - 1 = x - 1

Equation: y = x (Standard Form: x - y = 0)

Example 5: Line Given x- and y-Intercepts Two Intercepts Method

Problem: Find the equation of the line with an x-intercept of 5 and a y-intercept of -2.

Step 1: Use the symmetric two-intercept formula (x / a) + (y / b) = 1 with a = 5 and b = -2:

x / 5 + y / (-2) = 1 ⟹ x / 5 - y / 2 = 1

Step 2: Multiply through by the common denominator 10 to clear fractions:

10(x / 5) - 10(y / 2) = 10(1)

2x - 5y = 10 (Standard Form)

Step 3: Solve for y to get slope-intercept form:

-5y = -2x + 10 ⟹ y = (2/5)x - 2

y = 0.4x - 2

Applied Engineering, Physics, and Financial Contexts

Linear models are the bedrock of quantitative modeling across science, industry, and modern computing. When setting up and solving multi-term equations before graphing, use our Equation Simplifier for algebraic reduction.

Physics: Kinematic Motion & Hooke's Law

In uniform kinematic motion, position is a linear function of time: x(t) = v₀·t + x₀, where slope m = v₀ represents velocity and b = x₀ is the initial displacement. Similarly, Hooke's Law models elastic restorative force linearly: F = -k·x, where spring constant k represents the negative slope.

Economics: Cost Functions & Break-Even Analysis

A company's total production cost C(q) is modeled as C(q) = V·q + F, where V is variable cost per unit (slope) and F represents fixed overhead costs (y-intercept). Setting this linear cost equation equal to the linear revenue equation R(q) = P·q determines the critical break-even production volume.

Machine Learning: Linear Regression

In supervised learning, ordinary least squares (OLS) linear regression fits the optimal linear equation ŷ = w₁·x + w₀ to empirical datasets by minimizing the sum of squared residuals. The computed slope w₁ and intercept w₀ form the fundamental parameters of linear predictive models.

Computer Vision & Ray Tracing

Rendering engines calculate light bounces by parameterizing rays as 3D lines r(t) = r₀ + t·d and finding the exact algebraic intersection points with planar polygons, clipping windows, and scene geometry using simultaneous linear matrix transformations.

Common Pitfalls & Diagnostic Error Matrix

When solving linear equations, certain recurring procedural errors lead to incorrect results. The diagnostic table below clarifies how to detect and resolve each mistake.

Frequent Mistake Erroneous Action Correct Mathematical Rule
Inverting Rise and Run in Slope Computing m = (x₂ - x₁) / (y₂ - y₁) instead of Δy / Δx. Slope is strictly vertical change over horizontal change: m = (y₂ - y₁) / (x₂ - x₁). The y-coordinates must always be placed in the numerator.
Sign Errors in Subtraction Given y₁ = -5, writing y - 5 instead of y - (-5) = y + 5. Always enclose negative coordinates in parentheses when substituting into point-slope form: y - (-5) = y + 5.
Assuming Perpendicular Slope is Just -m Taking the negative without inverting (e.g., m₁ = 3 → m₂ = -3). Perpendicular slopes are negative reciprocals: both negate AND take the reciprocal (e.g., m₁ = 3 → m₂ = -1/3).
Misidentifying Standard Form Coefficients Given 4x - 2y = 8, stating slope m = 4/2 = 2. In Ax + By = C, the slope is m = -A/B. Here, m = -(4)/(-2) = 2. Notice the explicit minus sign in the formula.
Fact-Checked & Verified • Computational Accuracy Standards
Updated September 2026 • Editorial Policy
Authored By
Sanjay Samanta

Lead Developer & Founder of Basic Math Tools. Specializes in browser-native computational algorithms and applied mathematics.

Reviewed & Verified By
Academic Review Board

Mathematics & curriculum specialists. Audited against standard algebraic and arithmetic principles.

Found an error or have an improvement suggestion? Report a calculation issue

Frequently Asked Questions

How do you find the equation of a line with two points?
To find the equation of a line passing through two points (x₁, y₁) and (x₂, y₂), first compute the slope using m = (y₂ - y₁) / (x₂ - x₁). Next, substitute the calculated slope m and one of the points into the point-slope formula y - y₁ = m(x - x₁). Finally, solve for y to express the equation in slope-intercept form y = mx + b.
What is the difference between slope-intercept form and standard form?
Slope-intercept form is written as y = mx + b, which isolates y and explicitly displays the slope m and the vertical intercept (0, b). Standard form is expressed as Ax + By = C, where A, B, and C are typically integers with A ≥ 0. Standard form is preferred in matrix algebra, linear programming, and when representing vertical lines (where B = 0).
What is the slope of a vertical line versus a horizontal line?
A horizontal line has zero vertical rise (Δy = 0), producing a slope of exactly m = 0 with equation y = k. A vertical line has zero horizontal run (Δx = 0), which causes a division-by-zero condition in m = Δy / Δx. Therefore, the slope of a vertical line is undefined, and its equation is written as x = h.
How do you determine if two linear equations are parallel or perpendicular?
Two non-vertical lines are parallel if and only if their slopes are strictly equal (m₁ = m₂) while their y-intercepts differ (b₁ ≠ b₂). Two lines are perpendicular if and only if their slopes are negative reciprocals of one another, satisfying the identity m₁ · m₂ = -1 (or m₂ = -1 / m₁).
What is the intercept form of a line equation?
The intercept form (or symmetric two-intercept form) is written as (x / a) + (y / b) = 1, where a represents the non-zero x-intercept (a, 0) and b represents the non-zero y-intercept (0, b). It cannot be used if the line passes through the origin (0, 0) or is strictly parallel to either coordinate axis.
How do you calculate the perpendicular distance from an external point to a line?
Given a linear equation in standard form Ax + By + C = 0 and an arbitrary coordinate point P(x₀, y₀), the shortest Euclidean distance d is given by the formula d = |A·x₀ + B·y₀ + C| / √(A² + B²).