Find the range of $k$ for which the inequality $k\cos^2x-k\cos x+1\geq0 ,\forall x\in(-\infty,\infty)$ holds. Find the range of $k$ for which the inequality $k\cos^2x-k\cos x+1\geq0 ,\forall x\in(-\infty,\infty)$ holds.

This is an inequality involving trigonometric function $\cos x$ which varies from $-1$ to $1$.
If the question had been $kx^2-kx+1\geq 0$, i would have easily solved it,by using the discriminant property of the quadratics.If quadratic is positive then its discriminant is negative but i am not able to find the range of $k$ in this question. 
 A: Just another way: Equivalently, you have to find when 
$$4k(\cos x -\tfrac12)^2  \ge k-4$$
Now $\cos x \in [-1, 1] \implies (\cos x - \tfrac12)^2 \in [0, \tfrac94]$, and so $ k \in [-\frac12, 4]$.
A: This problem is equivalent to asking: on what condition will the quadratic function $p(t) = kt^2 - kt + 1$ have at most one root in the interval $t \in [-1,1]$? This is because if we put $\cos x = t$ then the only interval we actually have to care about is the range of $\cos x$. 
Let's analyse the behaviour of $p(t) $ in this interval. $p'(t) = 2kt - k$. Thus, we see that the extremum of the quadratic function is at $t = 1/2$. This is a fixed value even with the changing parameter $k$.
CASE I: Upward parabola or $k>0$. So if we add the condition that $p(1/2) \ge 0$, then the rest of the function will also certainly satisfy this, not only in the interval $[-1,1]$. Therefore $k/4 - k/2 + 1 \ge 0 \Rightarrow \boxed{0<k \le 4}$
CASE II: Downward parabola or $k<0$. Here, we know that the boundaries matter. Specifically, the boundary that is more far apart from the vertex will decide what happens (try drawing it). We thus want $p(-1) \ge 0 \Rightarrow 2k + 1 \ge 0 \Rightarrow \boxed{-1/2 \le k <0}$
And of course, the trivial case $k=0$ deserves a special mention.
