Solving trigonometric non-linear equations in MATLAB

7 次查看(过去 30 天)
Hi there, I'm trying to solve some non-linear simultaneous equations with trigonometric functions. They are of the form:
360.1265265*(cos(x)+cos(y)+cos(z))=220;
cos(3*x)+cos(3*y)+cos(3*z)=0;
cos(5*x)+cos(5*y)+cos(5*z)=0;
I am not getting any results. MATLAB says that the "last step was ineffective". Does this mean that my system is unsolveable or have I made a mistake in my code?

回答(4 个)

Star Strider
Star Strider 2018-4-14
Did you get acceptable results from whatever solver you used?
If so, the message likely means that parameter variations in the last step produced no significant change in the value of the objective function.

Walter Roberson
Walter Roberson 2018-4-14
syms x y z
eqn = [360.1265265*(cos(x)+cos(y)+cos(z))==220;cos(3*x)+cos(3*y)+cos(3*z)==0;cos(5*x)+cos(5*y)+cos(5*z)==0];
sol = solve(eqn);
vpa(sol.x)
vpa(sol.y)
vpa(sol.z)
vpa(subs(eqn, sol))
seems to check out to within round-off.
Maple is telling me there are 6 solutions instead of 16; I am not sure about the differences yet.
  2 个评论
Walter Roberson
Walter Roberson 2018-4-14
MATLAB is finding two basic solutions for each of x and y, and one basic solution for z, and is taking +/- each of the values. That would normally give you a total of 32 combinations but MATLAB is omitting half of them, and it turns out the half it omits do not work as solutions, so MATLAB is returning the 16 solutions that work with back substitution based upon these values.
Maple is finding a form that involves the solutions of the square root of an expression involving the root of a cubic. That gives a total of 6 solutions, all of which check out through back substitution.
Since MATLAB is only choosing index 1 of the cubic, but is finding combinations with multiple signs, and Maple is choosing all indexes of the cubic but not finding multiple signs in the same way, then it is possible that there might be up to 48 solutions by combining the arrangements.
Walter Roberson
Walter Roberson 2018-4-15
I confirmed through substitution that the equalities hold to within round-off for root #2, not just root #1.

请先登录,再进行评论。


Alex Sha
Alex Sha 2019-8-2
For the numerical calculation, there are infinitely solutions:
No. x y z
1 -0.555653038054963 5.06016630687609 -92.0589065440682
2 2.18887400768471 5.06016744417036 -0.555653606178796
3 -198.873056766125 6.83883834523503 -20.0725749218456
4 -1.22301993800355 -5.72753422997246 -2.18887325095859
5 57.7716867649272 -26829.7569146949 5317.76364293755
6 -11.3210204152338 -8143.53902207035 22.9542361856632
7 74.1752046858574 0.555653038066782 35.5102387794528
8 -26424.8885289337 -36.4760928427902 -73507.5405617321
9 50.8194489584878 -1.22404524627458 4.09440432429833
10 -10.3774816037934 -6.83884555233292 23.9097400990646
  1 个评论
Walter Roberson
Walter Roberson 2019-8-8
Ah, I just went back to Maple and tried again there. Maple finds 6 sets of real-valued solutions, and each set involves 3 booleans and 3 arbitrary integers. You could expand the booleans out to get 6*8 = 48 sets of real-valued solutions, each involving 3 arbitrary integers. But of course that is the same thing as saying that there are infinite solutions.
The arbitrary integers appear to be multiplying by 2*Pi.

请先登录,再进行评论。


Nurahmed
Nurahmed 2019-11-21
Did you find the solution to your problem? I have the same equation, but couldn't solve in MATLAB.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by