フィルターのクリア

Question about using fzero to find all real roots of a polynomial

3 ビュー (過去 30 日間)
Yianni
Yianni 2014 年 11 月 9 日
コメント済み: Roger Stafford 2014 年 11 月 9 日
I have the polynomial y = x^7-4.75*x^6+10.875*x^5-20.125*x^4+20*x^3+1.75*x^2-30*x+25 and I want to find not just one real root, but all three of them. I know for a fact that they are: -1.00, 1.25, and 2.50. I DO know how to find these values in many other ways, but I want to see if I can display all three of these real roots with this following program:
ff=[1 -4.75 10.875 -20.125 20 1.75 -30 25];
fun = @f;
x0 = 0;
B = fzero(fun,x0)
In particular, this yields B = -1 with x0 = 0 as my guess, but I want to find and display all three of them. Now the basic question: Is it possible to display all of the real roots of this polynomial using the fzero command?

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 11 月 9 日
編集済み: Azzi Abdelmalek 2014 年 11 月 9 日
ff=[1 -4.75 10.875 -20.125 20 1.75 -30 25];
out=roots(ff)
out=out(imag(out)==0)
%or
out=out(imag(out)<1e-5)
  1 件のコメント
Yianni
Yianni 2014 年 11 月 9 日
Thank you, this works, but I want to use the fzero method to do this and I want to see if I can get all three roots at once from one run of the program given the right values for x0 or my guess of the roots.

サインインしてコメントする。


Roger Stafford
Roger Stafford 2014 年 11 月 9 日
Is it possible to display all of the real roots of this polynomial using the fzero command?
The answer to this question is yes provided 1) that you furnish a sufficiently close initial estimate (x0) for each root, and 2) that none of the roots is a double root - that is, a point where the curve becomes only tangent to the x-axis instead of crossing it. To accomplish 1) it is helpful to make a graph of the polynomial.
Your 'fun' is not properly defined. I hope you used code other than what you show.
  2 件のコメント
Yianni
Yianni 2014 年 11 月 9 日
Yes there is more code. I just wanted to keep my question simple and to the point.
And yes I understand your response, but is there a way to make all three real roots appear as I run the program once? Maybe this is not possible strictly for the fzero method.
Roger Stafford
Roger Stafford 2014 年 11 月 9 日
No, 'fzero' does not function that way. For each initial estimate it will give only one answer, so to get three roots you would have to call on it with at least three different estimates. The 'roots' function is what you need to get all roots with one run.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOptimization についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by