wrong answer of solve function

2 visualizzazioni (ultimi 30 giorni)
iridium
iridium il 14 Mar 2015
Modificato: Star Strider il 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!

Risposta accettata

Star Strider
Star Strider il 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 Commenti
iridium
iridium il 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 il 14 Mar 2015
Modificato: Star Strider il 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

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by