Let $n$ be a positive integer. Let $A$ be a square matrix. Let $I$ be the identity matrix with the same size as $A$.
I want to simplify $f_n(A) = I + A + A^2 + A^3 + A^4 + \cdots + A^n$
Now I know that for a complex number $z$ we have $1 + z + z^2 + z^3 + z^4 + \cdots + z^n= \dfrac{z^{n+1}-1}{z-1}$ when $z$ is not equal to $1$ ... and even if $z=1$ then by computing the limit we get the right answer : $n+1$. This is well known as the geometric series and leads to the so-called q-analogue ideas.
But for matrices $A$ this does not work if the determinant of $A-I$ is $0$ , because then $\dfrac{A^{n+1} - I}{A - I}$ is not well defined.
This frustrates me a lot. Now I have heard about pseudoinverses but I do not know much about them and I even wonder if they can be of any help here.
I tried some things from calculus and continued fractions too, but nothing worked for me.
I also considered this problem for infinite (square) matrices but I assume that is analogue to this problem and so is its solution.