anyone have a clue why roots([1,6,9]) outputs complex numbers?
2 ビュー (過去 30 日間)
古いコメントを表示
a = roots([1,6,9])
I was using roots to output the roots of the equation x^2+6x+9=0
this gives:
a =
-3.0000 + 0.0000i
-3.0000 - 0.0000i
when I use other values that create a quadratic equation with equal roots it seems to work fine, can someone explain to me why this is the case?
0 件のコメント
採用された回答
Walter Roberson
2019 年 10 月 28 日
If you switch to format long you will see non zero imaginary parts. Those are caused by roundoff problems with solving the Vandermode system to get the roots.
0 件のコメント
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Linear Algebra についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!