Bookmarks    
nPr and nCr    
Random Number    
SD Calculator    
Sample Size    
Percent Error    
Density    
Molarity    
Molar Mass    
Ohm's Law    
Watts to Amps    
Voltage Drop    
Long Division    
Mixed Numbers    
Rounding    
Nth Root    
Exponents    
Half-Life    
Polar Form    
De Moivre    
3D Distance    
Point to Line    
Cross Product    
Determinant    
Sin Cos Tan    
Triangle Area    
Scale Factor    
Sector Area    
Ellipse Area    
Cube Volume    
Box Volume    
Sphere Volume    
Cone Volume    
Pipe Volume    
Time Duration    
Time Card    
Present Value    
Future Value    
Churn Rate    
A/B Test Calc    
SEO Traffic    
Ideal Weight    
Fat Intake    
Child Height    
Golf Handicap    
Heat Index    
Wind Chill    
Dew Point    
Download Time    
kWh to Cost    
AC Size (BTU)    
Heating Costs    
LED Savings    
Trip Gas Cost    
Tire Size    
Solar Output    
Solar Payback    
Battery Size    
Wall Area    
Gravel Needed    
Mortar Mix    
Slope Grade    
Curtain Size    
Soil Needed    
Sod Needed    
Ramp Length    
Blind Size    
Drain Slope    
Board Feet    
Heat Loss    
Furniture Fit    
Moving Boxes    
Plywood Cuts    
Shelf Sag    
   Add
