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 from a Point to a Line Calculator (Foot of the Perpendicular and Parallel Lines)

Choose how the line is written (general form or slope-intercept form), then enter the coefficients and the coordinates of the point. The equation below is linked to the input fields, so you can also edit the numbers in the equation directly.

Enter numbers only. Decimals, negative numbers and fractions such as 3/4 are OK. A blank coefficient of x or y counts as 1 (x is the same as 1x), and a blank constant or coordinate counts as 0.
Result and figure
Enter the coefficients of the line and the coordinates of the point in the fields on the left and press "Calculate". The result and a figure will appear here.

What you can do on this page

  • Enter the coefficients and coordinates, and you get the distance from a point \(\mathrm{P}(x_0,\ y_0)\) to a line \(ax + by + c = 0\) on the spot (the length of the perpendicular from the point to the line, which is the shortest distance)
  • The answer is shown both as an exact value with a rationalized denominator, such as \(\dfrac{7\sqrt{5}}{5}\), and as a decimal (12 significant digits)
  • Besides the distance, you also get the coordinates of the foot of the perpendicular \(\mathrm{H}\) (the point on the line closest to \(\mathrm{P}\)) and the equation of the perpendicular line itself
  • You can enter the line in general form \(ax + by + c = 0\) or in slope-intercept form \(y = mx + k\) (for slope-intercept form, the steps also show how to rewrite it in general form)
  • The distance between two parallel lines \(ax + by + c_1 = 0\) and \(ax + by + c_2 = 0\) can be found on the same screen
  • You can check the result on a figure of the coordinate plane. A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are also on this page
Coefficients and coordinates can be decimals, negative numbers or fractions such as 3/4. This page works with lines in the plane (2D).

What is this calculation used for?

How GPS and map apps know which road you are on

The location your phone or car GPS receives can be off by several feet to over a hundred feet. If the app simply plotted that point, you might appear inside a building or in the middle of a field. So map apps calculate the distance from the measured point to each nearby road (on the map, a set of line segments) and move the point onto the closest road. This is called map matching, and the distance from a point to a line is at its core.
If the app also finds the foot of the perpendicular, it knows exactly where on that road you are, so it can tell you how far it is to the next turn.

Measuring offsets from a reference line in construction and surveying

Building plans have grid lines, and road and railway designs have a centerline. The positions of columns, walls, curbs and stakes are given as "how far from the reference line". This offset is exactly the distance from a point to a line. On site, surveyors calculate it from coordinates measured with a total station and check it against the design value.
Placing a curb at half the road width from the centerline is the same calculation repeated along the road.

How machine learning picks a line that separates two groups

A classification method called the support vector machine draws a line (a plane in higher dimensions) between two groups of data. It picks the line that is as far as possible from the data points of both groups, and that "how far" is the distance from a point to a line. Choosing the line with the widest gap (margin) is believed to make fewer mistakes on data the model has not seen yet.
It has been a standard method for spam filtering and image classification since before deep learning spread, and it is still a strong choice when there is little training data.

Finding lines in images and point clouds (image processing and self-driving cars)

Lane detection in self-driving cars and straightening a scanned document both need the line that best fits a set of detected points. How well a line fits is measured by adding up the squared distances from each point to the line, and the line with the smallest total is chosen.
RANSAC, a method that fits a line while ignoring outliers, also uses the point-to-line distance: points within a set distance of the line count as fitting it.

Simplifying paths in maps and graphics

When you zoom out on a map app, small bends in coastlines and roads are dropped automatically. This uses the Ramer–Douglas–Peucker algorithm. It finds the point farthest from the straight line joining the two ends of a path. If that distance is smaller than a set limit, all the points in between are dropped; if not, the path is split at that point and the check is repeated.
The shape still looks right with far less data, because the algorithm measures "how far off the line" each point is with a proper distance.

Formulas and figures

