To find a method for factorising an expression such as \(\mathbf {x^2 + 5x + 6}\), look at how that expression was arrived at by expanding two brackets.
If the mention of algebra conjures bad memories of math classes, a Python library called SymPy could change your mind about the subject. With SymPy, algebraic operations become easier than tedious ...