Simplifying solution to algebraic system of equations

1 回表示 (過去 30 日間)
Aleem Andrew
Aleem Andrew 2020 年 4 月 20 日
コメント済み: Aleem Andrew 2020 年 4 月 21 日
The following code outputs a value for a and b with respect to the imaginary number i but the output is not fully simplified with the complex and real part separately factored. Is there a way to modify the code so the real and imaginary parts are separate?
syms X Y Q t w v a b z c N theta m L g
eq1 = b-a == 10*(cosd(45)+i*sind(45));
eq2 = 3 == (a-b)/4+a*i/3 + b/(6*i)+b/12;
sol = solve([eq1 eq2], [b a]); %[a b c] = [theta' theta'' x'']
sol_b = simplify(sol.b)
solb = sol.b

採用された回答

John D'Errico
John D'Errico 2020 年 4 月 21 日
It would be almost as easy to solve by hand.
>> sol = solve(eq1,eq2,[a,b]);
>> real(sol.a)
ans =
8*2^(1/2) + 36/5
>> imag(sol.a)
ans =
4*2^(1/2) - 72/5
b will be similar. The symbolic toolbox chooses to group the sqrt(2) stuff together, but I don't see the problem either way. If I had to guess, look at the expression:
sol.a
ans =
2^(1/2)*(8 + 4i) + 36/5 - 72i/5
Here, we have 8+4i as ONE number. A complex number, yet only one number. Likewise, (36/5 - 72i/5) may be thought of as only one number, not two numbers, just one complex number. So the form returned is actually simpler than what you want to see.
  1 件のコメント
Aleem Andrew
Aleem Andrew 2020 年 4 月 21 日
Thank you for your answer.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by