Distance from a point to a line
Figure
Standard notation (the usual math form)
\(d\) \(=\) \(\left|a x_0 + b y_0 + c\right|\) \(\div\) \(\sqrt{a^{2} + b^{2}}\)
In words (symbols replaced with words)
③ \(d\): distance from \(\mathrm{P}\) to the line \(=\) ① absolute value of \(ax + by + c\) at the point \(\div\) ② \(\sqrt{a^2 + b^2}\): length of the normal vector
The formula in words
① Take the absolute value of \(ax + by + c\) with the point \((x_0,\ y_0)\) plugged in
② divide it by the length \(\sqrt{a^2 + b^2}\) of the normal vector \((a,\ b)\)
③ and you get the distance \(d\) from \(\mathrm{P}\) to the line
Quick example
The distance from the point \(\mathrm{P}(4,\ 3)\) to the line \(x + 2y - 3 = 0\) is
distance \(d\) \(=\) absolute value at the point (\(|4 + 6 - 3| = 7\)) \(\div\) length of the normal vector (\(\sqrt{1 + 4} = \sqrt{5}\))
\(d = \dfrac{\left|1 \times 4 + 2 \times 3 + (-3)\right|}{\sqrt{1^{2} + 2^{2}}} = \dfrac{7}{\sqrt{5}} = \dfrac{7\sqrt{5}}{5} \approx 3.13\)
Key idea
The distance from a point to a line is the length of the perpendicular dropped from the point to the line. A line has endless points, but only the foot of the perpendicular is closest to \(\mathrm{P}\). Every other point on the line is farther away, because in a right triangle the hypotenuse is longer than either leg. That is why "distance = shortest distance = length of the perpendicular" is a clear definition. Rewriting \(\dfrac{7}{\sqrt{5}}\) as \(\dfrac{7\sqrt{5}}{5}\) is called rationalizing the denominator. With a root in the denominator, it is hard to see how big the value is or to add it to other values, so answers are usually written with a rationalized denominator. If \(a\) and \(b\) are both 0, then \(ax + by + c = 0\) is not a line, and the formula cannot be used.
Why this formula gives the distance (using the normal vector)
Figure
Standard notation (the usual math form)
\(d\) \(=\) \(\left|\vec{n}\cdot\overrightarrow{\mathrm{AP}}\right|\) \(\div\) \(\left|\vec{n}\right|\)
In words (symbols replaced with words)
③ \(d\): distance from \(\mathrm{P}\) to the line \(=\) ① absolute value of the dot product of the normal vector and \(\overrightarrow{\mathrm{AP}}\) \(\div\) ② \(|\vec{n}|\): length of the normal vector \(\vec{n}\)
The formula in words
① Let \(\mathrm{A}\) be any point on the line and \(\vec{n} = (a,\ b)\) the vector perpendicular to the line (the normal vector). Take the absolute value of the dot product of \(\vec{n}\) and \(\overrightarrow{\mathrm{AP}}\)
② divide it by the length \(|\vec{n}|\) of the normal vector \(\vec{n}\)
③ and you get the distance \(d\) from \(\mathrm{P}\) to the line
Quick example
Try it with the point \(\mathrm{A}(3,\ 0)\) on the line \(x + 2y - 3 = 0\) and the point \(\mathrm{P}(4,\ 3)\) (\(\vec{n} = (1,\ 2)\), \(\overrightarrow{\mathrm{AP}} = (1,\ 3)\))
distance \(d\) \(=\) absolute value of the dot product (\(|1 \times 1 + 2 \times 3| = 7\)) \(\div\) length of the normal vector (\(\sqrt{5}\))
\(\vec{n}\cdot\overrightarrow{\mathrm{AP}} = 1 \times 1 + 2 \times 3 = 7\)
\(d = \dfrac{\left|7\right|}{\sqrt{5}} = \dfrac{7\sqrt{5}}{5} \approx 3.13\)
Key idea
Take the \(x\) and \(y\) coefficients of the line \(ax + by + c = 0\) as they are, and you get the vector \(\vec{n} = (a,\ b)\). This vector is perpendicular to the line, and it is called the normal vector. To see why, take two points \((x_1,\ y_1)\) and \((x_2,\ y_2)\) on the line. Both satisfy the equation, so subtracting gives \(a(x_2 - x_1) + b(y_2 - y_1) = 0\). The dot product of \(\vec{n}\) and a vector along the line is 0, so they are perpendicular. Since \(\mathrm{A}\) is on the line, \(ax_1 + by_1 + c = 0\). Expanding \(\vec{n}\cdot\overrightarrow{\mathrm{AP}} = a(x_0 - x_1) + b(y_0 - y_1)\) therefore gives exactly \(ax_0 + by_0 + c\). This is why the numerator of the distance formula is "the point's coordinates plugged into the equation". The dot product \(\vec{n}\cdot\overrightarrow{\mathrm{AP}}\) equals the length of the shadow of \(\overrightarrow{\mathrm{AP}}\) cast straight onto the direction of \(\vec{n}\), times \(|\vec{n}|\). (If the shadow falls in the direction opposite to \(\vec{n}\), the sign is negative, so we take the absolute value to get a length.) Why is that shadow the distance we want? Let \(\mathrm{H}\) be the foot of the perpendicular. Then \(\overrightarrow{\mathrm{AP}} = \overrightarrow{\mathrm{AH}} + \overrightarrow{\mathrm{HP}}\). \(\overrightarrow{\mathrm{AH}}\) runs along the line, so it is perpendicular to \(\vec{n}\) and casts no shadow in that direction. The remaining part \(\overrightarrow{\mathrm{HP}}\) is parallel to \(\vec{n}\), so its shadow is its full length, which is the distance \(d\) from \(\mathrm{P}\) to the line. The answer does not depend on where you put \(\mathrm{A}\) on the line: moving \(\mathrm{A}\) only changes \(\overrightarrow{\mathrm{AH}}\), which never affects the shadow. So dividing the dot product by \(|\vec{n}|\) gives back the distance. The \(\sqrt{a^2 + b^2}\) in the denominator is this \(|\vec{n}|\).
Distance when the line is in slope-intercept form \(y = mx + k\)
Standard notation (the usual math form)
\(d\) \(=\) \(\left|m x_0 - y_0 + k\right|\) \(\div\) \(\sqrt{m^{2} + 1}\)
In words (symbols replaced with words)
③ \(d\): distance from \(\mathrm{P}\) to the line \(=\) ① absolute value of \(mx - y + k\) at the point \(\div\) ② \(\sqrt{m^2 + 1}\): length of the normal vector \((m,\ -1)\)
The formula in words
① Rewrite the line \(y = mx + k\) as \(mx - y + k = 0\). Then take the absolute value of \(mx - y + k\) with the point plugged in
② divide it by the length \(\sqrt{m^2 + 1}\) of the normal vector \((m,\ -1)\)
③ and you get the distance \(d\) from \(\mathrm{P}\) to the line
Quick example
The distance from the point \(\mathrm{P}(4,\ 3)\) to the line \(y = 2x + 1\) (in general form, \(2x - y + 1 = 0\)) is
distance \(d\) \(=\) absolute value at the point (\(|8 - 3 + 1| = 6\)) \(\div\) length of the normal vector (\(\sqrt{4 + 1} = \sqrt{5}\))
\(y = 2x + 1 \;\Longrightarrow\; 2x - y + 1 = 0\)
\(d = \dfrac{\left|2 \times 4 - 3 + 1\right|}{\sqrt{2^{2} + 1}} = \dfrac{6}{\sqrt{5}} = \dfrac{6\sqrt{5}}{5} \approx 2.68\)
Key idea
When the line is given as \(y = mx + k\), move everything to the left side to get \(mx - y + k = 0\). Comparing this with the general form \(ax + by + c = 0\) gives \(a = m\), \(b = -1\) and \(c = k\), so the denominator becomes \(\sqrt{m^2 + (-1)^2} = \sqrt{m^2 + 1}\). So there is no new formula to memorize. Just rewrite the line in general form and use the same formula. When you choose "slope-intercept form" in this calculator, it also rewrites the line in general form first and shows how in the steps. A vertical line (parallel to the \(y\)-axis, such as \(x = 3\)) has no defined slope \(m\), so it cannot be written as \(y = mx + k\). For such a line, use general form and enter \(a = 1\), \(b = 0\), \(c = -3\).
Coordinates of the foot of the perpendicular \(\mathrm{H}\)
Figure
Standard notation (the usual math form)
\(\mathrm{H}\) \(=\) \(\left(x_0,\ y_0\right)\) \(-\) \(t\,(a,\ b)\)
In words (symbols replaced with words)
③ \(\mathrm{H}\): foot of the perpendicular \(=\) ① \((x_0,\ y_0)\): coordinates of \(\mathrm{P}\) \(-\) ② normal vector \((a,\ b)\) times \(t\)
The formula in words
① Set the scale factor \(t = \dfrac{ax_0 + by_0 + c}{a^2 + b^2}\). Start from the coordinates \((x_0,\ y_0)\) of \(\mathrm{P}\)
② subtract the normal vector \((a,\ b)\) times \(t\)
③ and you get the coordinates of the foot of the perpendicular \(\mathrm{H}\)
Quick example
The foot of the perpendicular from \(\mathrm{P}(4,\ 3)\) to the line \(x + 2y - 3 = 0\) (\(t = \dfrac{7}{5}\)) is
foot of the perpendicular \(\mathrm{H}\) \(=\) coordinates of \(\mathrm{P}\) (\((4,\ 3)\)) \(-\) normal vector times \(\dfrac{7}{5}\) (\(\left(\dfrac{7}{5},\ \dfrac{14}{5}\right)\))
\(t = \dfrac{1 \times 4 + 2 \times 3 + (-3)}{1^{2} + 2^{2}} = \dfrac{7}{5}\)
\(\mathrm{H} = \left(4 - \dfrac{7}{5} \times 1,\ \ 3 - \dfrac{7}{5} \times 2\right) = \left(\dfrac{13}{5},\ \dfrac{1}{5}\right)\)
Key idea
If you move straight from \(\mathrm{P}\) parallel to the normal vector \(\vec{n} = (a,\ b)\), you always hit the line. The place where you hit it is the foot of the perpendicular \(\mathrm{H}\). As the subtraction in \(\mathrm{H} = (x_0,\ y_0) - t\,(a,\ b)\) shows, the scale factor \(t\) tells how many copies of \(\vec{n}\) you must move back to reach the line. If \(t\) is positive, you move opposite to \(\vec{n}\); if \(t\) is negative, you move in the same direction as \(\vec{n}\). The numerator of \(t\) is the same as the numerator of the distance formula (before taking the absolute value), and the denominator is \(a^2 + b^2\), which is \(|\vec{n}|^2\). The distance formula divides by \(|\vec{n}|\) only once, but here we divide twice, and there is a reason. You need to move the distance \(d\), and one copy of \(\vec{n}\) has length \(|\vec{n}|\), so the scale factor is \(d \div |\vec{n}|\). Put \(d = \dfrac{\left|ax_0 + by_0 + c\right|}{|\vec{n}|}\) into it, and you divide by \(|\vec{n}|\) twice. Once you know the foot of the perpendicular, the reflection of \(\mathrm{P}\) across the line is simply \(2\mathrm{H} - \mathrm{P}\). In geometry problems, this reflection is often the key to the solution.
Distance between two parallel lines
Figure
Standard notation (the usual math form)
\(d\) \(=\) \(\left|c_1 - c_2\right|\) \(\div\) \(\sqrt{a^{2} + b^{2}}\)
In words (symbols replaced with words)
③ \(d\): distance between the lines \(=\) ① \(|c_1 - c_2|\): absolute difference of the constants \(\div\) ② \(\sqrt{a^2 + b^2}\): length of the normal vector
The formula in words
① For two lines \(ax + by + c_1 = 0\) and \(ax + by + c_2 = 0\) with the same \(x\) and \(y\) coefficients, take the absolute difference of the constants \(|c_1 - c_2|\)
② divide it by the length of the normal vector \(\sqrt{a^2 + b^2}\)
③ and you get the distance \(d\) between the lines
Quick example
The distance between the lines \(x + 2y - 3 = 0\) and \(x + 2y + 7 = 0\) is
distance between the lines \(d\) \(=\) absolute difference of the constants (\(|-3 - 7| = 10\)) \(\div\) length of the normal vector (\(\sqrt{5}\))
\(d = \dfrac{\left|(-3) - 7\right|}{\sqrt{1^{2} + 2^{2}}} = \dfrac{10}{\sqrt{5}} = 2\sqrt{5} \approx 4.47\)
Key idea
Whether two lines are parallel depends on the ratio of their \(x\) and \(y\) coefficients. For \(a_1x + b_1y + c_1 = 0\) and \(a_2x + b_2y + c_2 = 0\), they are parallel when \(a_1b_2 - a_2b_1 = 0\). (This is just "the ratios are equal" written as a multiplication, and it works even when a coefficient is 0.) For example, \(2x + 4y - 6 = 0\) and \(x + 2y + 7 = 0\) meet this condition, so they are parallel. But the numerator of this formula only works when the coefficients match exactly, so first multiply one equation by a number to make the \(x\) and \(y\) coefficients the same. This calculator takes just one pair of \(x\) and \(y\) coefficients and two constants, so you cannot forget this step. The distance between two parallel lines is the same wherever you pick a point on one of them. So pick any point on one line and find its distance to the other line with the point-to-line formula, and this formula follows right away. A point on \(ax + by + c_1 = 0\) satisfies \(ax_0 + by_0 = -c_1\), so \(|ax_0 + by_0 + c_2| = |c_2 - c_1|\). If \(c_1\) and \(c_2\) are equal, the two equations describe the same line and the distance is 0. Two lines that are not parallel always cross at one point, so there is no gap between them and their distance is 0. That is why this formula is only for parallel lines.
To find the distance from a point \(\mathrm{P}(x_0,\ y_0)\) to a line \(ax + by + c = 0\), plug the point into the equation, take the absolute value \(|ax_0 + by_0 + c|\), and divide it by the length \(\sqrt{a^2 + b^2}\) of the normal vector \((a,\ b)\). This distance is the length of the perpendicular from the point to the line, and the foot of the perpendicular is \(\mathrm{H} = (x_0 - ta,\ y_0 - tb)\), where \(t = \dfrac{ax_0 + by_0 + c}{a^2 + b^2}\).

