Math Calculator

Distance Formula Calculator

Find exact straight-line lengths.

Distance inputs

Measure the direct segment exactly.

Signed decimal, scientific e notation or integer fraction.

Coordinate and display options

Inactive sources are retained locally and excluded from calculation and sharing.

Signed decimal, scientific e notation or integer fraction.

Signed decimal, scientific e notation or integer fraction.

Signed decimal, scientific e notation or integer fraction.

Changing this unit reinterprets all entered coordinates; it does not rescale their numbers.

Converts the result using an exact length multiplier. Squared distances use its square.

Load a worked example

Examples replace coordinates and dimensions while retaining the selected units and display options.

Exact coordinates and radicals remain unchanged. Very large or tiny nonzero values use at least six significant scientific digits.

Sources support sixty significant decimal digits or sixty digits per integer fraction, one hundred eighty characters, and scientific input exponents from negative one hundred through positive one hundred. Exact numerators and denominators are bounded to eighteen hundred digits. Root rounding uses exact integer comparisons and half-away-from-zero ties. Large radicals retain a verified exact expression without promising complete square-free factorization. Diagram positions are numerical approximations.

Exact straight-line distance

d=5 cmd=5\,\mathrm{cm}

Rounded distance view

d=5 cmd=5\,\mathrm{cm}

Coordinate subtraction and squaring stay exact. The nonnegative radical squares back to the output squared distance with zero residual. The decimal view does not replace that exact answer.

Distance in the coordinate unit

dcoord=5 cmd_{\mathrm{coord}}=5\,\mathrm{cm}

The coordinate-unit length and chosen output length describe the same physical segment when physical units are selected.

This is straight-line Euclidean distance in Cartesian coordinates with compatible axis units, not route length, geographic distance or a signed displacement. Changing the coordinate unit reinterprets the entered numbers; changing the output unit converts the result.

Segment and right-triangle diagram

Straight-line distance and coordinate displacement legsThe square planar view uses equal coordinate units and is centered on the exact segment center. Distinct endpoints appear as a square and a diamond, with dashed perpendicular coordinate legs. A right-angle marker appears only when both legs are nonzero. Coincident points share one marked location. Axes outside the local window are omitted; exact coordinates and checks remain in the table.FirstSecondHorizontal coordinateVertical coordinate

Square: first endpoint. Diamond: second endpoint. Solid line: direct distance. Dashed legs: coordinate displacements. An axis-aligned segment has a zero leg and no right-angle marker.

Viewport center: (52,4)\left(\frac{5}{2},4\right).
Equal coordinate units per grid step: 23 cm\frac{2}{3}\,\mathrm{cm}.

Axes outside this local window are omitted. Centering uses exact coordinate differences before numerical plotting; components below screen resolution can appear aligned. The exact coordinates determine the answer.

Distance calculation step by step

  1. Record the source points

    A=(1,2),B=(4,6)A=\left(1,2\right),\quad B=\left(4,6\right)

    Use one Cartesian reference frame and one common coordinate unit. Every selected coordinate axis contributes; unit choices label these source numbers rather than rescaling them.

  2. Subtract the horizontal coordinates

    Δx=Bx−Ax=(4)−(1)=3\Delta x=B_x-A_x=\left(4\right)-\left(1\right)=3

    Subtract in the same endpoint order on every active axis. A signed component is a displacement, not the nonnegative straight-line length.

  3. Subtract the vertical coordinates

    Δy=By−Ay=(6)−(2)=4\Delta y=B_y-A_y=\left(6\right)-\left(2\right)=4

    Subtract in the same endpoint order on every active axis. A signed component is a displacement, not the nonnegative straight-line length.

  4. Square and add the active displacements

    dcoord2=(3)2+(4)2=25 cm2d_{\mathrm{coord}}^2=\left(3\right)^2+\left(4\right)^2=25\,\mathrm{cm}^{2}

    Each squared contribution is nonnegative. In one dimension this reduces to an absolute coordinate difference; in three dimensions the depth contribution is included.

  5. Take the nonnegative square root

    dcoord=25=5 cmd_{\mathrm{coord}}=\sqrt{25}=5\,\mathrm{cm}

    The exact radical defines the length. Common small square factors and perfect-square remainders are extracted with bounded work; exceptionally large radicals are not claimed to be completely square-free.

  6. Convert the length and verify the radical

    d=1(5)=5 cm,d2=25 cm2d=1\left(5\right)=5\,\mathrm{cm},\quad d^2=25\,\mathrm{cm}^{2}

    The length multiplier acts once on distance, and its square acts on squared distance. An exact algebraic certificate squares the resulting radical and must reproduce the output squared distance without rounding.

