I need to determine $a\in\mathbb{R}$ so that $f:\mathbb{R}\to\mathbb{R}, f(x):=\begin{cases}x^4-x^2+4a & x\leq 1\\x^3+2x+a^2 &x>1\end{cases}$ is continuous in $\mathbb{R}$.
Idea: I only need to make $f$ continuous in $x=1$: $$ \lim_{x\nearrow1}=4a \text{ and } \lim_{x\searrow1}=3+a^2, \text{ so it has to be }4a=3+a^2.$$ Solving $a^2-4a+3=0$ by using the p-q-fomula I get $a=1$ or $a=3$. By checking $f(1)=4=\lim_{x\to1}f(x)$ for $a=1$ and $f(1)=12=\lim_{x\to1}f(x)$ for $a=3$ I can conclude: $f$ is continuous on $\mathbb{R}$ for all $a\in\{1,3\}$, correct?