Length of a Line Segment Calculator
Find the length of a line segment between any two points (x₁, y₁) and (x₂, y₂) on the coordinate plane. Also reports the midpoint and plots the segment.
Straight-line distance from P₁ to P₂
- 1
Δx (horizontal change)
3 − 0 = 3 - 2
Δy (vertical change)
4 − 0 = 4 - 3
Δx² + Δy²
3² + 4² = 25 - 4
d = √(Δx² + Δy²)
√25 = 5Square root of the sum of squared differences — the Pythagorean theorem on coordinate changes.
How does this calculator work?
Segment length from (x₁,y₁) to (x₂,y₂) is d = √((x₂−x₁)²+(y₂−y₁)²) — the Pythagorean theorem on coordinate differences. The midpoint is M = ((x₁+x₂)/2, (y₁+y₂)/2). Enter all four coordinates for the instant result and a coordinate plot.
Formula
How this is calculated
The distance formula is the Pythagorean theorem applied to coordinate differences. The horizontal change Δx = x₂ − x₁ and vertical change Δy = y₂ − y₁ form the two legs of a right triangle; the line segment is the hypotenuse. Squaring and summing the legs, then taking the square root, gives d = √(Δx² + Δy²).
The midpoint is the point equidistant from both ends: M = ((x₁+x₂)/2, (y₁+y₂)/2). The plot renders both endpoints connected by the segment and marks the midpoint M so the geometry is immediately visible.
Assumptions: coordinates share the same unit of measurement and the plane is flat (Euclidean). For distance on Earth's curved surface — e.g. between GPS coordinates — the Haversine formula is required instead.
Frequently asked questions
No. Distance is symmetric: swapping P₁ and P₂ changes the signs of Δx and Δy but not their squares, so the result is identical.
Δx = Δy = 0, so d = 0. The midpoint equals either endpoint.
Yes. All real-number coordinates work, including negative values for points in the second, third, or fourth quadrant.
Also known as
TG we-Calculate Editorial Team. (2026). Length of a Line Segment Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/length-of-a-line-segment-calculator
TG we-Calculate Editorial Team. "Length of a Line Segment Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/length-of-a-line-segment-calculator.
TG we-Calculate Editorial Team, "Length of a Line Segment Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/length-of-a-line-segment-calculator
@misc{wecalculate_length_of_a_line_segment_calculator, title = {Length of a Line Segment Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/length-of-a-line-segment-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
