Solve the following system of equations: $\;$ $x + y + xy = 5, \;\; x^2 + y^2 + xy = 7$
Given system of equations:
$x + y + xy = 5$ $\;\;\; \cdots \; (1)$ $\;$ and $\;$ $x^2 + y^2 + xy = 7$ $\;\;\; \cdots \; (2)$
Adding equations $(1)$ and $(2)$ gives
$x^2 + y^2 + 2xy + x + y = 12$
i.e. $\;$ $\left(x + y\right)^2 + \left(x + y\right) = 12$ $\;\;\; \cdots \; (3)$
Let $\;\;$ $x + y = p$ $\;\;\; \cdots \; (4)$
Then, in view of equation $(4)$, equation $(3)$ becomes
$p^2 + p - 12 = 0$
i.e. $\;$ $\left(p + 4\right) \left(p - 3\right) = 0$
i.e. $\;$ $p = - 4$ $\;\;$ or $\;\;$ $p = 3$
When $\;$ $p = - 4$, $\;$ we have from equation $(4)$
$x + y = - 4$ $\;\;$ i.e. $\;$ $x = - 4 - y$ $\;\;\; \cdots \; (5)$
In view of equation $(5)$, equation $(1)$ becomes
$- 4 - y + y - \left(4 + y\right) y = 5$
i.e. $\;$ $-4 - 4y - y^2 = 5$
i.e. $\;$ $y^2 + 4y + 9 = 0$ $\;\;\; \cdots \; (6)$
Equation $(6)$ does not have a real solution since its discriminant $\;$ $\Delta = \left(4\right)^2 - \left(4 \times 1 \times 9\right) = 16 - 36 = -20 < 0$
Next, when $\;$ $p = 3$, $\;$ we have from equation $(4)$
$x + y = 3$ $\;\;$ i.e. $\;$ $x = 3 - y$ $\;\;\; \cdots \; (7)$
In view of equation $(7)$, equation $(1)$ becomes
$3 - y + y + \left(3 - y\right) y = 5$
i.e. $\;$ $3 + 3y - y^2 = 5$
i.e. $\;$ $y^2 - 3y + 2 = 0$
i.e. $\;$ $\left(y - 2\right) \left(y - 1\right) = 0$
i.e. $\;$ $y = 2$ $\;\;$ or $\;\;$ $y = 1$
Substituting the values of $y$ in equation $(1)$ gives
when $\;$ $y = 2$, $\;\;$ $x + 2 + 2x = 5$
i.e. $\;$ $3x = 3$ $\;\;$ i.e. $\;$ $x = 1$
and when $\;$ $y = 1$, $\;\;$ $x + 1 + x = 5$
i.e. $\;$ $2x = 4$ $\;\;$ i.e. $\;$ $x = 2$
$\therefore \;$ The solution to the given system of equations is $\;$ $\left(x, y\right) = \left\{\left(1, 2\right), \; \left(2, 1\right) \right\}$