The roots of the equations:
- \( x^2 + 2x - a^2 = 0 \Rightarrow x = -1 \pm \sqrt{1 + a^2} \)
- \( y^2 + 4y - b^2 = 0 \Rightarrow y = -2 \pm \sqrt{4 + b^2} \)
So points A and B are:
- \( A = (x_1, y_1), B = (x_2, y_2) \) where:
\[
x_1 + x_2 = -2,\quad y_1 + y_2 = -4,\quad x_1 x_2 = -a^2,\quad y_1 y_2 = -b^2
\]
Midpoint \( M = \left( \frac{x_1 + x_2}{2}, \frac{y_1 + y_2}{2} \right) = (-1, -2) \)
Using formula for circle with diameter AB:
\[
(x - x_1)(x - x_2) + (y - y_1)(y - y_2) = 0
\Rightarrow x^2 - (x_1 + x_2)x + x_1 x_2 + y^2 - (y_1 + y_2)y + y_1 y_2 = 0
\]
Substitute:
- \( x_1 + x_2 = -2 \)
- \( x_1 x_2 = -a^2 \)
- \( y_1 + y_2 = -4 \)
- \( y_1 y_2 = -b^2 \)
\[
x^2 + 2x - a^2 + y^2 + 4y - b^2 = 0
\Rightarrow x^2 + y^2 + 2x + 4y - a^2 - b^2 = 0
\]
\[
\boxed{ x^2 + y^2 + 2x + 4y - a^2 - b^2 = 0 }
\]