## How to solve a complex equation which has one equation but two real variables?

### Feng Zhou (view profile)

on 14 Feb 2019
Latest activity Answered by Walter Roberson

### Walter Roberson (view profile)

on 14 Feb 2019
Normally, a set of equations that have the same number of unknowns can be solved. However, an complex eqaution with two unknowns are possible to be solved. For example, a complex equation like : x+y*j = a+ b*j, can be solved by x = a, and y = b, because the real part and imaginary part correspond to each other.
Now, my question is how to do it with MATLAB solve function. A typical scanerio is the propagation constant solution in EM wave. The original eqaution is:
Kc = omiga* sqrt(u*(eps-j*sigma/omiga));
we would like to solve the equation into Kc = k_real -j* k_img. k_real and k_img are the unknowns in the equation.

### Torsten (view profile)

on 14 Feb 2019
Edited by Torsten

### Torsten (view profile)

on 14 Feb 2019

Does that help ?
>> syms z k
>> z0 = 1+3*1I;
>> a = solve(z==k*z0,z)
a = (sym) k*(1 + 3*I)
>> real(a)
ans = (sym) re(k) - 3*im(kc)
>> imag(a)
ans = (sym) 3*re(k) + im(kc)

on 14 Feb 2019
I get the results like this. There are also something strange in my Matlab. I suppose there are something wrong in my MATLAB。
>> syms z k
>> z0 = 1+3*1i;
>> a = solve(z==k*z0,z)
a =
z

on 14 Feb 2019
>> syms z complex
>> syms k
>> z0 = 1+3*1i;
>> a = solve(z==k*z0,z)
a =
k*(1 + 3i)
>> real(a)
ans =
real(k) - 3*imag(k)
>> imag(a)
ans =
imag(k) + 3*real(k)
>>
Walter Roberson

### Walter Roberson (view profile)

on 14 Feb 2019
complex is the default assumption and does not need to be added. Instead add real to the variables intended to be real valued.