Below is the problem as stated in Putnam and Beyond:
Let $A$ and $B$ be tw0 $n\times n$ matrices that commute and such that for some positive integers $p$ and $q$, $A^p=I_n$ and $B^q=O_n$. Prove that $A+B$ is invertible, and find its inverse.
In the following I will give my "solution" and I would be very grateful if you could either verify that it is correct or else tell me where I've gone wrong. I would also greatly appreciate any comments on my proof writing.
We start of by making the assumption $p>q$. Note that in order for this argument to be correct, $p$ and $q$ may need to be interchanged. It follows that $A^p+B^p=I_n$. The expression on the left can be factored as $(A+B)(A^{p-1}+BA^{p-2}+...+B^{p-1})= I_n$. From this we see clearly that $A+B$ is invertible, its inverse being $(A^{p-1}+BA^{p-2}+...+B^{p-1})$. My argument is concluded.
Thank you!
Your argument is right when $p\ge q$ because $$B^q=0\to B^p=0 \text{ and } (-B)^p=0$$also we know that $A^p-(-B)^p$ is divisible by $A-(-B)=A+B$ so your conclusion is right in this case. Now let $p<q$. Also since all the eigenvalues of $A^p$ are $1$ so all the eigenvalues of $A$ are roots of $1$ and non-zero and $A$ is invertible which means that$$A^q=A^{q-p}$$therefore $$A^{q-p}=A^q-(-B)^q=(A+B)(A^{q-1}-\cdots \pm B^{q-1})$$therefore $$(A+B)(A^{q-1}-\cdots \pm B^{q-1})(A^{q-p})^{-1}=I$$or $$(A+B)^{-1}=\left((A^{q-1}-\cdots \pm B^{q-1})(A^{q-p})^{-1}\right)^{-1}=A^{q-p}(A^{q-1}-\cdots \pm B^{q-1})^{-1}$$