Solution (source code)

= Solution

Put $t=\operatorname{tr}A=a+d$ and $\delta=\det A=ad-bc$. Direct <matrix> multiplication gives the two-dimensional <Cayley-Hamilton theorem> identity $A^2-tA+\delta I=0$. If $A^2=0$, <determinant> multiplicativity gives $\delta^2=0$, hence $\delta=0$. The identity then says $tA=0$. If $A=0$, its <trace> is zero; otherwise a nonzero entry forces $t=0$. Thus $d=-a$ and $bc=ad=-a^2$.

Conversely, those two scalar relations give $t=\delta=0$, so the same <Cayley-Hamilton theorem> identity implies $A^2=0$. Therefore
$$
\boxed{A^2=0\iff d=-a\text{ and }bc=-a^2.}
$$
This is the <square-zero criterion for a two-by-two matrix>. If $A^3=0$, <determinant> multiplicativity first gives $\delta^3=0$, hence $\delta=0$. Now $A^2=tA$ and $A^3=t^2A$. Either $A=0$, or a nonzero entry gives $t^2=0$ and hence $t=0$; in both cases $A^2=0$. The converse follows by multiplying $A^2=0$ by $A$. Consequently \b[$A^3=0\iff A^2=0$]. A nonzero <nilpotent matrix> of this size therefore has nilpotency index two.