Problem Statement:-
If $f(x)=\left|\dfrac{x^2+ax+1}{x^2+x+1}\right|$, then find the values of $a$ for which $\forall x\in\Bbb{R^+}, \;f(x)\lt3,\;$ and $f(x)\gt3$ for at least one negative real $x$.
Attempt at a solution:-
As $x^2+x+1\gt0$, $\forall x\in\Bbb{R}$ hence $$f(x)=\dfrac{\left|x^2+ax+1\right|}{x^2+x+1}$$
Now, consider the following cases:-
Case 1:- If $\qquad x^2+ax+1\gt 0$, then $$f(x)=\dfrac{x^2+ax+1}{x^2+x+1}$$
Let $g(x)=2x^2+(3-a)x+2$
For $x^2+ax+1\gt 0$ consider the following subcases:-
Sub Case-1:- $D(x^2+ax+1)\lt0$ which implies that the $\forall x\in\Bbb{R}.\;\;(x^2+ax+1\gt0)$.
So, from the conditions that the question wants to be satisfied, i.e. $\forall x\in\Bbb{R^+}.\;(f(x)\lt3)\;$ and $\exists x\lt0.\;(f(x)\gt3)$, we get
$$\forall x\gt0.\;(g(x)=2x^2+(3-a)x+2\gt0)\\ \exists x\lt0. \;(g(x)=2x^2+(3-a)x+2\lt0)$$
As the situation is same as that in the second sub case, lets save some work here we get $$a\lt3\\ a\in(-\infty,-1)\cup(7,\infty)$$
So, combining all the inequalities in this sub case we get, $$\boxed{a\in(-2,-1)}$$
Sub Case-2:- Discriminant of $x^2+ax+1$ is greater than $0$. So, $|a|\gt2$ and $$x\in\left(-\infty,\dfrac{-a-\sqrt{a^2-4}}{2}\right)\cup\left(\dfrac{-a+\sqrt{a^2-4}}{2},\infty\right)$$
So, $$f(x)=\dfrac{x^2+ax+1}{x^2+x+1}$$
So, as the question asks for $\forall x\gt0.\; (f(x)\gt3)$, which on simplifying gives $$g(x)=2x^2+(3-a)x+2\gt0$$
We see that $g(0)\gt 0$, so either both roots are either positive or negative. As the question also demands for the condition $\exists x\lt0.\; (f(x)\lt3)$, so the both roots of $g(x)$ need to be negative.
So, $g^\prime(0)\gt 0\implies 3-a\gt0 \implies a\lt3$
Also, $D(g(x))\gt0\implies (a+1)(a-7)\gt0\implies a\in(-\infty,-1)\cup(7,\infty)$
And since $|a|\lt2$, the common interval for all the inequalities comes out to be $\boxed{a\in(-\infty, -2)}$
To conclude this case we get that $\boxed{a\in(-\infty,-2)\cup(-2,-1)}$
Case-2:- If $x^2+ax+1\lt0$, then
$$f(x)=-\dfrac{x^2+ax+1}{x^2+x+1}$$
Also, $D(x^2+ax+1)\gt0\implies a^2-4\gt0\implies |a|\gt2\implies a\in(-\infty,-2)\cup(2,\infty)$
Also, the bounds of $x$ in which the given inequalities are to be examined is $$x\in\left(\dfrac{-a-\sqrt{a^2-4}}{2},\dfrac{-a+\sqrt{a^2-4}}{2}\right)$$
Let $h(x)=4x^2+(3+a)x+4$ (assumed it here itself to reduce the mess while solving the inequality in this case).
So, from $\forall x\gt0.\;(f(x)\lt3)$ and $\exists x\lt0.\;(f(x)\gt3)$, we get $$\forall x\gt0.\;(h(x)=4x^2+(3+a)x+4\gt0)\\ \exists x\lt0.\;(h(x)\lt0)$$
As, we can see that $h(0)\gt0$, so same as the last case we conclude that either both the roots are either negative or are either positive. But as $\forall x\gt0.\; (h(x)\gt0)$, so $h^\prime(0)\gt0\implies a\gt-3$.
Lastly as the roots need to be real, so $$D(h(x))\gt0\implies (a-5)(a+11)\gt0\implies a\in(-\infty, -11)\cup(5,\infty)$$
From all the inequalities in this case we get
$$\boxed{a\in(5,\infty)}$$
My deal with the question:-
I am having trouble examining the bounds in which $a$ should be so that interval in which $x$ can be taken also is included in the bounds of $a$. To be more clear how do I incorporate the bounds in which the $x$ has been defined for $x^2+ax+1\lessgtr0$ depending upon the case being considered.