wrong answer of solve function
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Star Strider
on 14 Mar 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 Comments
Star Strider
on 14 Mar 2015
Edited: Star Strider
on 14 Mar 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
More Answers (0)
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!