Symbols and terms

Symbols

\(d\) dee A letter often used for distance, from the first letter of "distance". On this page it is the distance from the point to the line (the length of the perpendicular).
\(a,\ b,\ c\) a, b, c The coefficients of the line \(ax + by + c = 0\). \(a\) is the number in front of \(x\), \(b\) the number in front of \(y\), and \(c\) the number-only term (the constant). Letters from the start of the alphabet are usually used for fixed numbers.
\(x_0,\ y_0\) x naught, y naught The coordinates of the point \(\mathrm{P}\) you measure from. The small 0 at the lower right is a subscript. It shows that this is the coordinate of one fixed point, not the variable \(x\). (Also read "x sub zero".)
\(\mathrm{P},\ \mathrm{H},\ \mathrm{A}\) P, H, A Names of points. \(\mathrm{P}\) is for "point". \(\mathrm{H}\) is a common label for the foot of the perpendicular (think of the foot of a height). \(\mathrm{A}\) is a helper point taken on the line.
\(\left|\ \right|\) absolute value The absolute value sign. A positive number stays as it is; a negative number loses its minus sign (\(|-7| = 7\)). A distance is never negative, so the formula takes the absolute value of the plugged-in value.
\(\sqrt{\ }\) square root The square root sign: the number (0 or greater) that gives the number inside when squared. \(\sqrt{5}\) is the number whose square is 5. The sign is said to come from a stretched letter r, for "radix" (root).
\(\vec{n}\) vector n The normal vector: a vector that points perpendicular to the line. The letter n comes from "normal" (perpendicular). For the line \(ax + by + c = 0\), \(\vec{n} = (a,\ b)\).
\(\left|\vec{n}\right|\) magnitude of vector n The magnitude of a vector (the length of the arrow). For \(\vec{n} = (a,\ b)\), \(|\vec{n}| = \sqrt{a^2 + b^2}\). This is the denominator of the distance formula.
\(\vec{n}\cdot\overrightarrow{\mathrm{AP}}\) n dot AP The dot product of two vectors: multiply matching components and add (for \((a,\ b)\) and \((p,\ q)\), it is \(ap + bq\)). It shows how much the two directions line up. The raised dot is a different operation from ordinary multiplication.
\(t\) tee The scale factor that tells how many copies of the normal vector you move from \(\mathrm{P}\) to reach the line. The letter \(t\) (from "time") is commonly used for a number that can vary like this.
\(m,\ k\) m, k The slope and the y-intercept in slope-intercept form \(y = mx + k\). \(m\) is the usual letter for slope. Textbooks usually write the y-intercept as \(b\) (\(y = mx + b\)), but this page uses \(k\) so it is not confused with the \(b\) of the general form.
\(c_1,\ c_2\) c one, c two The constants of the two parallel lines. The small numbers at the lower right are subscripts that tell the first line from the second.
\(\ell_1,\ \ell_2\) ell one, ell two Names of lines. A script letter \(\ell\), from the first letter of "line", is commonly used for lines.

