We know that if $ax^2+bx+c=0$ with $a\ne0$, then the solution(s) can be given by the quadratic formula $x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}$.
But what if we want to solve a quadratic inequality such as $ax^2+bx+c>0$?
First, if $ax^2+bx+c$ can be factored into $(x+p)(x+q)$, then we have $(x+p)(x+q)>0$, so we know:
- Both $(x+p)$ and $(x+q)$ are positive; or,
- Both $(x+p)$ and $(x+q)$ are negative.
For the first case, we have $(x+p)>0$ and $(x+q)>0$, which simplify to $x>-p$ and $x>-q$, which is just $x>\max\{-p,-q\}$.
For the second case, we have (x+p)<0 and (x+q)<0, which simplify to x<-p and x<-q, which is just x<\min\{-p,-q\}.
So the final answer is just x\in\{x:x>\max\{-p,-q\}\text{ or }x<\min\{-p,-q\}\}.
Next suppose $\sqrt{b^2-4ac}$ is imaginary. Then we have two cases:
- $a>0$ so that the graph of $f(x)=ax^2+bx+c$ is completely above the $x$-axis. Then all real numbers are solutions to $ax^2+bx+c>0$.
- a<0 so that the graph of $f(x)=ax^2+bx+c$ is completely below the $x$-axis. Then no real number is a solution.
Now suppose $ax^2+bx+c$ does not factor. Then "force-factor" using the quadratic equation into $(x-\frac{-b + \sqrt{b^2-4ac}}{2a})$ and $(x-\frac{-b - \sqrt{b^2-4ac}}{2a})$ and repeat the steps above. Another way to think about this: since we are guaranteed that $\sqrt{b^2-4ac}$ is real (we took care of the imaginary cases already), we can divide the real number line into three intervals: $(-\infty,\frac{-b - \sqrt{b^2-4ac}}{2a})$, $(\frac{-b - \sqrt{b^2-4ac}}{2a},\frac{-b + \sqrt{b^2-4ac}}{2a})$, and $(\frac{-b + \sqrt{b^2-4ac}}{2a},+\infty)$ (or the other way round if a<0). Then check some number in each interval, and if that number is greater than $0$, then include that entire interval in the final answer. Otherwise don't include it. We can also do this by taking the outer two intervals when $a>0$ and taking the middle interval when a<0 (I think).
Questions: (1) Is this approach correct? (2) If so, is there a more efficient way to do it, i.e., how might one go about programming an algorithm for this type of problem?