sym/solve: input order relevant for solution success?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
when I use the symbolic toolbox to solve some equations, I stumbled upon a case where the specified order of input variables influences whether the toolbox can successfully solve the equation or not. From the documentation of sym/solve and related answers, I could not find any indication that this should take place. MWE see below.
My question is - is this a bug that should be reported? If not, how can I systematically find successful orders of variables except by brute force (for my application, there will generally be more than 2 input variables)?
I initially had the problem using Matlab 2021a on Windows and it also seems to appear in this 2021b web version.
Thank you very much.
MWE (Harmonic Balance equations for Duffing oscillator - edited to make it more minimal while retaining the effect):
syms a b gamma omega real positive
syms C psi real
assumeAlso(C > 0);
assumeAlso(psi >= 0);
assumeAlso(psi < 2*pi);
B = [-0.7500*b*cos(psi)*C^3 + cos(psi)*C*omega^2 - a*sin(psi)*C*omega - cos(psi)*C + gamma;...
0.2500*C*(4*sin(psi) - 4*omega^2*sin(psi) - 4*a*omega*cos(psi) + 3*C^2*b*sin(psi))];
% successful attempt using [C; psi]
sol1 = solve(B, [C; psi], "Real", true, "ReturnConditions", true)
% unsuccessful attempt using [psi; C; D]
sol2 = solve(B, [psi; C], "Real", true, "ReturnConditions", true)
댓글 수: 0
채택된 답변
Star Strider
2021년 12월 15일
syms a b gamma omega real positive
syms C psi real
assumeAlso(C > 0);
assumeAlso(psi >= 0);
assumeAlso(psi < 2*pi);
B = [-0.7500*b*cos(psi)*C^3 + cos(psi)*C*omega^2 - a*sin(psi)*C*omega - cos(psi)*C + gamma;...
0.2500*C*(4*sin(psi) - 4*omega^2*sin(psi) - 4*a*omega*cos(psi) + 3*C^2*b*sin(psi))];
B = simplify(B, 500)
% successful attempt using [C; psi]
sol1 = solve(B, [C; psi], "Real", true, "ReturnConditions", true)
% unsuccessful attempt using [psi; C; D]
sol2 = solve(B, [psi; C], "Real", true, "ReturnConditions", true)
.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!