Find $\operatorname{Tr}(A^{2018})$ if $\det(A^2-2018I_2)=0$ 
Find $\operatorname{Tr}(A^{2018})$ if $\det(A^2-2018I_2)=0, A\in M_2(\mathbb{Q})$

My attempt:
Let $A^2=\begin{bmatrix}a&b\\c&d\end{bmatrix}$ then $B=A^2-2018I_2=\begin{bmatrix}a-2018&b\\c&d-2018\end{bmatrix}$
then $\det(B)=(a-2018)(d-2018)-bc$ then we have: $a = 2018$ or $d=2018$ AND $b=0$ or $c=0$. And I took the possible candidate for $A^2$ when all of these happen at the same time so: $a=2018,d=2018,b=0,c=0\implies \operatorname{Tr}(A^{2018})=2\times2018^{1009}$ by induction.
Did I do everything right? I feel like my solution is not really that good.
Also can you give me some advice that might help me in these kind of situation with problems like this?
 A: Let 
$$
A=\begin{bmatrix}
\sqrt{2018}&0\\0&a\end{bmatrix}.$$
Then, 
$$
\det(A^2-2018I_2)=0
$$ 
and 
$$
A^{2018}=\begin{bmatrix}2018^{1009}&0\\0&a^{2018}\end{bmatrix},$$
which does not have a trace independent of $a$.  So, is there any additional information you have about $A$?
A: $\det(A^2-2018I_2)=0$ implies that $2018$ is an eigenvalue of $A^2$.
The spectral mapping theorem gives that $\sigma(A^2) = \sigma(A)^2$ so at least one of $\sqrt{2018}$ and $-\sqrt{2018}$ is in $\sigma(A).$
Now, because $A \in M_2(\mathbb{Q})$, its characteristic polynomial $p_A$ has rational coefficients and  $\deg p_A = 2$.
We know that one of $\pm\sqrt{2018}$ is a root of $p_A$, and the minimal polynomial of $\pm\sqrt{2018}$ over $\mathbb{Q}$ is $x^2 - 2018$. Hence $x^2 - 2018$ divides $p_A$ and $p_A$ is monic so we conclude $p_A(x) = x^2 - 2018$.
Hence $\sigma(A) = \{-\sqrt{2018}, \sqrt{2018}\}$. The spectral mapping theorem again gives
$$\sigma(A^{2018}) = \sigma(A)^{2018} = \{(-\sqrt{2018})^{2018}, \sqrt{2018}^{2018}\} = \{2018^{1009}\}$$
The trace is the sum of eigenvalues so
$$\operatorname{Tr} A^{2018} = 2\cdot 2018^{1009}$$