Probability and random number calculators
Independent Events
Independent Events
Two Events Solver
Two Events Solver
Repeated Trials
Repeated Trials
Bayes' Theorem
Bayes' Theorem
Expected Value
Expected Value
Binomial Distribution
Binomial Distribution
nPr and nCr
nPr and nCr
Circular Permutation
Circular Permutation
With Repetition
With Repetition
Random Number
Random Number
Averages and statistics calculators
Average Calculator
Average Calculator
Mean Median Mode
Mean Median Mode
SD Calculator
SD Calculator
Quartiles & IQR
Quartiles & IQR
Frequency Table
Frequency Table
Correlation (r)
Correlation (r)
Normal Probability
Normal Probability
Z-Score Calculator
Z-Score Calculator
Confidence Interval
Confidence Interval
Sample Size
Sample Size
Mark & Recapture
Mark & Recapture
P-Value Calculator
P-Value Calculator
Percentage and ratio calculators
Percentage Calc
Percentage Calc
Percent Change
Percent Change
Percent Difference
Percent Difference
Percent Error
Percent Error
Ratio Calculator
Ratio Calculator
Discount Calculator
Discount Calculator
Sales Tax Calculator
Sales Tax Calculator
Margin Calculator
Margin Calculator
Speed calculators
Speed Calculator
Speed Calculator
Density and concentration calculators
Density
Density
Molarity
Molarity
Molar Mass
Molar Mass
Physics and electricity calculators
Ohm's Law
Ohm's Law
Watts to Amps
Watts to Amps
Resistor Colors
Resistor Colors
Voltage Drop
Voltage Drop
Unit conversion calculators
Weight Converter
Weight Converter
Shoe Size Converter
Shoe Size Converter
Integer and signed number calculators
Long Division
Long Division
LCM Calculator
LCM Calculator
GCF Calculator
GCF Calculator
Integer Calculator
Integer Calculator
Prime Factorization
Prime Factorization
Diophantine Solver
Diophantine Solver
Modulo Calculator
Modulo Calculator
Factor Calculator
Factor Calculator
Roman Numerals
Roman Numerals
Fraction, decimal and rounding calculators
Fraction Calculator
Fraction Calculator
Mixed Numbers
Mixed Numbers
Simplify Fractions
Simplify Fractions
Fraction to Decimal
Fraction to Decimal
Decimal to Fraction
Decimal to Fraction
Rounding
Rounding
Equation and inequality calculators
Linear Equation
Linear Equation
Linear Systems
Linear Systems
Quadratic Formula
Quadratic Formula
Absolute Value
Absolute Value
Quadratic Inequality
Quadratic Inequality
Polynomial calculators
Binomial Theorem
Binomial Theorem
Square root and nth root calculators
Simplify Radicals
Simplify Radicals
Nth Root
Nth Root
Exponent and logarithm calculators
Exponents
Exponents
Log Calculator
Log Calculator
Number of Digits
Number of Digits
Scientific Notation
Scientific Notation
Sci. Notation Math
Sci. Notation Math
Half-Life
Half-Life
Complex number calculators
Complex Numbers
Complex Numbers
Polar Form
Polar Form
De Moivre
De Moivre
Function and graph calculators
Slope Calculator
Slope Calculator
Linear Function
Linear Function
Direct & Inverse Variation
Direct & Inverse Variation
y = ax² Calculator
y = ax² Calculator
Distance Formula
Distance Formula
3D Distance
3D Distance
Section Formula
Section Formula
Point to Line
Point to Line
Lat/Long Distance
Lat/Long Distance
Complete the Square
Complete the Square
Circle Equation
Circle Equation
Conic Sections
Conic Sections
Polar Coordinates
Polar Coordinates
Sequence calculators
Arithmetic Sequence
Arithmetic Sequence
Geometric Sequence
Geometric Sequence
Fibonacci Sequence
Fibonacci Sequence
Recurrence Relation
Recurrence Relation
Vector calculators
Vector Calculator
Vector Calculator
Cross Product
Cross Product
Matrix calculators
Matrix Calculator
Matrix Calculator
Determinant
Determinant
Inverse Matrix
Inverse Matrix
Plane geometry calculators
Sin Cos Tan
Sin Cos Tan
Degrees ⇔ Radians
Degrees ⇔ Radians
a sin θ + b cos θ
a sin θ + b cos θ
Triangle Solver
Triangle Solver
Triangle Area
Triangle Area
Right Triangle
Right Triangle
Pythagorean Theorem
Pythagorean Theorem
Polygon Angles
Polygon Angles
Scale Factor
Scale Factor
Parallel Lines
Parallel Lines
Rectangle Area
Rectangle Area
Parallelogram Area
Parallelogram Area
Trapezoid Area
Trapezoid Area
Circle Calculator
Circle Calculator
Sector Area
Sector Area
Inscribed Angle
Inscribed Angle
Ellipse Area
Ellipse Area
Solid geometry calculators
Cube Volume
Cube Volume
Cube Surface Area
Cube Surface Area
Box Volume
Box Volume
Box Surface Area
Box Surface Area
Cylinder Volume
Cylinder Volume
Cylinder Surface
Cylinder Surface
Sphere Volume
Sphere Volume
Sphere Surface
Sphere Surface
Spherical Cap Volume
Spherical Cap Volume
Cap Surface Area
Cap Surface Area
Ellipsoid Volume
Ellipsoid Volume
Ellipsoid Surface
Ellipsoid Surface
Pyramid Volume
Pyramid Volume
Pyramid Surface
Pyramid Surface
Cone Volume
Cone Volume
Cone Surface Area
Cone Surface Area
Frustum Volume
Frustum Volume
Frustum Surface Area
Frustum Surface Area
Pipe Volume
Pipe Volume
Capsule Volume
Capsule Volume
Capsule Surface Area
Capsule Surface Area
Date and time calculators
Age Calculator
Age Calculator
Days Between Dates
Days Between Dates
Date Calculator
Date Calculator
Hours From Now
Hours From Now
Day of the Week
Day of the Week
Time Calculator
Time Calculator
Time Zone Converter
Time Zone Converter
Hours Calculator
Hours Calculator
Time Duration
Time Duration
Time Card
Time Card
Finance and economics calculators
Compound Interest
Compound Interest
Simple Interest
Simple Interest
Interest Calculator
Interest Calculator
TVM Calculator
TVM Calculator
Present Value
Present Value
Future Value
Future Value
ROI Calculator
ROI Calculator
IRR Calculator
IRR Calculator
Payback Period
Payback Period
Average Return
Average Return
GDP Calculator
GDP Calculator
Web marketing and ad metric calculators
CTR Calculator
CTR Calculator
Conversion Rate
Conversion Rate
CPC, CPM & CPA
CPC, CPM & CPA
ROAS Calculator
ROAS Calculator
Break-Even CPA
Break-Even CPA
LTV Calculator
LTV Calculator
CAC Calculator
CAC Calculator
Churn Rate
Churn Rate
A/B Test Calc
A/B Test Calc
A/B Sample Size
A/B Sample Size
SEO Traffic
SEO Traffic
Break-Even Point
Break-Even Point
Markup vs. Margin
Markup vs. Margin
CAGR Calculator
CAGR Calculator
Health and fitness calculators
BMI Calculator
BMI Calculator
Sleep Calculator
Sleep Calculator
Calorie Calculator
Calorie Calculator
BMR Calculator
BMR Calculator
TDEE Calculator
TDEE Calculator
Ideal Weight
Ideal Weight
Body Fat Calculator
Body Fat Calculator
Lean Body Mass
Lean Body Mass
Calories Burned
Calories Burned
Protein Intake
Protein Intake
Macro Calculator
Macro Calculator
Carb Calculator
Carb Calculator
Fat Intake
Fat Intake
Child Height
Child Height
Sports calculators
Golf Handicap
Golf Handicap
Pace Calculator
Pace Calculator
1RM Calculator
1RM Calculator
Target Heart Rate
Target Heart Rate
Weather calculators
Heat Index
Heat Index
Wind Chill
Wind Chill
Dew Point
Dew Point
Computer calculators
Base Converter
Base Converter
Subnet Calculator
Subnet Calculator
Download Time
Download Time
Household energy and budget calculators
Electricity Cost
Electricity Cost
kWh to Cost
kWh to Cost
Yearly kWh to Cost
Yearly kWh to Cost
AC Size (BTU)
AC Size (BTU)
AC Running Cost
AC Running Cost
Heating Costs
Heating Costs
Gas vs Electric
Gas vs Electric
LED Savings
LED Savings
Salary Calculator
Salary Calculator
Budget Calculator
Budget Calculator
Car calculators
Trip Gas Cost
Trip Gas Cost
EV Charging Cost
EV Charging Cost
EV vs Gas Cost
EV vs Gas Cost
MPG Calculator
MPG Calculator
Tire Size
Tire Size
Solar power and battery calculators
Solar Output
Solar Output
Solar Panel Count
Solar Panel Count
Solar Payback
Solar Payback
Battery Size
Battery Size
Home and DIY calculators
Tile Calculator
Tile Calculator
Stair Calculator
Stair Calculator
Concrete Volume
Concrete Volume
Wall Area
Wall Area
Wallpaper Rolls
Wallpaper Rolls
Paint Calculator
Paint Calculator
Flooring Needed
Flooring Needed
Exterior Walls
Exterior Walls
Gravel Needed
Gravel Needed
Mortar Mix
Mortar Mix
Slope Grade
Slope Grade
Lumber Cut List
Lumber Cut List
Lot Coverage/FAR
Lot Coverage/FAR
Sheet Vinyl Roll
Sheet Vinyl Roll
Insulation Needed
Insulation Needed
Curtain Size
Curtain Size
TV Size & Distance
TV Size & Distance
Soil Needed
Soil Needed
Sod Needed
Sod Needed
Block Calculator
Block Calculator
Brick Calculator
Brick Calculator
Deck Materials
Deck Materials
Ramp Length
Ramp Length
Pilot Hole Size
Pilot Hole Size
Room Ventilation
Room Ventilation
Paint Thinning
Paint Thinning
Baseboard & Trim
Baseboard & Trim
Blind Size
Blind Size
Picture Hanging
Picture Hanging
Drain Slope
Drain Slope
Screw Calculator
Screw Calculator
Board Feet
Board Feet
Fence Calculator
Fence Calculator
Wood Shrinkage
Wood Shrinkage
Caulk Calculator
Caulk Calculator
Heat Loss
Heat Loss
Furniture Fit
Furniture Fit
Moving Boxes
Moving Boxes
Storage Capacity
Storage Capacity
Plywood Cuts
Plywood Cuts
Shelf Sag
Shelf Sag

