Wrong symbolic solution for trigonometry
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Torsten
2023-11-7
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
2023-11-7
编辑:John D'Errico
2023-11-7
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
采纳的回答
Walter Roberson
2023-11-8
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 个评论
更多回答(1 个)
Les Beckham
2023-11-7
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 个评论
Walter Roberson
2023-11-8
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!