Inputs saved with this calculation

Coordinate dimensions
2 Cartesian dimensions
Active source points
First endpoint: horizontal 1, vertical 2; Second endpoint: horizontal 4, vertical 6
Common coordinate unit
Centimeters
Output distance unit
Centimeters
Rounded decimal places
6
Show diagram
true
Show conversions
true

All result details

The full record preserves original coordinates, signed displacements, individual squared contributions, coordinate and output squared distances, the length multiplier and exact radical residual. A squared length and a length have different dimensions; their unit conversion powers differ.

Distance calculation details
QuantityExact valueRounded decimalInterpretation
First endpoint horizontal coordinate1 cm1\,\mathrm{cm}1 cm1\,\mathrm{cm}Exact source coordinate in the common coordinate unit.
First endpoint vertical coordinate2 cm2\,\mathrm{cm}2 cm2\,\mathrm{cm}Exact source coordinate in the common coordinate unit.
Second endpoint horizontal coordinate4 cm4\,\mathrm{cm}4 cm4\,\mathrm{cm}Exact source coordinate in the common coordinate unit.
Second endpoint vertical coordinate6 cm6\,\mathrm{cm}6 cm6\,\mathrm{cm}Exact source coordinate in the common coordinate unit.
Signed horizontal displacement3 cm3\,\mathrm{cm}3 cm3\,\mathrm{cm}Second endpoint coordinate minus first endpoint coordinate; endpoint reversal changes the sign.
Signed vertical displacement4 cm4\,\mathrm{cm}4 cm4\,\mathrm{cm}Second endpoint coordinate minus first endpoint coordinate; endpoint reversal changes the sign.
Horizontal squared contribution9 cm29\,\mathrm{cm}^{2}9 cm29\,\mathrm{cm}^{2}Square of the matching coordinate displacement; never negative.
Vertical squared contribution16 cm216\,\mathrm{cm}^{2}16 cm216\,\mathrm{cm}^{2}Square of the matching coordinate displacement; never negative.
Coordinate squared distance25 cm225\,\mathrm{cm}^{2}25 cm225\,\mathrm{cm}^{2}Sum of every active squared coordinate displacement.
Length conversion multiplier1111Exact output length units per coordinate length unit; apply once to length and twice to squared length.
Output squared distance25 cm225\,\mathrm{cm}^{2}25 cm225\,\mathrm{cm}^{2}Coordinate squared distance multiplied by the square of the length conversion multiplier.
Exact radical verification0 cm20\,\mathrm{cm}^{2}0 cm20\,\mathrm{cm}^{2}Square of the exact radical minus output squared distance; exactly zero.

Distance in all physical units

All seventeen supported physical conversions use exact ratios. Feet and miles are international definitions; points and picas use the typographic inch definitions stated in the selector. Hidden conversions remain in CSV.