Distance Between Two Points Calculator (Distance Formula, Slope and Equation of the Line)

Enter the coordinates of point 1 and point 2 to find the distance between them. The slope and the equation of the line through the two points are shown too.

Enter the coordinates as numbers (decimals and negative numbers are OK). All four fields are required.
Result and graph
Enter the coordinates of two points in the fields on the left and press "Calculate". The result will appear here.

What you can do on this page

  • Enter the coordinates of two points, and you get the distance \(d\) between them on the spot
  • Along with the distance, it also finds the change in x \(\Delta x\), the change in y \(\Delta y\), the slope \(m\) and the equation of the line through the two points, \(y = mx + b\)
  • The result is also shown on a graph, so you can see that the distance is the length of the line segment joining the two points
  • A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are all on this page
This page finds the straight-line distance between two points in the plane (two dimensions). It also works for two points with the same x-coordinate (on a vertical line), but then the slope is undefined, so "Undefined" is shown, and the line is written as x = c (a constant) instead of y = mx + b.

What is this calculation used for?

Collision detection and distance to enemies in games (programming)

In a 2D game, the positions of your character, enemies and items are kept as coordinates, and the game counts a "hit" when the distance becomes less than a set amount. For example, if your character is at (1, 1) and an enemy is at (4, 5), the distance is \(\sqrt{3^2 + 4^2} = 5\). Repeating this calculation is how distance-based collision detection works.
The distance formula is one of the first practical formulas you write when you start learning game development.

