# How to tell if a function generates a positive value or a negative value?

Let's say I have a function as: $$f(x) = ax^5 + bx^4 + cx^3 + dx^2 + ex + h.$$

How to tell if $f(x)$ is positive or negative given different values of $a,b,c,d,e,h,$ and $x$ without actually evaluating the sum and checking it?

• This is too broad. For a specific example-say you had $a$~$x_0$ , $x_0\lt \lt 0$ and $b,c$ much smaller than $a$ you could guess that $f(x_0)$ would be negative or vice versa..Or if the coefficients of the odd terms are all zero you can see that there is a lower bound dependent on $h$..But in general you can't just by looking at it – MathematicianByMistake Oct 27 '17 at 11:36
• Is there even any need to make it simpler? For a polynomial like this you just compute it the Horner way $f(x)=((((ax+b)x+c)x+d)x+e)x+h$. If you are only interested in the sign and you are afraid of number getting to big, you can also do it backwards: $((((h/x+e)/x+d)/x+c)/x+b)/x+a$ and take its sign if $\mathrm{sgn}(x)=1$ or flip it if $\mathrm{sgn}(x)=-1$. – M. Winter Oct 27 '17 at 11:40
• If you want to check it for many different $x$ you could first try to calculate the zeros of $f$, say $x_1< ... <x_k$ with $k$ at most $5$. If $a>0$, then $\lim_{x\rightarrow -\infty}f(x)= -\infty$ and thus $f(x)$ will be negative for $x<x_1$, $f(x)>0$ for $x_1<x<x_2$ and so on, where the sign changes at every zero. I.e. in the end you would only have to determine in which interval a given $x$ lies. – Jan Bohr Oct 27 '17 at 11:47

Once you know all real zeros $x_1<\cdots<x_n$ (represented with multiplicities) for some $n\in\{1,3,5\}$ and, say, $a>0$ you know that

$$f(x)\begin{cases} <0 & \text{for x<x_1 or x_k<x<x_{k+1} for even k}\\ =0 & \text{for x=x_k for some k}\\ >0 & \text{for x>x_k or x_k<x<x_{k+1} for odd k} \end{cases}.$$

If $a<0$ you flip the $<$ and $>$ case.

Example. Take the polynomial

\begin{align} f(x)&=(x-1)(x-2)(x-3)(x-4)(x-5)\\ &=x^5-15x^4+85x^3-225x^2+274x-120. \end{align}

Because of the way in which I gave the polynomial, we know the zeros $x_i=i$ for $i=1,...,5$.

And you can see that the function is indeed positive on the intervals

$$(x_1,x_2), (x_3,x_4) \text{ and } (x_5,\infty)$$

$$(-\infty,x_1), (x_2,x_3) \text{ and } (x_4,x_5)$$

which end in odd numbered zeros.

Honestly, polynomials are easy enough to compute (most of the time, easier than computing the zeros). You can use a Horner like scheme to do it: set $f_0=a$ and compute

$$f_1=xf_0+b,\quad f_2=xf_1+c,\quad f_3=xf_2+d,\quad f_4=xf_3+e,\quad f_5=xf_4+h$$

and this gives you the result $f(x)=f_5$. If you are afraid that the numbers are getting too big, then you can do it the other way around and only extract the sign like this: set $f_0=h$ and compute

$$f_1=f_0/x+e,\quad f_2=f_1/x+d,\quad f_3=f_2/x+c,\quad f_4=f_3/x+b,\quad f_5=f_4/x+a.$$

If your $x$ was positive, then $\mathrm{sign}(f(x))=\mathrm{sign}(f_5)$, otherwise it is the flipped sign.

• Could you please explain the f(x) intervals with an example. I am getting confused with even and odd thing. Thanks. – user3243499 Oct 27 '17 at 12:20
• @user3243499 Added an example. I hope it helps. – M. Winter Oct 27 '17 at 12:33

I think it's pretty straight forward to do that in the case of familiar 2nd degree polynomial functions, but I highly doubt the possibility of what you're asking for, unless one is a specialist and has developed personal techniques of problem solving. Otherwise you would just use the tools of calculus and analysis.