The minimum of $x^2+y^2$ under the constraints $x+y=a$ and $xy=a+3$ I solved the following problem: If $x,y,a \in \mathbb{R}$ such that $x+y=a$ and $xy=a+3$, find the minimum of $x^2+y^2$
Here is my solution. $x^2+y^2=(x+y)^2 -2xy= a^2-2a-6$. The minimum value is obtained when $a=1$ and it is $-7$. Where did I go wrong?
The answer says that the minimum is $2$ when $x=y=-1$

Since $x,y$ are the real roots $X$ of $$(X-x)(X-y)=0\iff X^2-(x+y)X+xy=0\iff X^2-aX+(a+3)=0,$$ you need to have $$D=(-a)^2-4(a+3)\ge 0\iff (a-6)(a+2)\ge 0\iff a\le -2\ \text{or}\ a\ge 6.$$
So, considering $x^2+y^2=a^2-2a-6=(a-1)^2-7$ for $a\le -2\ \text{or}\ a\ge 6$ gives you that the minimum is $2$ at $a=-2$.