Finding the distance between two locations in surveying and mapping (surveying and civil engineering)

Surveyors record property corners and construction reference points as coordinates, for example in the State Plane Coordinate System used across the United States. Once you know the coordinates of two points, the horizontal distance between them can be found with the distance formula on this page.
This calculation supports the building of roads, buildings and other infrastructure. (To find a distance from latitude and longitude, taking the curve of the Earth into account, a different formula is used.)

Measuring how similar data are in data analysis and AI (Euclidean distance)

In data analysis, a pair of numbers such as height and weight is treated as a point on the coordinate plane, and the closer two points are, the more similar the data are considered to be. This distance (the Euclidean distance) is used to group similar customers (clustering) and to make predictions from nearby data (the k-nearest neighbors method).
The formula on this page is the basic way of measuring distance that appears in every AI and machine learning textbook.

Reading diagonal lengths from drawings and CAD (design and manufacturing)

In technical drawings and CAD, positions such as the centers of holes in a part are given as coordinates. The diagonal distance between the centers of two holes, which is often not written on the drawing, can be found from the differences in coordinates with the distance formula.
For example, two holes 1.5 in apart horizontally and 2 in apart vertically have centers \(\sqrt{1.5^2 + 2^2} = \sqrt{6.25} = 2.5\) in apart. It is an everyday calculation in machining and inspection.

Formulas and figures