Exact distance unit conversions
UnitExact lengthRounded length
Nanometers5×107 nm5\times10^{7}\,\mathrm{nm}50000000 nm50000000\,\mathrm{nm}
Micrometers50000 μm50000\,\mathrm{\mu m}50000 μm50000\,\mathrm{\mu m}
Millimeters50 mm50\,\mathrm{mm}50 mm50\,\mathrm{mm}
Centimeters5 cm5\,\mathrm{cm}5 cm5\,\mathrm{cm}
Decimeters12 dm\frac{1}{2}\,\mathrm{dm}0.5 dm0.5\,\mathrm{dm}
Meters120 m\frac{1}{20}\,\mathrm{m}0.05 m0.05\,\mathrm{m}
Decameters1200 dam\frac{1}{200}\,\mathrm{dam}0.005 dam0.005\,\mathrm{dam}
Hectometers12000 hm\frac{1}{2000}\,\mathrm{hm}0.0005 hm0.0005\,\mathrm{hm}
Kilometers120000 km\frac{1}{20000}\,\mathrm{km}0.00005 km0.00005\,\mathrm{km}
Mils (one thousandth inch)250000127 mil\frac{250000}{127}\,\mathrm{mil}≈  1968.503937 mil\approx\;1968.503937\,\mathrm{mil}
Inches250127 in\frac{250}{127}\,\mathrm{in}≈  1.968504 in\approx\;1.968504\,\mathrm{in}
International feet125762 ft\frac{125}{762}\,\mathrm{ft}≈  0.164042 ft\approx\;0.164042\,\mathrm{ft}
International yards1252286 yd\frac{125}{2286}\,\mathrm{yd}≈  0.054681 yd\approx\;0.054681\,\mathrm{yd}
International miles25804672 mi\frac{25}{804672}\,\mathrm{mi}≈  0.000031 mi\approx\;0.000031\,\mathrm{mi}
International nautical miles137040 nmi\frac{1}{37040}\,\mathrm{nmi}≈  0.000027 nmi\approx\;0.000027\,\mathrm{nmi}
Typographic points (one seventy-second inch)18000127 pt\frac{18000}{127}\,\mathrm{pt}≈  141.732283 pt\approx\;141.732283\,\mathrm{pt}
Typographic picas (one sixth inch)1500127 pc\frac{1500}{127}\,\mathrm{pc}≈  11.811024 pc\approx\;11.811024\,\mathrm{pc}
What Can You Create?

Measure direct segments and understand every squared contribution

Exact lengths between Cartesian points

Enter endpoints on a number line, in a plane or in space. The calculator preserves signed finite decimal and integer-fraction sources while subtracting corresponding coordinates exactly. It records every displacement and squared contribution before constructing the nonnegative radical length. This makes the result useful when nearby large coordinates would otherwise lose their separation through an early conversion to floating-point numbers.

Physical conversions with the right dimensions

Choose a common physical coordinate unit and a separate output unit, or explicitly use unitless coordinates. The length and squared-length records use different conversion powers, with exact rational factors for all seventeen physical units. Feet and miles follow international definitions, while typographic points and picas use their stated inch relationships. Hidden conversion rows remain available in the complete CSV export.

Inspectable geometric and algebraic evidence

A planar diagram separates the finite direct segment from its perpendicular coordinate legs, uses equal units and distinguishes both endpoints with different marker shapes. Exact subtraction and squaring steps explain the displayed length. A radical certificate must reproduce the output squared distance exactly. Coincident and axis-aligned cases have truthful degenerate diagrams, and space calculations retain every active coordinate without pretending to be planar.

Formulas and worked examples

Distance formulas and step-by-step examples

Build a direct planar length from perpendicular changes

For A=(1,2)A=(1,2) and B=(4,6)B=(4,6), the displacements are Δx=3\Delta x=3 and Δy=4\Delta y=4. Square both changes and add their nonnegative contributions. The coordinate squared distance is 2525, while the nonnegative distance is 55. These are different quantities with different physical dimensions when a length unit is assigned.

d=(4−1)2+(6−2)2=32+42=25=5d=\sqrt{(4-1)^2+(6-2)^2}=\sqrt{3^2+4^2}=\sqrt{25}=5

Retain fractions before taking the root

With A=(1/3,−1/2)A=(1/3,-1/2) and B=(5/6,3/4)B=(5/6,3/4), the exact displacements are 1/21/2 and 5/45/4. Their squared sum is 29/1629/16, giving a distance of 29/4\sqrt{29}/4. The decimal view is useful for reading, but rounding either coordinate first would change the defined problem and the squared-distance verification.

d2=(12)2+(54)2=2916,d=294d^2=\left(\frac12\right)^2+\left(\frac54\right)^2=\frac{29}{16},\qquad d=\frac{\sqrt{29}}4

Add the depth contribution in space

