Is this algorithm to solve inequalities, correct? My book says:

If P(x) and Q(x) are polynomials, then the inequalities regarding $\frac{P(x)}{Q(x)}$ can be solved by ALGORITHM:
$(1)$Plot the critical points on number-line. Note $n$ critical points will divide the number line in $n+1$ regions.
$(2)$ In the right most region, the expression will be positive and in other regions it will be alternatively negative and positive. So, mark positive sign int the right most region and than mark alternatively negative and positive signs in the remaining regions.

I have seen some examples following and contradicting the algorithm. some of the examples are:
$(1)$Example which follows the algorithm: $$f(x)=\frac{4x^2+1}{x}>0$$ In the example I get critical points $-1/2$ and $1/2$.
Number line
so our inequality is positive on $(-\infty,\frac{1}{2})\cup(\frac{1}{2},\infty)$
$(2)$ Example which contradicts :$$f(x)=(\frac{x}{2+x})^2\frac{1}{1+x}>0$$
here I get critical points $-1$,$0$. But the Algorithm doesn't give me correct result.Numberline
The actual solution is:$(-1,0)\cup(0,\infty)$ here we neglected $zero$ than ploted the regions, but WHY?
$(3)$In another case, $zero$ is a solution and we take into account $zero$ when plotting regions.$$f(x)=x^4-2x^2>0$$
solution is: $(-1,0)\cup(1,\infty)$
Someone Please Explain. the algorithm and where am i wrong in understanding my book.

Here is a method to determine which regions a rational function $f(x)=\frac{P(x)}{Q(x)}$ is strictly positive. 


*

*First you find the critical points $P(x)$ and $Q(x)$ and corresponding multiplicities.

*Break the number line up by the critical points you found in $1$. 

*Look at the leading coefficients of $P(x)$ and $Q(x)$. If they share the same sign then $f(x)$ is positive in the right most region, otherwise is is negative.

*Working from right to left, once you go over a critical point, if the multiplicity is odd, then the sign of $f(x)$ changes. If it is even, then the sign of $f(x)$ remains unchanged. If it is a critical point of $Q(x)$ and even we also include the critical point in the region.


Note, if $P(x)$ and $Q(x)$ share a critical point, do as above but look at the difference in multiplicities to determine if odd or even.