Terms

distance from a point to a line The length of the perpendicular from the point to the line. It is shorter than the distance to any other point on the line, so it is also the shortest distance between the point and the line. It is usually taught in high school geometry or precalculus.
perpendicular A line or segment that meets another line at a right angle. If you drop a perpendicular from a point to a line, its length is the distance from the point to the line.
foot of the perpendicular The point where the perpendicular from a point meets the original line. It is the spot on the line closest to that point.
general form Writing the equation of a line as \(ax + by + c = 0\). Vertical lines (such as \(x = 3\)) can be written this way too, so every line fits the same form. (Some textbooks call \(ax + by = c\) the standard form; it is the same line with the constant moved to the right side.)
slope-intercept form Writing the equation of a line as \(y = mx + k\) (in most textbooks \(y = mx + b\)). You can see the slope and where the line crosses the \(y\)-axis at a glance, but vertical lines cannot be written this way.
normal vector A vector pointing perpendicular to a line (or a plane). The normal vector of the line \(ax + by + c = 0\) is \((a,\ b)\). The point-to-line distance formula finds the length measured in the direction of this normal vector.
dot product A calculation that makes one number from two vectors: multiply matching components and add (\((a,\ b)\cdot(p,\ q) = ap + bq\)). It also equals \(|\vec{u}||\vec{v}|\cos\theta\). If it is 0, the two vectors are perpendicular.
projection The shadow of one vector cast straight onto the direction of another vector (also called the orthogonal projection). The distance from a point to a line is the length of the shadow of \(\overrightarrow{\mathrm{AP}}\) in the direction of the normal vector.
absolute value The size of a number without its sign. It is the distance from 0 on the number line (\(|-7| = 7\), \(|7| = 7\)). A distance is never negative, so the formula uses the absolute value.
rationalizing the denominator Removing a root from the denominator by multiplying the numerator and denominator by the same number. For example, multiply both parts of \(\dfrac{7}{\sqrt{5}}\) by \(\sqrt{5}\) to get \(\dfrac{7\sqrt{5}}{5}\). It is taught in Algebra 1 or Algebra 2, and final answers are usually written this way.
parallel Two lines that never meet, however far you extend them. For \(a_1x + b_1y + c_1 = 0\) and \(a_2x + b_2y + c_2 = 0\), the lines are parallel or the same when the ratios of the \(x\) and \(y\) coefficients are equal (as an equation, \(a_1b_2 - a_2b_1 = 0\)). If the constants follow the same ratio too, the two lines lie on top of each other.
reflection The point you get by flipping a point across a line, like a mirror image. Once you know the foot of the perpendicular \(\mathrm{H}\), the reflection of \(\mathrm{P}\) is \(2\mathrm{H} - \mathrm{P}\).
coordinate plane A plane with an \(x\)-axis and a \(y\)-axis, where each point is written as a pair \((x,\ y)\). It lets you turn geometry problems into calculations.

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 to review these topics is the fastest way forward.

