Solve equation with 2 unknowns using solve

3 ビュー (過去 30 日間)
Jane Low
Jane Low 2021 年 6 月 30 日
コメント済み: Jane Low 2021 年 6 月 30 日
How to solve the two equation below?
cos(3a)+cos(3b)=0
cos(a)+cos(b)=1.6
Ans:
a = 7.6 degree = 0.132645 rad
b = 52.4 degree = 0.9145525 rad
Hereby my code
syms a b
sol = solve(cos(3*a)+cos(3*b)==0, cos(a)+cos(b)==1.6,[a,b])
sol.a
sol.b
and it gave me this
In sym/solve>warnIfParams (line 478)
In sym/solve (line 357)
sol =
struct with fields:
a: [1×1 sym]
b: [1×1 sym]
ans =
z
ans =
z1

採用された回答

Walter Roberson
Walter Roberson 2021 年 6 月 30 日
syms a b
sol = vpasolve(cos(3*a)+cos(3*b)==0, cos(a)+cos(b)==1.6,[a,b],[0, pi; 0, pi])
sol = struct with fields:
a: [1×1 sym] b: [1×1 sym]
sol.a
ans = 
0.91660896848843414923150917923804
sol.b
ans = 
0.13058858270816359692270528185513
Your equations are symmetric in your variables, so this is an equivalent solution to what you posted.
  1 件のコメント
Jane Low
Jane Low 2021 年 6 月 30 日
Thank you :)

サインインしてコメントする。

その他の回答 (1 件)

Alan Stevens
Alan Stevens 2021 年 6 月 30 日
There are an infinite number of solutions! Restrict the range. One possibility is as follows
bfn = @(a) acos(1.6-cos(a));
fn = @(a) cos(3*a)+cos(3*bfn(a));
a0 = 0.1; % initial guess
a = fzero(fn, a0);
b = bfn(a);
disp([a, b])
0.1306 0.9166
disp(rad2deg([a,b]))
7.4822 52.5178
  1 件のコメント
Jane Low
Jane Low 2021 年 6 月 30 日
Thank you :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEquation Solving についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by