Given the function $$ f:\mathbb{R}\rightarrow \mathbb{R}^{n\times n}\\ f(x)=x^2I +xA+B $$ where $I$ is the identity and $A$ and $B$ are given matrices. For which values of $x$ is the resulting matrix singular?
It would of course be easy if $A$ and $B$ commuted but I would like to have an answer for the most general case possible.