<s>[INST] expanding and factoring in algebra Expanding very simple process, just open round brackets and multiply each with each for example
$(x-6)(x+3) = x^2 + 3x - 6x -18 = x^2 -3x -18$
Factoring is confused me a little for example I have $x^2 -3x -18$ I try to brute force all combinations in my mind and get the result like this
$(x-6)(x+3)$ 
Cold you please recommend some algorithm, how to find factoring in the easy way. 
Thanks.
 [/INST] Here's an algorithm to factor any quadratic (so $a\neq 0$):
\begin{align}ax^2+bx+c&=a\left(x^2+\frac{b}{a}x+\frac{c}{a}\right)\\&=a\left(\left(x+\frac{b}{2a}\right)^2-\frac{b^2}{4a^2}+\frac{c}{a}\right)\\&=a\left(\left(x+\frac{b}{2a}\right)^2-\frac{\Delta}{4a^2}\right) &(\Delta=b^2-4ac)\\&=a\left(\left(x+\frac{b}{2a}\right)^2-\left(\frac{\sqrt{\Delta}}{2a}\right)^2\right)\\&=a\left(x+\frac{b-\sqrt{\Delta}}{2a}\right)\left(x+\frac{b+\sqrt{\Delta}}{2a}\right)\end{align}
Note that we used $\sqrt{\Delta}$. If you know complex numbers, that shouldn't be a problem. If not, note that when $\Delta<0$, the equation $ax^2+bx+c=0$ has no solutions in $\mathbb{R}$ because it's equivalent to $$\left(x+\frac{b}{2a}\right)^2-\frac{\Delta}{4a^2}=0$$ which has clearly no solutions in $\mathbb{R}$ as $\left(x+\frac{b}{2a}\right)^2\ge 0$ and $-\frac{\Delta}{4a^2}>0$. Thus, if $\Delta<0$, you can't factor over $\mathbb{R}$.
</s>