How to find only positive root of a polynomial

조회 수: 16 (최근 30일)
Atom
Atom 2013년 4월 16일
How to find only positive root of a polynomial equation x^4+7*x^2-A=0 where A is varying from 1:.1:3. If rr is the positive real root, then find rr/(rr+1) for each case.
for A=1:.1:3
poly = [1 0 7 0 A];
R = roots(poly);
if isa(R,'complex') && (R<=0)
continue;
else
R/(R+1)
end
Please correct the code.
  댓글 수: 2
Matt J
Matt J 2013년 4월 16일
What do you mean by "without solving a polynomial equation"? A root is, by definition, the solution to such a problem.
Atom
Atom 2013년 4월 16일
Yes. you are right. Please ignore the words "without solving".

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2013년 4월 16일
편집: Matt J 2013년 4월 16일
By the quadratic formula, the largest solution for x^2 is
x^2 = (-7+ sqrt(49+4*A))/2
For positive A, this will always be positive. You can then get a positive root for x by doing
x = sqrt( (-7+ sqrt(49+4*A))/2 )
I don't know if this satisfies your requirement "without solving a polynomial equation". It doesn't seem possible that you meant this literally (see my comment above).
  댓글 수: 2
Atom
Atom 2013년 4월 16일
Please ignore the words "without solving". Please modify the above code so that I can use it for general one.
Matt J
Matt J 2013년 4월 16일
편집: Matt J 2013년 4월 16일
for A=1:.1:3
b=poly(3);
a=poly(1);
R = sqrt( (-b+ sqrt(b^2+4*A*a))/2/a );
R/(R+1)
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by