For A=(1,−2,3)A=(1,-2,3) and B=(7,4,−1)B=(7,4,-1), the displacement is (6,6,−4)(6,6,-4). Every active coordinate must contribute. The squared distance is 8888 and the exact length can be written 2222\sqrt{22}. A planar picture would omit depth and therefore describe a different segment length.

d=62+62+(−4)2=88=222d=\sqrt{6^2+6^2+(-4)^2}=\sqrt{88}=2\sqrt{22}

Convert squared lengths with the squared multiplier

The default segment has length 5 cm5\,\mathrm{cm}. Converting to meters uses a length multiplier of 1/1001/100. The squared distance is therefore multiplied by 1/100001/10000, not 1/1001/100. Keeping both records makes the dimensional change inspectable, and converting back recovers the original exact length.

d=5 cm=120 m,d2=25 cm2=1400 m2d=5\,\mathrm{cm}=\frac1{20}\,\mathrm{m},\qquad d^2=25\,\mathrm{cm}^2=\frac1{400}\,\mathrm{m}^2

Handle number-line and zero-length cases consistently

On a number line, A=−3/2A=-3/2 and B=5/2B=5/2 have distance 44. Reversing them changes the signed difference but preserves its absolute value. Identical endpoints have distance 00 in every supported dimension. They need no special invented direction or nonzero triangle; the single shared diagram marker explains the geometry directly.

d=∣52−(−32)∣=4,d(A,A)=0d=\left|\frac52-\left(-\frac32\right)\right|=4,\qquad d(A,A)=0
Why Users Love This Tool

Why use an exact coordinate-distance workflow?

Preserve the defined problem

  • Finite decimal and integer-fraction sources retain their exact rational meaning through every active coordinate subtraction.
  • Nearby large coordinates preserve small exact separations; rounded endpoint views do not replace the stated sources.
  • Invalid, missing and unsupported inputs remain explicit errors instead of being silently turned into zero.
  • The table and CSV retain the original coordinates, units, component differences and complete squared-distance checks.

Separate length from its presentation

  • The nonnegative radical is verified against the output squared distance with an exact algebraic certificate.
  • Integer square-root comparisons control decimal rounding, including exact ties; scientific formatting preserves tiny nonzero lengths.
  • Physical lengths use exact ratios, while squared lengths use the square of the selected length conversion factor.
  • The equal-unit planar diagram is a numerical screen illustration; exact table values remain authoritative at tiny scales.
Perfect For

Useful for coordinate geometry, teaching and model checks

Learners applying the Pythagorean theorem

Connect endpoint coordinates to a right triangle through the signed horizontal and vertical differences. Squaring removes component signs without hiding the original direction. Compare a familiar integer-length example with an irrational or fractional example, then extend the same sum of squares to space. The step-by-step record explains why adding coordinate differences directly does not generally produce a straight-line length.

Teachers preparing checked worked solutions

Use the exact result, contribution table and finite diagram to build a reproducible solution. Endpoint swapping demonstrates distance symmetry while reversing component signs. Coincident and axis-aligned examples expose valid boundary cases. Share the active sources for another reader, or print the mathematical working with its input record. CSV keeps all digits when unusually large numerical expressions exceed a readable printed line.

Design and technical coordinate comparisons

Check direct separations inside a Cartesian model whose axes use compatible physical units. Compare the source-unit length with a chosen output unit and inspect the squared conversion power. This is a numerical model check rather than a measurement-validation service. Geographic positions, road routes, curved surfaces, historical survey definitions and anisotropic coordinate scales require their own transformations or distance models before this Euclidean calculation applies.

How It Works

How it works in three quick steps.

1

Choose dimensions and enter both endpoints

Select a number line, plane or space. Enter matching coordinates as signed finite decimals, scientific notation or integer fractions. Use one Cartesian reference frame and one common coordinate unit. Choose unitless when no physical coordinate scale is specified. Inactive coordinate fields retain their local source strings but do not contribute to the lower-dimensional calculation or its shared link.

2

Inspect exact displacements and the distance

Read each signed coordinate difference and its nonnegative squared contribution. Their exact sum is the coordinate squared distance. The calculator takes its nonnegative square root, preserves a certified exact radical and separately rounds a decimal view. An output-unit selection converts the length with an exact ratio; its square converts squared distance. The planar diagram distinguishes the direct segment from perpendicular coordinate legs.

