Wrong symbolic solution for trigonometry
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Boris
le 7 Nov 2023
Commenté : Walter Roberson
le 8 Nov 2023
syms x
solve(sin(x)/cos(x)==-3.0)
and
syms x
solve(tan(x)==-3.0)
Produces different result instead of Wolfwram and ti-89 who produces same result for these operations.
4 commentaires
Torsten
le 7 Nov 2023
Both are correct as you can see when tan is applied to the results.
As you can see from the calculation, -log(-sqrt(-16/5-12/5*i)/2)*i equals atan(-3) in the interval [0 pi], -log(sqrt(-16/5-12/5*i)/2)*i equals atan(-3) in the interval [-pi 0].
John D'Errico
le 7 Nov 2023
Modifié(e) : John D'Errico
le 7 Nov 2023
No. Both solutions returned are absolutely valid.
syms x
xsol = solve(sin(x)/cos(x)==-3.0)
vpa(sin(xsol)./cos(xsol))
vpa(xsol)
Now, compare that result to
atan(-3) + [pi,0]
As you can see, both are perfectly valid, mathematically correct solutions.
solve generated two solutions as it was used there, probably because sin(x)/cos(x) can reduce to an implicit quadratic polynomial problem. So it looks like solve did the transformation, then solved the resulting quadratic, with the result being two valid solutions from the general solution locus:
atan(-3) + k*pi
Réponse acceptée
Walter Roberson
le 8 Nov 2023
syms x
sol = solve(sin(x)/cos(x)==-3.0)
sola = rewrite(sol, 'atan')
simplify(sola, 'steps', 100)
simplify(sola, 'steps', 5000)
At the moment I do not know why it is able to identify atan(3) in the first row at the bottom, but not identify atan(3) in the second row, even though with steps 100 it was able to identify that the two are the same except + pi for one of them.
0 commentaires
Plus de réponses (1)
Les Beckham
le 7 Nov 2023
It looks like your second solve construct only returns one of the solutions. Someone who knows the symbolic toolbox better than I do may be able to explain why.
syms x
s1 = solve(sin(x)/cos(x)==-3.0)
format long
double(s1)
syms x
s2 = solve(tan(x)==-3.0)
double(s2)
14 commentaires
Walter Roberson
le 8 Nov 2023
syms x
eqn = sin(x)/cos(x)==-3.0
LS = lhs(eqn);
RS = rhs(eqn);
fplot([LS, RS], [-2*pi 2*pi])
Each intersection of a blue line with the red line is a solution. You can see that there are an infinite number of solutions.
sol = solve(eqn, 'returnconditions', true)
simplify(sol.x, 'steps', 500)
sol.conditions
Infinite number of solutions π apart.
MATLAB probably could have generated the unified series but that does not mean it was wrong to generate the forms that it did generate. It is a common approach to analyze in terms of full cycles
Voir également
Catégories
En savoir plus sur Calculus dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!