How to find the maximum or minumum of a function, if the roots of the first derivatice are non real? Lets say that I have this function $ f(x) =  x^3/3 + x - 1$ so  $f'(x)=x^2+1$ therefore the roots are non real so how can I find the maximum or minimum of the function?

If the roots of the derivative are non-real and the derivative is continuous, then the derivative is either positive or negative everywhere (by IVT ; also note that even if this is not true, by Darboux's theorem the derivative anyway has the IVT). Therefore, the function itself is either strictly increasing or strictly decreasing everywhere.
In this case, the derivative $x^2+1$ is positive (and in fact $\geq 1$ everywhere), so the function is strictly increasing everywhere. Therefore, the maximum and minimum of this function on $\mathbb R$ are not attained. On any bounded set $A$, the supremum and infimum of $f$ exist and are given by $f(\sup A)$ and $f(\inf A)$ respectively.