3

Review the working and retain the complete record

Follow the subtraction, squaring, summation, square-root and unit-conversion steps. The radical verification must be exactly zero. Swap endpoints to check length symmetry while observing the displacement sign reversal. Copy the complete summary, share the active sources, download every physical conversion as CSV or print the typeset calculation. Choose Save as PDF in the browser for a portable record of the inputs and working.

Download & Print

Keep the source coordinates, unit choices and complete working

Download a complete exact CSV

The CSV contains active source coordinates, signed differences, squared contributions, both squared-distance records, the exact radical certificate and all seventeen physical conversions when physical units are selected. Hiding the visual conversion table does not remove those values from the export. Full source strings and method notes retain the chosen coordinate scale and help explain the result when it is reused outside this page.

Print the calculation or save a PDF

Print removes editing controls and keeps the answer, coordinate-unit length, available diagram, ordered mathematical working, input record and complete result tables. Choose a suitable page orientation and Save as PDF through the browser print dialog. Long tables can continue with repeated headers. Exceptionally long numerical expressions use an explicit compact notice pointing to CSV, rather than silently clipping exact digits at a page edge.

Share or copy a reproducible problem

Share calculation copies an editable URL fragment containing active coordinates, dimension count, coordinate and output units, precision and display choices. Hidden coordinate axes are excluded, and malformed, duplicate or extra imported fields are rejected. Copy summary retains plain-text exact radicals and every conversion without raw typesetting commands. Local dimension switches retain inactive source fields so you can revisit the previous editor state without reconstructing its coordinates.

FAQ

Frequently Asked Questions

How does the distance formula work?
In the plane, subtract the matching coordinates, square both differences, add them and take the nonnegative square root: d=(x2−x1)2+(y2−y1)2d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}. The coordinate changes form perpendicular legs of a right triangle, so the Pythagorean theorem supplies the direct segment length. The calculator retains exact source arithmetic and shows each contribution separately. Negative differences are valid; their squares cannot make the final length negative.
Can I calculate distance on a number line or in space?
Yes. One-dimensional distance is d=∣x2−x1∣d=|x_2-x_1|, while three-dimensional distance adds the squared depth difference before taking the square root. Select the matching dimension count and provide every active coordinate. Inactive fields retain their local values without contaminating a lower-dimensional calculation. The diagram is planar only; selecting three dimensions does not silently discard depth or present a projected planar length as the actual space distance.
Can coordinates be fractions, negative numbers or scientific notation?
Yes. Active coordinate fields accept signed finite decimals, scientific e notation and signed integer fractions with nonzero denominators. Negative denominators are normalized. Sources support sixty significant decimal digits or sixty digits per integer fraction, one hundred eighty characters and input exponents from negative one hundred through positive one hundred. Commas, arbitrary arithmetic expressions and recurring-decimal syntax are unsupported. Use a fraction for an exact repeating rational value instead of entering an already rounded decimal.
What is the difference between distance and displacement?
A coordinate displacement is signed: Δx=x2−x1\Delta x=x_2-x_1. Reversing endpoint order reverses each displacement component. Euclidean distance is the nonnegative magnitude of the full displacement vector, so reversing the endpoints preserves the length and squared distance. Adding absolute coordinate changes instead would measure an axis-aligned route in the plane, which is generally longer than the direct segment. The solid line in the diagram identifies the straight-line quantity calculated here.
How are physical units and squared units converted?
All active coordinates share the selected coordinate unit. Changing that selector reinterprets their numbers; it does not rescale the source fields. Changing the output unit converts the calculated length. If the exact length multiplier is kk, then dout=kdcoordd_{\mathrm{out}}=k d_{\mathrm{coord}} and dout2=k2dcoord2d_{\mathrm{out}}^2=k^2d_{\mathrm{coord}}^2. The table keeps these quantities separate, preventing the common mistake of applying a length factor only once to an area-dimensional squared distance.
Which feet, miles, points and picas are used?
Feet, yards and miles use their international definitions, not historical U.S. survey units. An international foot is exactly 0.3048 m0.3048\,\mathrm{m} and an inch is exactly 0.0254 m0.0254\,\mathrm{m}. International nautical miles use exactly 1852 m1852\,\mathrm{m}. Typographic points and picas are defined here as one seventy-second and one sixth of an inch, respectively. The calculator stores these relationships as exact rational factors; it does not reconstruct them from rounded binary decimal constants.
Does the exact radical always simplify completely?
The exact radical is always retained with an algebraic certificate: squaring its coefficient and multiplying by its radicand reproduces the output squared distance exactly. Common small square factors and perfect-square remainders are extracted, and rational lengths are displayed as exact fractions when available. Factoring arbitrary very large integers completely could make an interactive calculator unresponsive, so full square-free reduction is not promised for exceptionally large radicals. The preserved expression remains exact even when further symbolic simplification is possible.
What happens with identical points or an axis-aligned segment?
Identical endpoints produce exactly zero distance, zero squared contributions and one shared diagram marker. A horizontal or vertical segment has one zero coordinate leg; its length equals the absolute value of the nonzero displacement. The tool keeps these valid cases rather than treating them as errors. The diagram omits the right-angle marker when a leg is zero, because a degenerate triangle should not be drawn as though it had two nonzero perpendicular sides.
How accurate are the decimal result and diagram?
Subtraction, squaring, unit ratios and radical verification use exact rational arithmetic within the stated bounds. Decimal length rounding uses integer square-root comparisons, including exact half-away-from-zero tie handling; it does not square an overflowing floating-point coordinate difference. Select zero through twelve decimal places. Very large or sub-resolution nonzero values use scientific notation with at least six significant digits. Diagram positions are numerical screen approximations, so tiny directional components can appear aligned even when the exact table preserves their differences.
Is this suitable for geographic coordinates, sharing and printing?
Use this calculator for Cartesian straight-line distance with compatible axis units. Latitude and longitude, road routes, curved surfaces and unequal physical axis scales require different models. Share calculation preserves active coordinates, dimensions, units and display settings in an editable fragment while rejecting malformed or inactive imported fields. Copy and CSV retain the complete calculation, including hidden physical conversions. Print removes controls and retains working; save it as PDF through the browser. Exceptionally long numerical expressions use a clear notice pointing to complete CSV digits.
About This Tool

