I'm doing some electric circuit calcualtions and I'm trying to get the phasor representation of some arbitrary function of Sin or Cos. Could be complex like:

(0. - 10. I) Sin[1000 t]

For instance, if I have:

Vin = 10Cos[1000t- 90Degree]

which is:

Vin = 10Re[Exp[-I*90Degree]*Exp[I*1000t]]

I want to get the magnitude angle form. i.e $10\angle-90^\circ$

I can get the magnitude with:

MaxValue[Abs[Vin], t]

but I can't get the phase angle correctly. I've tried:

Re[N[ArcCos[(Vin/MaxValue[Vin, t]) /. t -> 0]/Degree]]

but that gives $90^\circ$ not $-90^\circ$

So I have 2 questions actually:

  1. Can I force mathematica to keep my function in $\cos\left(something - 90^\circ\right)$ form instead of changing it to $\sin\left(something + 0^\circ\right)$?
  2. And how can I correctly obtain the phase angle

Maybe you could expand the Vin to Fourier series to "normalize" it.

For example there are three of them kind:

VinSet = {10 Cos[1000 t - π/2], 9 Cos[400 t + π/4], Cos[t + 3.45]};

coeffSet = FourierCoefficient[# /. Times[ω_?NumericQ t] :> t, t, 1] & /@ VinSet

$\left\{-5 i,\frac{9 \sqrt[4]{-1}}{2}, -0.476409-0.151771 i\right \}$

{2 Abs[#], Arg[#]} & /@ coeffSet

{$\left\{10,-\frac{\pi }{2}\right\}$,$\left\{9,\frac{\pi }{4}\right\}$,$\{1.,-2.83319\}$}

Note $2\pi-2.83319 \approx 3.45$.


If you specify the angle as a real number (rather than an exact integer), it does not do the transformation to Sin. For instance

Vin = 10 Cos[1000 t - Pi/2.0]


Vin = 10 Cos[1000 t - 90.0 Degree]    

both do what you ask.

  • $\begingroup$ Great that works, any idea how to obtain the phase angle? $\endgroup$ – Wayne Apr 26 '13 at 21:51

As for your second question, here's one way that is very similar to what we'd do by hand. Use the exponential form and then identify the phase and magnitude.

Clear[A, p, t]
Vin = 10 Exp[-Pi/2]*Exp[1000 t I];
{A, p} = Replace[Vin, A_ Exp[p_] -> {A Exp[Re[p]], Im[p]}]

A now holds the amplitude and p holds the phase. If you have the trigonometric form you can use FullSimplify to bring it into the exponential form first.

To get rid of Im[t] and Re[t] we can tell Mathematica that the variable t is a real variable:

Refine[{A, p}, Assumptions :> t \[Element] Reals]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.