Tool to calculate the equation of a line perpendicular to another (or a segment) passing through a given point in the plane.
Perpendicular Line - dCode
Tag(s) : Geometry
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
A line perpendicular to another is a line that intersects it at a right angle, that is, an angle of 90°. In the Cartesian plane, two lines are perpendicular when the product of their slope coefficients is equal to $ -1 $
Starting with a starting line in the form $ y = a x + b $, the slope of the perpendicular line is then $ c = -1/a $
All lines perpendicular to the first will therefore have an equation of the type: $ y = c x + d $, or $ y = (-1/a) x + d $
The parameter $ d $ (the y-intercept) can take any real value: it determines the vertical position of the line.
Thus, there are an infinite number of lines perpendicular to a given line, all parallel to each other.
Example: The line $ y = 2x + 1 $ has as perpendicular lines all those of the form $ y = -\frac{1}{2}x + d $, where $ d $ is any real number.
If the first line has the equation $ y = ax + b $, and the second $ y = c x + d $, then they are perpendicular if and only if $ a \times c = -1 $
Example: The line with equation $ y = 2x + 1 $ (slope $ 2 $) is perpendicular to the line with equation $ y = -x/2 + 3 $ (slope $ -1/2 $) because $ 2 \times -1/2 = -1 $
Identify the slope $ a $ of the starting line.
Calculate the slope $ c = -\frac{1}{a} $ of the perpendicular.
Knowing a point $ P(x_0, y_0) $ through which it passes, write the equation in reduced form: $ y - y_0 = c(x - x_0) $
Simplify to obtain the form $ y = cx + d $ with $ d = y_0 - cx_0 $
Example: The perpendicular to the line $ y = 2x + 1 $ passing through $ A(0, 3) $ has the equation $ y - 3 = -\frac{1}{2}(x - 0) $ or $ y = -\frac{x}{2} + 3 $
Solve the system formed by their equations: $ y = a x + b $ and $ y = c x + d $
By equating the two expressions, obtain the coordinates of the intersection point: $$ x = \frac{d-b}{a-c} $$ then calculate $ y $ by substituting into one of the equations.
If the starting line is vertical (equation of type $ x = c $), the perpendicular line is horizontal (equation $ y = k $) and the slope of a vertical line is undefined.
If the starting line is horizontal (equation of type $ y = c $), the perpendicular line is vertical (equation $ x = k $) and the slope of the horizontal line is zero.
dCode retains ownership of the "Perpendicular Line" source code. Any algorithm for the "Perpendicular Line" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Perpendicular Line" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Perpendicular Line" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Perpendicular Line" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Perpendicular Line on dCode.fr [online website], retrieved on 2025-10-19,