The coordinate plane and coordinates of points (Grades 5–6)
  • Knowing that a point in the plane is written as a pair of numbers \((x,\ y)\) (for example, the point \((4,\ 3)\) is 4 right and 3 up from the origin)
  • Knowing what the \(x\)-axis, the \(y\)-axis and the origin are
Equations of lines (Grade 8 and Algebra 1)
  • Knowing that \(y = mx + k\) is a line, where \(m\) is the slope (how much \(y\) changes when you move 1 to the right) and \(k\) is the height where it crosses the \(y\)-axis
  • Knowing that the same line can be written as \(ax + by + c = 0\) (general form), and being able to rewrite \(y = 2x + 1\) as \(2x - y + 1 = 0\)
  • Knowing that "the point is on the line" is the same as "the point's coordinates make the equation true"
Square roots and rationalizing the denominator (Algebra 1 and Algebra 2)
  • Knowing that \(\sqrt{5}\) is the number whose square is 5, and being able to take square factors out of a root, as in \(\sqrt{20} = 2\sqrt{5}\)
  • Being able to rationalize \(\dfrac{7}{\sqrt{5}}\) into \(\dfrac{7\sqrt{5}}{5}\) by multiplying the top and bottom by \(\sqrt{5}\)
Absolute value (Grades 6–7)
  • Knowing that the absolute value is the size of a number without its sign, as in \(|-7| = 7\)
  • Understanding that the absolute value is the distance from 0 on the number line, so it is never negative