Distance between two points \(d\) (the distance formula)
Figure
Standard notation (the usual math form)
\(d\) \(=\) \(\sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\)
In words (symbols replaced with words)
② \(d\): distance between the points \(=\) ① square root of the sum of the squared differences
The formula in words
① Take the square root of the sum of the squared differences, \((x_2 - x_1)^2 + (y_2 - y_1)^2\) (square the difference of the x-coordinates and the difference of the y-coordinates, add them, and take the square root)
② and you get the \(d\): distance between the points
Quick example
The distance between the points (1, 1) and (4, 5) is
distance \(d\) \(=\) square root of the sum of the squared differences ((4−1)² + (5−1)² = 25)
\(d = \sqrt{(4-1)^2 + (5-1)^2} = \sqrt{9 + 16} = \sqrt{25} = 5\)
Key idea
A common mistake is to take the square roots separately, as in \(\sqrt{(x_2-x_1)^2} + \sqrt{(y_2-y_1)^2}\). Add up everything under the square root sign first, and take the square root only once, at the end. Even if a difference of coordinates is negative, its square is positive, so the distance is the same whichever point you enter first. The answer is often a number that does not come out even, such as \(\sqrt{13}\); in that case, this calculator shows a decimal (an approximate value).
Why this formula gives the distance (the Pythagorean theorem)
Figure
Standard notation (the usual math form)
\(\Delta x^2\) \(+\) \(\Delta y^2\) \(=\) \(d^2\)
In words (symbols replaced with words)
① square of the change in x, \(\Delta x = x_2 - x_1\) \(+\) ② square of the change in y, \(\Delta y = y_2 - y_1\) \(=\) ③ square of the distance \(d\) (the hypotenuse)
The formula in words
① Add the square of the change in x, \(\Delta x\) (how far apart the points are horizontally)
② and the square of the change in y, \(\Delta y\) (how far apart the points are vertically)
③ and you get exactly the square of the distance \(d\) between the points (the hypotenuse) (the Pythagorean theorem)
Quick example
Checking with the points (1, 1) and (4, 5) (Δx = 3, Δy = 4)
Δx squared (3² = 9) \(+\) Δy squared (4² = 16) \(=\) distance squared (25 = 5²)
\(3^2 + 4^2 = 9 + 16 = 25 = 5^2\)
Key idea
Picture a right triangle whose hypotenuse is the line segment joining the two points, and whose two legs are the horizontal change \(\Delta x\) and the vertical change \(\Delta y\). Then the Pythagorean theorem applies directly. The distance formula is just this equation solved for \(d\). Once you see that "the distance formula" and "the Pythagorean theorem" are not two different formulas but one and the same theorem, you have one less thing to memorize.
The slope \(m\) and the equation \(y = mx + b\) of the line through two points
Graph
Standard notation (the usual math form)
\(m\) \(=\) \(y_2 - y_1\) \(\div\) \(x_2 - x_1\)
\(y\) \(=\) \(m\) \(\times\) \(x\) \(+\) \(b\)
In words (symbols replaced with words)
③ \(m\): slope of the line \(=\) ① change in y, \(\Delta y = y_2 - y_1\) \(\div\) ② change in x, \(\Delta x = x_2 - x_1\)
⑦ \(y\): y-coordinate of a point on the line \(=\) ④ \(m\): slope \(\times\) ⑤ \(x\): x-coordinate \(+\) ⑥ \(b\): y-intercept
The formula in words
① Take the change in y, \(\Delta y\)
② divide it by the change in x, \(\Delta x\)
③ and you get the \(m\): slope of the line
④ Next, take the \(m\): slope
⑤ multiply it by the \(x\): x-coordinate
⑥ add the \(b\): y-intercept (found as \(b = y_1 - m x_1\))
⑦ and you get the \(y\): y-coordinate of a point on the line (this is the equation of the line through the two points)
Quick example
For the line through the points (1, 5) and (3, 2)
slope \(m\) \(=\) change in y (2 − 5 = −3) \(\div\) change in x (3 − 1 = 2)
\(m = \frac{2 - 5}{3 - 1} = \frac{-3}{2} = -1.5\)
\(b = y_1 - m x_1 = 5 - (-1.5) \times 1 = 6.5\)
\(y = -1.5x + 6.5\)
Key idea
As a bonus to the distance, this calculator also shows information about the line through the two points. The slope \(m\) tells how much the line goes up or down for each 1 step to the right, and the y-intercept \(b\) is the height where the line crosses the y-axis. However, when the two points have the same x-coordinate (\(x_1 = x_2\), one directly above the other), you would have to divide by \(\Delta x = 0\), so the slope is undefined. This line cannot be written as \(y = mx + b\); it takes the form \(x = c\), where \(c\) is a constant (a vertical line). The distance can still be found as \(|\Delta y|\). For a more detailed explanation of slope and the angle of inclination, see the related page "Slope Calculator".
To find the distance between two points, square the difference of the x-coordinates and the difference of the y-coordinates, add them, and take the square root. This is the Pythagorean theorem itself. Picture it as finding the length of the hypotenuse from the horizontal and vertical differences, and you will not forget it.

Symbols and terms

Symbols

