Matlab gave wrong answer while Mathematica gave true answers, why?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146975/image.png)
0 commentaires
Réponse acceptée
Mike Hosea
le 30 Jan 2015
I don't see where you checked any of the answers in a valid way. To check MATLAB's answer, you severely rounded it first and then checked. This equation is too sensitive for that, at least in a neighborhood of the solution that MATLAB happened to find.
>> syms x
>> digits(80)
>> solve(x.^sin(x) + 8 == cot(47*log(x) + exp(x)))
Warning: Cannot solve symbolically. Returning a numeric approximation instead.
> In solve (line 305)
ans =
98.395408219472484524557308589774849406939634099330937204374930424512026883616545
>> x = ans
x =
98.395408219472484524557308589774849406939634099330937204374930424512026883616545
>> x.^sin(x) + 8 - cot(47*log(x) + exp(x))
ans =
-0.0000000000000000000000000000000000000000000039330287842258440407834931520866339281329156271877649321572401303526533554381423
>> x.^sin(x) + 8
ans =
8.0207252854535032324512918938000052606517288839589889758585840803139163993208885
>> cot(47*log(x) + exp(x))
ans =
8.0207252854535032324512918938000052606517288878920177600844281210974095514075224
As you an see, the solution is a reasonable one. However, if we round to 6 significant digits
>> x = vpa('98.3954',80)
x =
98.3954
>> x.^sin(x) + 8 - cot(47*log(x) + exp(x))
ans =
9.3384410716385311286176401501200638006304113096004241102191653019034016905187388
This is no longer a good solution.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!