The Pythagorean theorem and the distance formula (Grade 8 and Geometry)
  • Knowing that \(a^2 + b^2 = c^2\) in a right triangle
  • Knowing that the distance between \((x_1,\ y_1)\) and \((x_2,\ y_2)\) is \(\sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\)
  • Knowing that the hypotenuse is the longest side of a right triangle (this is why the perpendicular is the shortest distance)
Vectors and the dot product (Precalculus)
  • Knowing that a vector has a direction and a magnitude, and in the plane can be written in components as \((a,\ b)\)
  • Knowing that the magnitude of a vector is \(\sqrt{a^2 + b^2}\)
  • Being able to calculate the dot product \((a,\ b)\cdot(p,\ q) = ap + bq\), and knowing that the vectors are perpendicular when it is 0 (you can use the distance formula even if you have not studied this yet)

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 from a point to a line
x coefficient a 1
y coefficient b 2
Constant c -3
x-coordinate of P 4
y-coordinate of P 3
Numerator |a*x0+b*y0+c| =ABS(B1*B4+B2*B5+B3)
Denominator √(a^2+b^2) =SQRT(B1^2+B2^2)
Distance d =B6/B7
Table to check the normal vector explanation
x coefficient a 1
y coefficient b 2
x-coordinate of point A on the line 3
y-coordinate of point A on the line 0
x-coordinate of P 4
y-coordinate of P 3
Dot product n·AP =B1*(B5-B3)+B2*(B6-B4)
Length of the normal vector |n| =SQRT(B1^2+B2^2)
Distance d =ABS(B7)/B8
Table to find the distance for slope-intercept form
Slope m 2
y-intercept k 1
x-coordinate of P 4
y-coordinate of P 3
Distance d =ABS(B1*B3-B4+B2)/SQRT(B1^2+1)
Table to find the foot of the perpendicular H
x coefficient a 1
y coefficient b 2
Constant c -3
x-coordinate of P 4
y-coordinate of P 3
Scale factor t =(B1*B4+B2*B5+B3)/(B1^2+B2^2)
x-coordinate of H =B4-B1*B6
y-coordinate of H =B5-B2*B6
Table to find the distance between parallel lines
x coefficient a 1
y coefficient b 2
1st line's constant c1 -3
2nd line's constant c2 7
Distance d =ABS(B3-B4)/SQRT(B1^2+B2^2)
After pasting, the upper rows (coefficients and coordinates) are your inputs and the lower rows are calculated automatically.
"^" is a power, ABS gives the absolute value, and SQRT gives the square root.
The first table is the example of the point (4, 3) and the line x + 2y - 3 = 0. The numerator is 7, the denominator is about 2.2360679775, and the distance is about 3.1304951685.
The second table checks that the same distance comes from "dot product of the normal vector and AP ÷ length of the normal vector". The dot product is 7, and the distance is about 3.1304951685, the same as in the first table.
The third table is the example of the point (4, 3) and the line y = 2x + 1. The distance is about 2.683281573.
The fourth table gives 1.4, 2.6 and 0.2, so the foot of the perpendicular is (2.6, 0.2) = (13/5, 1/5).
The fifth table is the distance between x + 2y - 3 = 0 and x + 2y + 7 = 0. The answer is about 4.472135955.

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 from a point to a line
x coefficient a 1
y coefficient b 2
Constant c -3
x-coordinate of P 4
y-coordinate of P 3
Numerator |a*x0+b*y0+c| =ABS(B1*B4+B2*B5+B3)
Denominator √(a^2+b^2) =SQRT(B1^2+B2^2)
Distance d =B6/B7
Table to check the normal vector explanation
x coefficient a 1
y coefficient b 2
x-coordinate of point A on the line 3
y-coordinate of point A on the line 0
x-coordinate of P 4
y-coordinate of P 3
Dot product n·AP =B1*(B5-B3)+B2*(B6-B4)
Length of the normal vector |n| =SQRT(B1^2+B2^2)
Distance d =ABS(B7)/B8
Table to find the distance for slope-intercept form
Slope m 2
y-intercept k 1
x-coordinate of P 4
y-coordinate of P 3
Distance d =ABS(B1*B3-B4+B2)/SQRT(B1^2+1)
Table to find the foot of the perpendicular H
x coefficient a 1
y coefficient b 2
Constant c -3
x-coordinate of P 4
y-coordinate of P 3
Scale factor t =(B1*B4+B2*B5+B3)/(B1^2+B2^2)
x-coordinate of H =B4-B1*B6
y-coordinate of H =B5-B2*B6
Table to find the distance between parallel lines
x coefficient a 1
y coefficient b 2
1st line's constant c1 -3
2nd line's constant c2 7
Distance d =ABS(B3-B4)/SQRT(B1^2+B2^2)
The same formulas as in Excel work as is. Copy the whole table, paste it into cell A1, and replace the coefficients and coordinates with your own numbers.