About this exact Cartesian distance formula calculator

This distance formula calculator measures the nonnegative straight-line separation between two points in a common Cartesian reference frame. Each selected coordinate contributes its signed endpoint difference, then its squared difference. The sum of those contributions defines the squared length, and its nonnegative square root defines the distance. A number-line calculation uses one coordinate, the plane uses two, and space uses three. The tool keeps those dimensional choices explicit rather than treating a space example as a planar projection.

The implementation separates mathematical meaning from display. Finite decimal and integer-fraction sources retain exact rational values through subtraction, squaring and unit conversion. A verified radical certificate establishes the exact output length, while a separate integer square-root comparison determines rounded decimal views. Bounded radical reduction extracts common square factors without promising complete factorization of arbitrary large integers. The diagram illustrates a finite planar segment and its perpendicular displacement legs with equal coordinate units, but exact table values remain authoritative when screen resolution cannot distinguish tiny components.

Physical-unit handling is part of the defined problem. Changing the common coordinate-unit selector relabels the entered numbers; choosing a different output unit converts the resulting length. Squared lengths use the square of that conversion factor, and unitless coordinates are never assigned invented physical conversions. International customary definitions and the stated typographic inch conventions are preserved as exact ratios. This tool does not transform geographic coordinates, validate a survey or find route lengths. Sharing, copying, CSV and print carry the source coordinates, dimensions, units and methodology alongside the result so another reader can evaluate the same calculation.

Editorial Transparency

Who maintains this page

Ownership and review

Written and maintained by the Toolarithm editorial team. No review date is shown without a maintained editorial record. No independent professional review is claimed.

Methodology

Equations are checked by substituting worked examples into the stated relationship and comparing the result with the interactive implementation.

Read the editorial methodology

Dates and sources

Review dates change only after a substantive method or content check.

Keep building

Explore more calculators

Calculators hub