tags:

views:

48

answers:

2

I have a polynomial, y(x)=a0+a1*x^1+a2*x^2+a3*x^3+a4*x^4+......+an*x^n. of the degree n, where ai is a real number.

My question is, is there a function in matlab that I can use to find the range of x for all y(x)>0?

A: 

No there is no explicit function that does this. However, as long as you desire a numerical solution, it is possible.

You can solve for the roots of y(x). (hint: roots)

What happens between any pair of roots? What happens above and below the largest and smallest real roots? What can you do with any roots that are complex?

woodchips
@woodchips, that is my solution as well ( just in case there's no built in function in Matlab). But I would expect Matlab has built-in functions for something as straightforward and wide-used as this.
Ngu Soon Hui
Why do you think this is so useful? Just because you want to do something does not make it widely useful, and it is rather simple to do. Personally, I've never had any desire to do that specific thing. The virtue of a language like MATLAB is you can extend it to fit the class of problems you tend to see. So write your own m-file that does this. Document it well. Then you can use it whenever you wish. If it is any good, then post it on the file exchange so that others can use it too, here: http://www.mathworks.com/matlabcentral/fileexchange/
woodchips
+1  A: 

I can't think of a function but I would do the following:

  1. Find the roots of your polynomial with roots.
  2. Find the gradient of y(x) at the smallest root.
  3. If it is increasing, then it will decrease at the next root and vice versa.
  4. Now you can create intervals where y(x) is positive.

Additionally, if you want visualize your answers, you can plot your polynomial with ezplot. E.g. ezplot('5*x^3 + 4*x^2 + 3*x + 2');

Jacob
This algorithm is not complete. It fails to say what to do with complex roots, as a sign change in the function will not happen there. It also may fail on multiple roots, where the derivative will be zero.
woodchips

related questions