How to calculate it in Python

from fractions import Fraction

# Line ax + by + c = 0 (a fraction such as 3/4 can be written as Fraction(3, 4))
a = Fraction(1)
b = Fraction(2)
c = Fraction(-3)

# Coordinates of point P
x0 = Fraction(4)
y0 = Fraction(3)

# The point plugged into the equation (with its sign) and the squared length of the normal vector
substituted = a * x0 + b * y0 + c
square = a * a + b * b

distance = abs(float(substituted)) / float(square) ** 0.5
print(f"Numerator |a*x0+b*y0+c| = {abs(substituted)}")
print(f"Denominator √(a^2+b^2) = √{square}")
print(f"Distance d = {distance}")

# Foot of the perpendicular H (move back t times the normal vector)
t = substituted / square
foot_x = x0 - a * t
foot_y = y0 - b * t
print(f"Scale factor t = {t}")
print(f"Foot of the perpendicular H = ({foot_x}, {foot_y})")
With the fractions module from the standard library, the numerator, the denominator and the foot of the perpendicular are calculated as exact fractions with no rounding error. This example finds the distance from the point (4, 3) to the line x + 2y - 3 = 0. Running it shows the numerator 7, the denominator √5, the distance 3.1304951684997055, the scale factor t = 7/5 and the foot of the perpendicular (13/5, 1/5). Change the coefficients and coordinates and run it again.

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

Distance from a point to a line
d = |a·x₀ + b·y₀ + c| ÷ √(a² + b²)
d = \frac{\left|a x_0 + b y_0 + c\right|}{\sqrt{a^{2} + b^{2}}}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>d</mi>
    <mo>=</mo>
    <mfrac>
      <mrow>
        <mo>|</mo>
        <mi>a</mi><msub><mi>x</mi><mn>0</mn></msub>
        <mo>+</mo>
        <mi>b</mi><msub><mi>y</mi><mn>0</mn></msub>
        <mo>+</mo>
        <mi>c</mi>
        <mo>|</mo>
      </mrow>
      <msqrt>
        <mrow>
          <msup><mi>a</mi><mn>2</mn></msup>
          <mo>+</mo>
          <msup><mi>b</mi><mn>2</mn></msup>
        </mrow>
      </msqrt>
    </mfrac>
  </mrow>
</math>
d = abs(a*x_0 + b*y_0 + c)/sqrt(a^2 + b^2)
d = Abs[a x0 + b y0 + c]/Sqrt[a^2 + b^2]
d := abs(a*x0 + b*y0 + c)/sqrt(a^2 + b^2);
d = abs(a*x0 + b*y0 + c)/sqrt(a^2 + b^2);
d = |a x_0+b y_0+c|/√(a^2+b^2)
Why this formula gives the distance (using the normal vector)
d = |n·AP| ÷ |n|
d = \frac{\left|\vec{n}\cdot\overrightarrow{\mathrm{AP}}\right|}{\left|\vec{n}\right|}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>d</mi>
    <mo>=</mo>
    <mfrac>
      <mrow>
        <mo>|</mo>
        <mover><mi>n</mi><mo>&#x2192;</mo></mover>
        <mo>&#x22C5;</mo>
        <mover><mrow><mi>A</mi><mi>P</mi></mrow><mo>&#x2192;</mo></mover>
        <mo>|</mo>
      </mrow>
      <mrow>
        <mo>|</mo>
        <mover><mi>n</mi><mo>&#x2192;</mo></mover>
        <mo>|</mo>
      </mrow>
    </mfrac>
  </mrow>
