Systematically solving $ax^2+bx+c>0$ and the like 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)&lt0$ and $(x+q)&lt0$, which simplify to $x&lt-p$ and $x&lt-q$, which is just $x&lt\min\{-p,-q\}$.
So the final answer is just $x\in\{x:x>\max\{-p,-q\}\text{ or }x&lt\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&lt0$ 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&lt0$). 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&lt0$ (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?

$$\text{If }~ f>0 ~\text{then}~ \begin{cases}
 x \in(-\infty,x_1) \cup (x_2,+\infty), & \text{if } a>0 ~\text{and}~ D>0 \\
 x \in (x_1,x_2), & \text{if } a&lt0 ~\text{and}~ D>0 \\
x \in \mathbb{R}, & \text{if } a>0 ~\text{and}~ D &lt 0 \\
x \in \mathbb{R} \backslash \{x_{1,2}\}  ,& \text{if } a>0 ~\text{and}~ D = 0 \\
x \in \emptyset & \text{if } a&lt0 ~\text{and}~ D \leq 0 
\end{cases}$$
where $x_{1,2}$ are solutions of $ax^2+bx+c=0$ , and $D=b^2-4ac$
