wrong answer of solve function

2 views (last 30 days)
iridium
iridium on 14 Mar 2015
Edited: Star Strider on 14 Mar 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!

Accepted Answer

Star Strider
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
iridium
iridium on 14 Mar 2015
Thank you for your comment! Sorry for not being clear, I was talking about real solutions. Since solve function returns three real answers, I thought it solves for reals.
Star Strider
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

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!