# How can I solve a system of non-linear equations with complex numbers?

7 ビュー (過去 30 日間)
Owen Bennett 2022 年 9 月 21 日
コメント済み: Owen Bennett 2022 年 9 月 21 日
I'm in Mechanics of Machinery and I'm trying to use Matlab to help solve these equations:
eq1 = 0 == 2*cosd(240) + 10*cosd(theta) -r;
eq2 = 0 == 2*1i*sin(120) + 10*1i*sind(theta);
I need to solve for 'r' and 'theta'. I'm not great at coding but solving by hand is out of the question. Any help would be greatly appreciated. Thanks

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

### 採用された回答

John D'Errico 2022 年 9 月 21 日

WHY NOT TRY IT? Assuming you really intended for the second equation to use sind(120)...
syms theta r
eq1 = 0 == 2*cosd(240) + 10*cosd(theta) -r;
eq2 = 0 == 2*1i*sind(120) + 10*1i*sind(theta);
sol = solve(eq1,eq2,'returnconditions',true)
sol = struct with fields:
r: [2×1 sym] theta: [2×1 sym] parameters: k conditions: [2×1 sym]
sol.r
ans =
sol.theta
ans =
sol.conditions
ans =
So k is any integer. There are of course infinitely many solutions, though the primary solutions happen at k=0. If you want actual numbers...
vpa(sol.r)
ans =
vpa(sol.theta)
ans =
And finally, assuming you just want the principle solutions, in double precision...
format long g
double(subs(sol.r,0))
ans = 2×1
8.8488578017961 -10.8488578017961
double(subs(sol.theta,0))
ans = 2×1
-9.97422179440135 189.974221794401
Not that difficult to solve by hand, but this was really pretty easy. How would you solve it by hand?
First, recognize that these have simple numerical values.
cosd(sym(240))
ans =
sind(sym(120))
ans =
So now we can write the two equations with those numbers substituted.
0 == 2*(-1/2) + 10*cosd(theta) - r
0 == 2*1i*sqrt(3)/2 + 10*1i*sind(theta)
I'll also solve directly for r, since r appears in only one place. And in the second equation, get rid of the imaginary multiplier, as it appears on both terms.
r == -1 + 10*cosd(theta)
0 == sqrt(3) + 10*sind(theta)
Already, that is getting pretty simple. We might wish to solve for theta from the second equation now, as:
theta = asind(-sqrt(3)/10)
but that is only one of the two primary solutions. If we wish to write all solutions, we would quickly arrive at the same result given by solve.
##### 3 件のコメント表示非表示 2 件の古いコメント
Owen Bennett 2022 年 9 月 21 日
Thank you very much!

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

### カテゴリ

Find more on Operations on Strings in Help Center and File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by