</math>
d = abs(vec n * vec(AP))/abs(vec n)
d = Abs[n . ap]/Norm[n]
d := abs(DotProduct(n, ap))/Norm(n, 2);
d = abs(dot(n, ap))/norm(n);
d = |n\vec ∙AP\vec |/|n\vec |
Distance when the line is in slope-intercept form \(y = mx + k\)
d = |m·x₀ − y₀ + k| ÷ √(m² + 1)
d = \frac{\left|m x_0 - y_0 + k\right|}{\sqrt{m^{2} + 1}}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>d</mi>
    <mo>=</mo>
    <mfrac>
      <mrow>
        <mo>|</mo>
        <mi>m</mi><msub><mi>x</mi><mn>0</mn></msub>
        <mo>&#x2212;</mo>
        <msub><mi>y</mi><mn>0</mn></msub>
        <mo>+</mo>
        <mi>k</mi>
        <mo>|</mo>
      </mrow>
      <msqrt>
        <mrow>
          <msup><mi>m</mi><mn>2</mn></msup>
          <mo>+</mo>
          <mn>1</mn>
        </mrow>
      </msqrt>
    </mfrac>
  </mrow>
</math>
d = abs(m*x_0 - y_0 + k)/sqrt(m^2 + 1)
d = Abs[m x0 - y0 + k]/Sqrt[m^2 + 1]
d := abs(m*x0 - y0 + k)/sqrt(m^2 + 1);
d = abs(m*x0 - y0 + k)/sqrt(m^2 + 1);
d = |m x_0-y_0+k|/√(m^2+1)
Coordinates of the foot of the perpendicular \(\mathrm{H}\)
H = (x₀ − t·a, y₀ − t·b) t = (a·x₀ + b·y₀ + c) ÷ (a² + b²)
\mathrm{H} = \left(x_0 - t a,\ y_0 - t b\right),\quad t = \frac{a x_0 + b y_0 + c}{a^{2} + b^{2}}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi mathvariant="normal">H</mi>
    <mo>=</mo>
    <mo>(</mo>
    <mrow><msub><mi>x</mi><mn>0</mn></msub><mo>&#x2212;</mo><mi>t</mi><mi>a</mi></mrow>
    <mo>,</mo>
    <mrow><msub><mi>y</mi><mn>0</mn></msub><mo>&#x2212;</mo><mi>t</mi><mi>b</mi></mrow>
    <mo>)</mo>
    <mo>,</mo>
    <mi>t</mi>
    <mo>=</mo>
    <mfrac>
      <mrow>
        <mi>a</mi><msub><mi>x</mi><mn>0</mn></msub>
        <mo>+</mo>
        <mi>b</mi><msub><mi>y</mi><mn>0</mn></msub>
        <mo>+</mo>
        <mi>c</mi>
      </mrow>
      <mrow>
        <msup><mi>a</mi><mn>2</mn></msup>
        <mo>+</mo>
        <msup><mi>b</mi><mn>2</mn></msup>
      </mrow>
    </mfrac>
  </mrow>
</math>
H = (x_0 - t*a, y_0 - t*b), t = (a*x_0 + b*y_0 + c)/(a^2 + b^2)
t = (a x0 + b y0 + c)/(a^2 + b^2); h = {x0 - t a, y0 - t b}
t := (a*x0 + b*y0 + c)/(a^2 + b^2); H := [x0 - t*a, y0 - t*b];
t = (a*x0 + b*y0 + c)/(a^2 + b^2); H = [x0 - t*a, y0 - t*b];
H = (x_0-t a, y_0-t b), t = (a x_0+b y_0+c)/(a^2+b^2)
Distance between two parallel lines
d = |c₁ − c₂| ÷ √(a² + b²)
d = \frac{\left|c_1 - c_2\right|}{\sqrt{a^{2} + b^{2}}}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>d</mi>
    <mo>=</mo>
    <mfrac>
      <mrow>
        <mo>|</mo>
        <msub><mi>c</mi><mn>1</mn></msub>
        <mo>&#x2212;</mo>
        <msub><mi>c</mi><mn>2</mn></msub>
        <mo>|</mo>
      </mrow>
      <msqrt>
        <mrow>
          <msup><mi>a</mi><mn>2</mn></msup>
          <mo>+</mo>
          <msup><mi>b</mi><mn>2</mn></msup>
        </mrow>
      </msqrt>
    </mfrac>
  </mrow>
</math>
d = abs(c_1 - c_2)/sqrt(a^2 + b^2)
d = Abs[c1 - c2]/Sqrt[a^2 + b^2]
d := abs(c1 - c2)/sqrt(a^2 + b^2);
d = abs(c1 - c2)/sqrt(a^2 + b^2);
d = |c_1-c_2|/√(a^2+b^2)

How to have ChatGPT  do the calculation

You are a math assistant for coordinate geometry. 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 point (4, 3) and the line x + 2y - 3 = 0, find:
1. The distance from the point to the line (as an exact value with a rationalized denominator, and as a decimal)
2. The coordinates of the foot of the perpendicular from the point to the line (as reduced fractions)
3. The equation of that perpendicular (the line through the point, perpendicular to the given line)

In Python, use the fractions module from the standard library and sympy to calculate exactly. 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.