Wrong symbolic solution for trigonometry

2 次查看(过去 30 天)
syms x
solve(sin(x)/cos(x)==-3.0)
ans = 
and
syms x
solve(tan(x)==-3.0)
ans = 
Produces different result instead of Wolfwram and ti-89 who produces same result for these operations.
  4 个评论
Torsten
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
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)
xsol = 
vpa(sin(xsol)./cos(xsol))
ans = 
vpa(xsol)
ans = 
Now, compare that result to
atan(-3) + [pi,0]
ans = 1×2
1.8925 -1.2490
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
Walter Roberson 2023-11-8
syms x
sol = solve(sin(x)/cos(x)==-3.0)
sol = 
sola = rewrite(sol, 'atan')
sola = 
simplify(sola, 'steps', 100)
ans = 
simplify(sola, 'steps', 5000)
ans = 
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.

更多回答(1 个)

Les Beckham
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)
s1 = 
format long
double(s1)
ans = 2×1
1.892546881191539 -1.249045772398254
syms x
s2 = solve(tan(x)==-3.0)
s2 = 
double(s2)
ans =
-1.249045772398254
  14 个评论
Walter Roberson
Walter Roberson 2023-11-8
syms x
eqn = sin(x)/cos(x)==-3.0
eqn = 
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)
sol = struct with fields:
x: [2×1 sym] parameters: k conditions: [2×1 sym]
simplify(sol.x, 'steps', 500)
ans = 
sol.conditions
ans = 
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 CenterFile Exchange 中查找有关 Calculus 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by