Solution (source code)

= Solution

Expand the square using $i^2=-1$:
$$
\left(\frac12+2i\right)^2=\frac14+2i-4=-\frac{15}4+2i.
$$
Thus the <real part> and <imaginary part> are
$$
\boxed{\operatorname{Re}=-\frac{15}4,\qquad\operatorname{Im}=2.}
$$