Solving trigonometric non-linear equations in MATLAB
조회 수: 1 (최근 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?
댓글 수: 0
답변 (4개)
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.
댓글 수: 0
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
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
2018년 4월 15일
I confirmed through substitution that the equalities hold to within round-off for root #2, not just root #1.
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
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
2019년 11월 21일
Did you find the solution to your problem? I have the same equation, but couldn't solve in MATLAB.
댓글 수: 1
Walter Roberson
2019년 11월 21일
There are infinite solutions for those equations, with 48 families of solutions involved.
참고 항목
카테고리
Help Center 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!