5

How does one get the complex number out of this equation?

$$\Large{c = M e^{j \phi}}$$

I would like to write a function for this in C but I don't see how I can get the real and imaginary parts out of this equation to store it in a C structure.

some_id
  • 371

3 Answers3

3

In that form, the expresion is equivalent to the vector, in $\mathbb{R}^2$, with angle $\phi$ and length $M$. Now, with this information, can you continue?

sinbadh
  • 7,521
2

Use Euler's relation $$c = M\cos\phi + jM\sin\phi$$

enter image description here

So the real part is $M\cos\phi$ and imaginary part is $M\sin\phi$ I think that's what you want right? :)

wythagoras
  • 25,026
Padmal
  • 595
  • True I could do that, I was just wondering how the real and imaginary part can be extracted from that formula directly if passed in those arguments. I'll just use the trig formula in the function. – some_id Jan 03 '16 at 08:31
  • Yes, thanks for the updated answer. I think my question was pretty pointless as the polar form is the way it is. My uncertainty was more regarding how the math formula can be represented with a programming function. Using Euler's relation solves the problem, thanks :) – some_id Jan 03 '16 at 08:50
  • Oh you're going to get that $M$ and $\phi$ as input arguments in a programming function? Euler's relation does the job right? :) Good luck! :) – Padmal Jan 03 '16 at 08:58
  • yeah it does. Thanks :) – some_id Jan 04 '16 at 18:42
2

$$\mathcal{R}(c)=M\cdot\cos{\phi}$$ $$\mathcal{I}(c)=M\cdot\sin{\phi}$$

Assuming that $j^2=-1$ (Physics notation). If we follow a math notational convention where $i^2=-1$ and $j=e^{{2i\pi\over 3}}$ is a complex root of unity we just replace in the above $\phi$ by $\phi+{2i\pi\over 3}$

marwalix
  • 16,773
  • 3
    $j^2 = -1$ was engineering notation, I thought. I'm a physicist and I've never used it nor seen anyone in my field use it. We've all standardized on $i$ for the imaginary unit (and $j$ has no special meaning with regard to complex numbers). – David Z Jan 03 '16 at 11:55
  • Sorry I meant old fashioned electricity courses we used to have at High School. – marwalix Jan 03 '16 at 13:31
  • @DavidZ I imagine even a physics course would need to use 'j' when dealing with electrical networks having reactive components, since 'i' could be confused with the conventional notation for current. I am curious how you deal with that. – Masked Man Jan 03 '16 at 14:57
  • @MaskedMan Current never appears in an exponent. On top of that, we typically use capital $I$ for current, and/or write it as a function of time, $I(t)$ or $i(t)$. Throughout all of this, the imaginary unit is always $i$. – David Z Jan 03 '16 at 15:01
  • @MaskedMan: and $\mathbf{j}$ is actually used for current density in physics. – leftaroundabout Jan 03 '16 at 18:05