smallest circle that covers two points with its center in x axis
Don't solve it mathematically. Solve it by hand for a few cases first, and then have a go at making it mathematical. That way you will actually understand what you are doing.

The plane is divided up into points which are closer to $(a_1,b_1)$ than to $(a_2,b_2)$, points which are further away, and points which are equidistant. The $x$-axis is divided in the same way.

In the zone where points are closer to $(a_1,b_1)$, the radius of the circle (with a centre at such a point) is governed by the distance to the further point, $(a_2,b_2)$. So, in that part of the $x$-axis, you are trying to minimise the distance to $(a_2,b_2)$. That is a quadratic function of $x$ (or rather, its square is; but minimising the distance is the same as minimising the square).

In the zone where points are further from $(a_1,b_1)$, the radius of the circle is governed by the distance to $(a_1,b_1)$. So minimise that.

The zone (or, rather, the point on the $x$-axis) where the points are equidistant doesn't need special treatment because you can treat it as being a member of both the above zones at once.

So you already have an algorithm, more or less: find the minimum radius for the "closer to $(a_1,b_1)$" part of the $x$-axis, find the minimum radius for the "closer to $(a_2,b_2)$ part, and pick the minimum of the two minima.

But for real understanding, consider the possible geometries of the distance function in each of the two halves, and how the geometry of one half might relate to the geometry of the other half. Because nobody wants a solution to the question (it is known!) so the only benefit of doing the work is to gain understanding.