wrong answer of solve function
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
iridium
am 14 Mär. 2015
Bearbeitet: Star Strider
am 14 Mär. 2015
When I use "solve" to find the root for the equation 1/x+(1/x)^3==1, it returns 3 answers, even including one that's negative. Yet obviously this equation should have unique solution. How should I refine the answer? Thank you!
0 Kommentare
Akzeptierte Antwort
Star Strider
am 14 Mär. 2015
Why should it have a unique solution?
It’s a cubic equation, so it will have three roots. They do not have to be distinct roots, but there have to be three of them:
x =
1.4655712318767680266567312252199
- 0.23278561593838401332836561260997 - 0.79255199251544784832589830065336*i
- 0.23278561593838401332836561260997 + 0.79255199251544784832589830065336*i
2 Kommentare
Star Strider
am 14 Mär. 2015
Bearbeitet: Star Strider
am 14 Mär. 2015
My pleasure!
The solve function (I used vpasolve) doesn’t return three real answers, at least to your polynomial. It returns one real and two complex conjugate solutions.
It solves for all three solutions (as does the roots function if you cast your equation as a polynomial vector). Your equation does have a real solution: 1.46557123.
If you want only the real root, that’s easy enough:
p = [1 -1 0 -1];
pr = roots(p);
real_root = pr(imag(pr) == 0)
produces:
real_root =
1.4656
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Algebra finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!