Closed form of the perpendicular line passing through a point in general form 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.
 A: $$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.
A: 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.
