Given a line described by the linear equation in the general form $ax + by + c = 0$, how do I compute the coefficients $a_1$, $b_1$, $c_1$ of a perpendicular line described by the linear equation in the general form $a_1x + b_1y + c_1 = 0$ passing through the point $(x1, y1)$, explaining the reasoning behind and without resorting to slope form? As a curiosity in exploring its potential, I tried to ask ChatGPT but it seems extremely biased in converting the original line equation to slope form and returning coefficients for that, which is what I want to avoid to not incur in a formulation that don't handle finding perpendicular lines to equations in the form $y = c$. Unfortunately most answers I found do it similarly or just answers using the slope form. Note: In the end, I found the formulation I was looking for but I'm interested in the reasoning behind.
-
1$\begingroup$ Is it "resorting to slope form" if I directly suggest $a_1 = b$, $b_1 = -a$, and then compute $c_1$ from $c_1 = -(a_1 x_1 + b_1x_2)$? (These $a_1, b_1, c_1$ are not unique as they can be scaled by any non-zero number) $\endgroup$– peterwhyFeb 4 at 14:32
-
$\begingroup$ I fixed the intersection point naming, was better $(x1,y1)$ $\endgroup$– ceztkoFeb 4 at 14:45
-
1$\begingroup$ "I tried to ask ChatGPT": it can't even do basic calculations like those with the four operations. It tries to look for a match from something in its database so it doesn't understand maths, as can be seen from when it tries to explain its reasoning. $\endgroup$– Toby MakFeb 4 at 14:47
-
$\begingroup$ Yes, it was an attempt to understand its potentiality. Also it will do a lot of mistakes with signs and variable names. It gave me few hints, though. My reflection was that ChatGPT is biased in the same way people prefer to tell simple solutions that they understood, instead of searching for solid solutions that won't incur in singularities. $\endgroup$– ceztkoFeb 4 at 14:51
-
$\begingroup$ @peterwhy yes, that's the correct formulation. I edited the question to better clarify what I meant with "resorting to slope form". Basically most human answers I found returned the coefficients of a "slope form", which is not what I was interested. $\endgroup$– ceztkoFeb 4 at 16:41
2 Answers
$$ax+by+c=0$$
See e.g. Wikipedia: Line (geometry) for the different kinds of equations for a line: general form (as above), linear equation and parametric equation.
You don't want to use the standard form (slope-intercept equation). Let's use the parametric form (vector equation) therefore.
$$\left(^a_0\right)x+\left(^0_b\right)y+c=0\tag{1}$$
If the direction vector of a line is $\left(^{u_1}_{u_2}\right)$, the direction vector of its normal (the normal vector) is $\left(^{-u_2}_{\ \ \ u_1}\right)$. For a line perpendicular to line (1), we have therefore:
$$\left(^{-b}_{\ \ \ 0}\right)x+\left(^0_a\right)y+d=0$$
$$-bx+ay+d=0\tag{2}$$
Because line (2) must go through point $(x_1,y_1)$:
$$-bx_1+ay_1+d=0$$
$$d=bx_1-ay_1$$
Inserting into (2):
$$-bx+ay+bx_1-ay_1=0$$
$$bx-ay-bx_1+ay_1=0$$
$$a_1=b,\ b_1=-a,\ c_1=-bx_1+ay_1$$
For mathematics questions, we should better ask Wikipedia.
This answer will use vectors. The calculations can also be done without vectors, but the language of vectors is convenient.
Note that if a vector with coordinates $(p,q)$ is perpendicular to a vector with coordinates $(-q,p),$ which can be confirmed by taking the inner product (aka dot product) of the two vectors.
Without resorting to the usual slope-intercept equations for lines (which, as you point out, do not handle lines parallel to the $y$-axis), we know that the line described by
$$ ax + by + c = 0 $$
is perpendicular to the vector with $(x, y)$ coordinates $(a, b).$ This can be seen because if $ ax + by + c = 0 $ then $ a(x - b) + b(y + a) + c = 0 ,$ that is, by moving in the direction of the vector $(-b,a)$ we stayed on the line, but the vector $(-b,a)$ is perpendicular to the vector $(a,b).$
So we can always convert the equation of a line in this format to the coordinates of a vector perpendicular to the line by taking the coefficients of $x$ and $y$ in the equation as the $x$ and $y$ coordinates of the vector, and conversely we can use the $x$ and $y$ coordinates of a vector as the coefficients of $x$ and $y$ in an equation of this form to obtain the equation of a line perpendicular to the vector.
To get a line perpendicular to $ ax + by + c = 0 ,$ we therefore want a line parallel to the vector $(a,b),$ which is perpendicular to the vector $(-b,a).$ So we can take the coordinates of the vector $(-b,a)$ as the coefficients of $x$ and $y$ in the equation of a perpendicular line:
$$ -bx + ay + c_1 = 0. $$
Any value of $c_1$ in this equation will produce a line perpendicular to our original line, but we need the particular line that passes through $(x_1,y_1),$ that is, the line such that $$ -bx_1 + ay_1 + c_1 = 0. $$
Solving for $c_1,$ we have
$$ c_1 = bx_1 - ay_1. $$
So an equation of the line through the point $(x_1,y_1)$ perpendicular to the line $ ax + by + c = 0 $ is
$$ -bx + ay + (bx_1 - ay_1) = 0. $$
This is "an" equation since we can get an equally good equation of the same line by multiplying all coefficients (including the constant term) by a single non-zero factor.