# Simplifying solution to algebraic system of equations

1 view (last 30 days)
Aleem Andrew on 20 Apr 2020
Commented: Aleem Andrew on 21 Apr 2020
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 on 21 Apr 2020
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.
Aleem Andrew on 21 Apr 2020