<s>[INST] JEE Circles Doubt Can you derive a general formula for length of intercept made by a circle $x^2+y^2+2gx+2fy+c=0$ on the line $ax+by+c=0$? If no, then is there any other method to solve these type of questions?
 [/INST] \begin{align} 
x^2+y^2+2gx+2fy+d &= 0
\tag{1}\label{1}
,\\
ax+by+c &= 0
\tag{2}\label{2}
.
\end{align}
Expression \eqref{1} represent a circle
with radius $r=\sqrt{g^2+f^2-d}$
centered at $O=(-g,-f)$:
\begin{align} 
(x+g)^2+(y+f)^2
&=g^2+f^2-d
\tag{3}\label{3}
.
\end{align}
Intersection points $X_+,\ X_-$
of the circle $(O,R)$
and the line through the point $B$
in direction $D=z_2-z_1$ can be found as follows:
\begin{align}
X_{\pm}&=B+t_{\pm}\cdot D
\tag{4}\label{4}
,\\
t_{\pm}&=\frac{-(B-O)\odot D\pm\sqrt{\left((B-O)\odot D\right)^2+|D|^2(R^2-|B-O|^2)}}{|D|^2}
\tag{5}\label{5}
,
\end{align}
where $\odot$ is
the dot product.
Given \eqref{2},\eqref{3}, we can apply \eqref{4}, \eqref{5}
by setting (assuming that $b\ne0$)
\begin{align} 
O&=(-g,-f)
,\quad
z_1=(0,-\tfrac cb)
,\quad
z_2=(1,-\tfrac{a+c}b)
,\quad
B=z_1
,\quad
D=z_2-z_1=(1,-\tfrac ab)
\tag{6}\label{6}
.
\end{align}
The number of intersections is defined by the discriminant
\begin{align} 
\delta&=
(a\,f-b\,g)^2-d\,(a^2+b^2)+c\,(2a\,g+2b\,f-c)
\tag{7}\label{7}
.
\end{align}
If $\delta<0$, there are no intersections,
if $\delta>0$, there are two intersection points,
\begin{align} 
X_{\pm}&=
\left(
\frac{-b\,\Big(b\,g-a\,f\pm\sqrt{\delta}\Big)-a\,c}{a^2+b^2},\ 
\frac{ a\,\Big(b\,g-a\,f\pm\sqrt{\delta}\Big)-b\,c}{a^2+b^2}
\right)
\tag{8}\label{8}
,
\end{align}
and if $\delta=0$, then the line is tangent to the circle at the point
\begin{align} 
X_+=X_-&=
\left(
\frac{-b\,(b\,g-a\,f)-a\,c}{a^2+b^2},\ 
\frac{ a\,(b\,g-a\,f)-b\,c}{a^2+b^2}
\right)
\tag{9}\label{9}
.
\end{align}
The length of intercept is just
\begin{align}
|X_+-X_-|&=
2\sqrt{\frac{\delta}{a^2+b^2}}
\tag{10}\label{10}
.
\end{align}
</s>