\(d\) dee The distance between the two points, from the first letter of "distance".
\((x_1, y_1)\), \((x_2, y_2)\) x sub one, y sub one The coordinates of the two points. \(x\) is the horizontal position and \(y\) is the vertical position. The small number at the lower right (the subscript) tells the first point from the second.
\(\Delta x\), \(\Delta y\) delta x, delta y The change (the difference of the coordinates). \(\Delta\) (delta) is a Greek letter that stands for "change" or "difference": \(\Delta x = x_2 - x_1\) and \(\Delta y = y_2 - y_1\).
\(\sqrt{\phantom{a}}\) square root (radical sign) The sign for the square root (the number that gives this number when squared). \(\sqrt{25} = 5\) (because 5² = 25). In the distance formula, you take the square root only once, at the end.
\(m\) em The slope of the line through the two points. It tells how much the line goes up or down for each 1 step to the right. If it is positive, the line rises to the right; if negative, it falls to the right.
\(b\) bee The y-intercept: the height where the line crosses the y-axis (the value of \(y\) when \(x = 0\)).

Terms

coordinates A pair of numbers (horizontal position, vertical position) that gives the position of a point. The point (4, 5) is 4 to the right of the origin and 5 up.
coordinate plane A plane where positions are given by a horizontal x-axis and a vertical y-axis. The distance on this page is the straight-line length between two points on the coordinate plane.
line segment A straight line that joins two points, with those points as its ends. The distance between two points is the length of this line segment.
Pythagorean theorem The theorem that in a right triangle, the sum of the squares of the two legs equals the square of the hypotenuse (\(a^2 + b^2 = c^2\)). The distance formula is this theorem applied to coordinates. It is taught in Grade 8.
hypotenuse The longest side of a right triangle, opposite the right angle. In the distance formula, the line segment joining the two points is the hypotenuse.
Euclidean distance The formal name for the straight-line distance between two points that this page calculates. In data analysis and AI, this name is often used for the basic way to measure how close points are.
slope A number that shows how steep a line is: how much y increases when x increases by 1 ("rise over run"). It is the same as the rate of change of a linear function.
vertical line A line perpendicular to the x-axis (going straight up and down). The line through two points with the same x-coordinate is vertical. The change in x is 0, so its slope is undefined. Its equation has the form \(x = c\), where \(c\) is a constant.

Good to know before you start

Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.
If you get stuck, going back over these topics is the fastest way forward.

The coordinate plane (Grade 6)
  • Being able to read coordinates such as (4, 5) as a pair made of a horizontal position and a vertical position
  • Knowing that negative x- and y-coordinates stand for positions to the left and below
Operations with positive and negative numbers (Grade 7)
  • Being able to subtract with negative numbers, as in \(3 - (-3) = 6\)
  • Knowing that the square of a negative number is positive
Square roots (Grade 8)
  • Knowing that a square root is the number that gives the original number when squared, as in \(\sqrt{25} = 5\)
  • Knowing that a square root that does not come out even, such as \(\sqrt{13}\), can be written as an approximate decimal
The Pythagorean theorem (Grade 8)
  • Knowing that in a right triangle, the sum of the squares of the two legs equals the square of the hypotenuse (this is what the distance formula really is)
Linear functions (Grade 8)
  • Knowing that the graph of \(y = mx + b\) is a straight line with slope \(m\) and y-intercept \(b\) (only needed to read the slope and the equation of the line; not needed for the distance alone)

How to calculate it in Excel

Copy the whole table below and paste it into cell A1 in Excel. It works as is.
Table to find the distance d between two points
Point 1 x-coordinate x₁ 1
Point 1 y-coordinate y₁ 1
Point 2 x-coordinate x₂ 4
Point 2 y-coordinate y₂ 5
Distance between the points d =SQRT((B3-B1)^2+(B4-B2)^2)
Table to check with the Pythagorean theorem
Point 1 x-coordinate x₁ 1
Point 1 y-coordinate y₁ 1
Point 2 x-coordinate x₂ 4
Point 2 y-coordinate y₂ 5
Change in x Δx =B3-B1
Change in y Δy =B4-B2
Sum of squares Δx²+Δy² =B5^2+B6^2
Distance between the points d =SQRT(B7)
Table to find the slope m and the equation of the line
Point 1 x-coordinate x₁ 1
Point 1 y-coordinate y₁ 5
Point 2 x-coordinate x₂ 3
Point 2 y-coordinate y₂ 2
Slope m =(B4-B2)/(B3-B1)
y-intercept b =B2-B5*B1
After pasting, the upper rows are your inputs, and the formulas in the lower rows are calculated automatically.
"SQRT(…)" is the square root, and "^2" is squared.
The first table gives the distance 5. The second table finds the same distance 5 from Δx = 3, Δy = 4 and the sum of squares 25, so you can also see the values along the way.
The third table gives the slope −1.5 and the y-intercept 6.5 (the line y = −1.5x + 6.5). If the two points have the same x-coordinate, you would be dividing by 0 and an error (#DIV/0!) appears; this tells you that the slope is undefined (a vertical line).

How to calculate it in Google Sheets

Copy the whole table below and paste it into cell A1 in Google Sheets. It works as is.
Table to find the distance d between two points
Point 1 x-coordinate x₁ 1
Point 1 y-coordinate y₁ 1
Point 2 x-coordinate x₂ 4
Point 2 y-coordinate y₂ 5
Distance between the points d =SQRT((B3-B1)^2+(B4-B2)^2)
Table to check with the Pythagorean theorem
Point 1 x-coordinate x₁ 1
Point 1 y-coordinate y₁ 1
Point 2 x-coordinate x₂ 4
Point 2 y-coordinate y₂ 5
Change in x Δx =B3-B1
Change in y Δy =B4-B2
Sum of squares Δx²+Δy² =B5^2+B6^2
Distance between the points d =SQRT(B7)
Table to find the slope m and the equation of the line
Point 1 x-coordinate x₁ 1
Point 1 y-coordinate y₁ 5
Point 2 x-coordinate x₂ 3
Point 2 y-coordinate y₂ 2
Slope m =(B4-B2)/(B3-B1)
y-intercept b =B2-B5*B1
The same formulas as in Excel (SQRT and ^2) work as is in Google Sheets. Copy the whole table, paste it into cell A1, and replace the input numbers with your own coordinates.

How to calculate it in Python

import math

x1, y1 = 1.0, 1.0   # coordinates of point 1
x2, y2 = 4.0, 5.0   # coordinates of point 2

delta_x = x2 - x1                        # change in x
delta_y = y2 - y1                        # change in y
distance = math.hypot(delta_x, delta_y)  # distance between the points (same as √(Δx²+Δy²))

print(f"Distance between the points d: {distance}")

# Bonus: slope and equation of the line through the two points (undefined when Δx is 0, a vertical line)
if delta_x != 0:
    slope = delta_y / delta_x            # slope m
    y_intercept = y1 - slope * x1        # y-intercept b
    sign = "+" if y_intercept >= 0 else "-"   # split off the sign so a negative intercept is not shown as "+ -0.3"
    print(f"Slope m: {slope}")
    print(f"y-intercept b: {y_intercept}")
    print(f"Equation of the line: y = {slope}x {sign} {abs(y_intercept)}")
else:
    print(f"Vertical line (x = {x1}), so the slope is undefined")
Runs with the standard library only. math.hypot calculates "the square root of the sum of the squares" in one step, so it is the distance formula itself. Change the coordinates at the top and run it.

How to write it in LaTeX and other math languages (copy and paste)

Distance between two points \(d\) (the distance formula)
d = √((x₂ − x₁)² + (y₂ − y₁)²)
d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>d</mi>
    <mo>=</mo>
    <msqrt>
      <mrow>
        <msup>
          <mrow><mo>(</mo><msub><mi>x</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>x</mi><mn>1</mn></msub><mo>)</mo></mrow>
          <mn>2</mn>
        </msup>
        <mo>+</mo>
        <msup>
          <mrow><mo>(</mo><msub><mi>y</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>y</mi><mn>1</mn></msub><mo>)</mo></mrow>
          <mn>2</mn>
        </msup>
      </mrow>
    </msqrt>
  </mrow>
</math>
d = sqrt((x_2 - x_1)^2 + (y_2 - y_1)^2)
Sqrt[(x2 - x1)^2 + (y2 - y1)^2]
d := sqrt((x2 - x1)^2 + (y2 - y1)^2);
d = sqrt((x2 - x1)^2 + (y2 - y1)^2);
d = √((x_2 - x_1)^2 + (y_2 - y_1)^2)
Why this formula gives the distance (the Pythagorean theorem)
Δx² + Δy² = d²
\Delta x^2 + \Delta y^2 = d^2
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <msup><mrow><mi mathvariant="normal">&#x394;</mi><mi>x</mi></mrow><mn>2</mn></msup>
    <mo>+</mo>
    <msup><mrow><mi mathvariant="normal">&#x394;</mi><mi>y</mi></mrow><mn>2</mn></msup>
    <mo>=</mo>
    <msup><mi>d</mi><mn>2</mn></msup>
  </mrow>
</math>
(Delta x)^2 + (Delta y)^2 = d^2
dx^2 + dy^2 == d^2
dx^2 + dy^2 = d^2;
dx^2 + dy^2 == d^2
Δx^2 + Δy^2 = d^2
The slope \(m\) and the equation \(y = mx + b\) of the line through two points
m = (y₂ − y₁) ÷ (x₂ − x₁),  y = mx + b (b = y₁ − m·x₁)
m = \frac{y_2 - y_1}{x_2 - x_1}, \quad y = mx + b, \quad b = y_1 - m x_1
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>m</mi>
    <mo>=</mo>
    <mfrac>
      <mrow><msub><mi>y</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>y</mi><mn>1</mn></msub></mrow>
      <mrow><msub><mi>x</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>x</mi><mn>1</mn></msub></mrow>
    </mfrac>
    <mo>,</mo>
    <mi>y</mi>
    <mo>=</mo>
    <mi>m</mi><mi>x</mi>
    <mo>+</mo>
    <mi>b</mi>
    <mo>,</mo>
    <mi>b</mi>
    <mo>=</mo>
    <msub><mi>y</mi><mn>1</mn></msub>
    <mo>&#x2212;</mo>
    <mi>m</mi><msub><mi>x</mi><mn>1</mn></msub>
  </mrow>
</math>
m = (y_2 - y_1)/(x_2 - x_1), y = m x + b, b = y_1 - m x_1
m = (y2 - y1)/(x2 - x1); b = y1 - m*x1; y = m*x + b
m := (y2 - y1)/(x2 - x1); b := y1 - m*x1; y := m*x + b;
m = (y2 - y1)/(x2 - x1); b = y1 - m*x1; y = m*x + b;
m = (y_2 - y_1)/(x_2 - x_1), y = mx + b, b = y_1 - mx_1

How to have ChatGPT  do the calculation

You are a math calculation assistant. Do the following calculation by actually running Python code, and base your answer only on the numbers from the execution result (do not answer by mental math or guessing).

For the two points (1, 1) and (4, 5) on the coordinate plane, find each of the following:
1. The distance d between the two points (use the distance formula d = √((x2−x1)² + (y2−y1)²))
2. The change in x, Δx, and the change in y, Δy
3. The slope m of the line through these two points, and the equation of the line y = mx + b (also show the value of the y-intercept b)

Show the formulas you used and the numbers from the execution result.

How to Use
  1. 1
    Enter your numbers
    Type the numbers you want to calculate with into the input fields
  2. 2
    Calculate
    Press the "Calculate" button
  3. 3
    Check the result
    The result appears on the spot. The same page also explains the idea behind the calculation and the formula
  DataChef Features
Easy and Free
Unlimited conversions for free.
No technical knowledge required.
Intuitive and user-friendly operation.
No Registration Required
Available immediately after access.
Can be used without registering personal information.
Safe and Secure
Fully SSL encrypted communication.
Automatic file deletion by clicking "download".
Fast
High-speed site access
and rapid file conversion.
No Watermark
No watermark.
No attribution required.
Commercial Use Available
Free for commercial use.
No need to contact us for commercial use permission.