Imaginary part of expression too difficult to calculate












2












$begingroup$


I am trying to calculate the imaginary part of a long expression. It's a long enough expression that Mathematica "hangs" when you run:



imFUN2 = ComplexExpand[Im[expression]];


Is there something I can do that can help speed things up?



Here is my full code:



expression = -((I Ωc (4 γa^4 + 16 Δd^4 - 48 Δd^3 Δp + 48 Δd^2 Δp^2 - 16 Δd Δp^3 + 4 I γa^3 
(3 Δc + 6 Δd - 4 Δp - Δs) - 16 Δd^3 Δs + 32 Δd^2 Δp Δs - 16 Δd Δp^2 Δs - 4 Δd^2 Ωc^2 +
4 Δd Δp Ωc^2 + 4 Δd Δs Ωc^2 - 4 I dephasing Δd Ωd^2 + 12 Δd^2 Ωd^2 +
4 I dephasing Δp Ωd^2 - 24 Δd Δp Ωd^2 + 12 Δp^2 Ωd^2 - 8 Δd Δs Ωd^2 +
8 Δp Δs Ωd^2 - Ωc^2 Ωd^2 + Ωd^4 + 4 Δc^2 (4 Δd^2 - 4 Δd Δp + Ωd^2) -
2 γa^2 (4 Δc^2 + 26 Δd^2 + 10 Δp^2 + 2 Δc (13 Δd - 7 Δp - 2 Δs) +
6 Δp Δs - 2 Δd (18 Δp + 5 Δs) - Ωc^2 + 4 Ωd^2) + 4 Δc (8 Δd^3 - 4 Δd^2 (4 Δp + Δs) -
(4 Δp + Δs) Ωd^2 + Δd (8 Δp^2 + 4 Δp Δs - Ωc^2 + 4 Ωd^2)) - 2 I γa (24 Δd^3 +
4 Δc^2 (3 Δd - Δp) - 4 Δp^3 - 4 Δp^2 Δs - 4 Δd^2 (13 Δp + 4 Δs) + Δp Ωc^2 + Δs Ωc^2 -
2 I dephasing Ωd^2 - 10 Δp Ωd^2 - 3 Δs Ωd^2 + Δc (36 Δd^2 + 8 Δp^2 + 4 Δp Δs -
4 Δd (11 Δp + 3 Δs) - Ωc^2 + 7 Ωd^2) + Δd (32 Δp^2 + 20 Δp Δs - 3 Ωc^2 + 10 Ωd^2))))/
((γa + 2 I Δd) (2 γa^2 - 4 Δc^2 + 4 Δd Δp - 4 Δp^2 + 4 Δd Δs - 8 Δp Δs - 4 Δs^2 +
2 I γa (3 Δc + Δd - 3 (Δp + Δs)) + Δc (-4 Δd + 8 (Δp + Δs)) + Ωd^2) (4 I γa^3 (Δc - Δp) -
16 Δc^2 Δd Δp - 16 Δc Δd^2 Δp + 16 Δc^2 Δp^2 + 48 Δc Δd Δp^2 + 16 Δd^2 Δp^2 - 32 Δc Δp^3 -
32 Δd Δp^3 + 16 Δp^4 - 4 Δc Δd Ωc^2 - 4 Δd^2 Ωc^2 + 8 Δc Δp Ωc^2 + 8 Δd Δp Ωc^2 -
8 Δp^2 Ωc^2 + Ωc^4 - 4 Δc^2 Ωd^2 - 4 Δc Δd Ωd^2 + 8 Δc Δp Ωd^2 + 8 Δd Δp Ωd^2 -
8 Δp^2 Ωd^2 - 2 Ωc^2 Ωd^2 + Ωd^4 + 2 γa^2 (-4 Δc^2 - 6 Δc Δd + 14 Δc Δp + 6 Δd Δp -
10 Δp^2 + Ωc^2 + Ωd^2) - 2 I γa (4 Δc^2 (Δd - 3 Δp) - 4 Δd^2 Δp + Δd (20 Δp^2 -
3 Ωc^2 - Ωd^2) + Δc (4 Δd^2 - 24 Δd Δp + 28 Δp^2 - 3 Ωc^2 - Ωd^2) + 4 Δp (-4 Δp^2 +
Ωc^2 + Ωd^2)) + 2 dephasing (2 γa^3 + 2 I γa^2 (2 Δc + 3 Δd - 5 Δp) + γa (-4 Δd^2 -
4 Δc (Δd - 3 Δp) + 20 Δd Δp - 16 Δp^2 + Ωc^2 + Ωd^2) + 2 I (4 Δd^2 Δp - 8 Δd Δp^2 +
4 Δp^3 - Δp Ωc^2 + Δd Ωd^2 - Δp Ωd^2 + Δc (4 Δd Δp - 4 Δp^2 + Ωd^2)))))) /.
{γa -> 1, dephasing -> 10^-4};

imFUN2 = ComplexExpand[Im[expression]];









share|improve this question











$endgroup$

















    2












    $begingroup$


    I am trying to calculate the imaginary part of a long expression. It's a long enough expression that Mathematica "hangs" when you run:



    imFUN2 = ComplexExpand[Im[expression]];


    Is there something I can do that can help speed things up?



    Here is my full code:



    expression = -((I Ωc (4 γa^4 + 16 Δd^4 - 48 Δd^3 Δp + 48 Δd^2 Δp^2 - 16 Δd Δp^3 + 4 I γa^3 
    (3 Δc + 6 Δd - 4 Δp - Δs) - 16 Δd^3 Δs + 32 Δd^2 Δp Δs - 16 Δd Δp^2 Δs - 4 Δd^2 Ωc^2 +
    4 Δd Δp Ωc^2 + 4 Δd Δs Ωc^2 - 4 I dephasing Δd Ωd^2 + 12 Δd^2 Ωd^2 +
    4 I dephasing Δp Ωd^2 - 24 Δd Δp Ωd^2 + 12 Δp^2 Ωd^2 - 8 Δd Δs Ωd^2 +
    8 Δp Δs Ωd^2 - Ωc^2 Ωd^2 + Ωd^4 + 4 Δc^2 (4 Δd^2 - 4 Δd Δp + Ωd^2) -
    2 γa^2 (4 Δc^2 + 26 Δd^2 + 10 Δp^2 + 2 Δc (13 Δd - 7 Δp - 2 Δs) +
    6 Δp Δs - 2 Δd (18 Δp + 5 Δs) - Ωc^2 + 4 Ωd^2) + 4 Δc (8 Δd^3 - 4 Δd^2 (4 Δp + Δs) -
    (4 Δp + Δs) Ωd^2 + Δd (8 Δp^2 + 4 Δp Δs - Ωc^2 + 4 Ωd^2)) - 2 I γa (24 Δd^3 +
    4 Δc^2 (3 Δd - Δp) - 4 Δp^3 - 4 Δp^2 Δs - 4 Δd^2 (13 Δp + 4 Δs) + Δp Ωc^2 + Δs Ωc^2 -
    2 I dephasing Ωd^2 - 10 Δp Ωd^2 - 3 Δs Ωd^2 + Δc (36 Δd^2 + 8 Δp^2 + 4 Δp Δs -
    4 Δd (11 Δp + 3 Δs) - Ωc^2 + 7 Ωd^2) + Δd (32 Δp^2 + 20 Δp Δs - 3 Ωc^2 + 10 Ωd^2))))/
    ((γa + 2 I Δd) (2 γa^2 - 4 Δc^2 + 4 Δd Δp - 4 Δp^2 + 4 Δd Δs - 8 Δp Δs - 4 Δs^2 +
    2 I γa (3 Δc + Δd - 3 (Δp + Δs)) + Δc (-4 Δd + 8 (Δp + Δs)) + Ωd^2) (4 I γa^3 (Δc - Δp) -
    16 Δc^2 Δd Δp - 16 Δc Δd^2 Δp + 16 Δc^2 Δp^2 + 48 Δc Δd Δp^2 + 16 Δd^2 Δp^2 - 32 Δc Δp^3 -
    32 Δd Δp^3 + 16 Δp^4 - 4 Δc Δd Ωc^2 - 4 Δd^2 Ωc^2 + 8 Δc Δp Ωc^2 + 8 Δd Δp Ωc^2 -
    8 Δp^2 Ωc^2 + Ωc^4 - 4 Δc^2 Ωd^2 - 4 Δc Δd Ωd^2 + 8 Δc Δp Ωd^2 + 8 Δd Δp Ωd^2 -
    8 Δp^2 Ωd^2 - 2 Ωc^2 Ωd^2 + Ωd^4 + 2 γa^2 (-4 Δc^2 - 6 Δc Δd + 14 Δc Δp + 6 Δd Δp -
    10 Δp^2 + Ωc^2 + Ωd^2) - 2 I γa (4 Δc^2 (Δd - 3 Δp) - 4 Δd^2 Δp + Δd (20 Δp^2 -
    3 Ωc^2 - Ωd^2) + Δc (4 Δd^2 - 24 Δd Δp + 28 Δp^2 - 3 Ωc^2 - Ωd^2) + 4 Δp (-4 Δp^2 +
    Ωc^2 + Ωd^2)) + 2 dephasing (2 γa^3 + 2 I γa^2 (2 Δc + 3 Δd - 5 Δp) + γa (-4 Δd^2 -
    4 Δc (Δd - 3 Δp) + 20 Δd Δp - 16 Δp^2 + Ωc^2 + Ωd^2) + 2 I (4 Δd^2 Δp - 8 Δd Δp^2 +
    4 Δp^3 - Δp Ωc^2 + Δd Ωd^2 - Δp Ωd^2 + Δc (4 Δd Δp - 4 Δp^2 + Ωd^2)))))) /.
    {γa -> 1, dephasing -> 10^-4};

    imFUN2 = ComplexExpand[Im[expression]];









    share|improve this question











    $endgroup$















      2












      2








      2





      $begingroup$


      I am trying to calculate the imaginary part of a long expression. It's a long enough expression that Mathematica "hangs" when you run:



      imFUN2 = ComplexExpand[Im[expression]];


      Is there something I can do that can help speed things up?



      Here is my full code:



      expression = -((I Ωc (4 γa^4 + 16 Δd^4 - 48 Δd^3 Δp + 48 Δd^2 Δp^2 - 16 Δd Δp^3 + 4 I γa^3 
      (3 Δc + 6 Δd - 4 Δp - Δs) - 16 Δd^3 Δs + 32 Δd^2 Δp Δs - 16 Δd Δp^2 Δs - 4 Δd^2 Ωc^2 +
      4 Δd Δp Ωc^2 + 4 Δd Δs Ωc^2 - 4 I dephasing Δd Ωd^2 + 12 Δd^2 Ωd^2 +
      4 I dephasing Δp Ωd^2 - 24 Δd Δp Ωd^2 + 12 Δp^2 Ωd^2 - 8 Δd Δs Ωd^2 +
      8 Δp Δs Ωd^2 - Ωc^2 Ωd^2 + Ωd^4 + 4 Δc^2 (4 Δd^2 - 4 Δd Δp + Ωd^2) -
      2 γa^2 (4 Δc^2 + 26 Δd^2 + 10 Δp^2 + 2 Δc (13 Δd - 7 Δp - 2 Δs) +
      6 Δp Δs - 2 Δd (18 Δp + 5 Δs) - Ωc^2 + 4 Ωd^2) + 4 Δc (8 Δd^3 - 4 Δd^2 (4 Δp + Δs) -
      (4 Δp + Δs) Ωd^2 + Δd (8 Δp^2 + 4 Δp Δs - Ωc^2 + 4 Ωd^2)) - 2 I γa (24 Δd^3 +
      4 Δc^2 (3 Δd - Δp) - 4 Δp^3 - 4 Δp^2 Δs - 4 Δd^2 (13 Δp + 4 Δs) + Δp Ωc^2 + Δs Ωc^2 -
      2 I dephasing Ωd^2 - 10 Δp Ωd^2 - 3 Δs Ωd^2 + Δc (36 Δd^2 + 8 Δp^2 + 4 Δp Δs -
      4 Δd (11 Δp + 3 Δs) - Ωc^2 + 7 Ωd^2) + Δd (32 Δp^2 + 20 Δp Δs - 3 Ωc^2 + 10 Ωd^2))))/
      ((γa + 2 I Δd) (2 γa^2 - 4 Δc^2 + 4 Δd Δp - 4 Δp^2 + 4 Δd Δs - 8 Δp Δs - 4 Δs^2 +
      2 I γa (3 Δc + Δd - 3 (Δp + Δs)) + Δc (-4 Δd + 8 (Δp + Δs)) + Ωd^2) (4 I γa^3 (Δc - Δp) -
      16 Δc^2 Δd Δp - 16 Δc Δd^2 Δp + 16 Δc^2 Δp^2 + 48 Δc Δd Δp^2 + 16 Δd^2 Δp^2 - 32 Δc Δp^3 -
      32 Δd Δp^3 + 16 Δp^4 - 4 Δc Δd Ωc^2 - 4 Δd^2 Ωc^2 + 8 Δc Δp Ωc^2 + 8 Δd Δp Ωc^2 -
      8 Δp^2 Ωc^2 + Ωc^4 - 4 Δc^2 Ωd^2 - 4 Δc Δd Ωd^2 + 8 Δc Δp Ωd^2 + 8 Δd Δp Ωd^2 -
      8 Δp^2 Ωd^2 - 2 Ωc^2 Ωd^2 + Ωd^4 + 2 γa^2 (-4 Δc^2 - 6 Δc Δd + 14 Δc Δp + 6 Δd Δp -
      10 Δp^2 + Ωc^2 + Ωd^2) - 2 I γa (4 Δc^2 (Δd - 3 Δp) - 4 Δd^2 Δp + Δd (20 Δp^2 -
      3 Ωc^2 - Ωd^2) + Δc (4 Δd^2 - 24 Δd Δp + 28 Δp^2 - 3 Ωc^2 - Ωd^2) + 4 Δp (-4 Δp^2 +
      Ωc^2 + Ωd^2)) + 2 dephasing (2 γa^3 + 2 I γa^2 (2 Δc + 3 Δd - 5 Δp) + γa (-4 Δd^2 -
      4 Δc (Δd - 3 Δp) + 20 Δd Δp - 16 Δp^2 + Ωc^2 + Ωd^2) + 2 I (4 Δd^2 Δp - 8 Δd Δp^2 +
      4 Δp^3 - Δp Ωc^2 + Δd Ωd^2 - Δp Ωd^2 + Δc (4 Δd Δp - 4 Δp^2 + Ωd^2)))))) /.
      {γa -> 1, dephasing -> 10^-4};

      imFUN2 = ComplexExpand[Im[expression]];









      share|improve this question











      $endgroup$




      I am trying to calculate the imaginary part of a long expression. It's a long enough expression that Mathematica "hangs" when you run:



      imFUN2 = ComplexExpand[Im[expression]];


      Is there something I can do that can help speed things up?



      Here is my full code:



      expression = -((I Ωc (4 γa^4 + 16 Δd^4 - 48 Δd^3 Δp + 48 Δd^2 Δp^2 - 16 Δd Δp^3 + 4 I γa^3 
      (3 Δc + 6 Δd - 4 Δp - Δs) - 16 Δd^3 Δs + 32 Δd^2 Δp Δs - 16 Δd Δp^2 Δs - 4 Δd^2 Ωc^2 +
      4 Δd Δp Ωc^2 + 4 Δd Δs Ωc^2 - 4 I dephasing Δd Ωd^2 + 12 Δd^2 Ωd^2 +
      4 I dephasing Δp Ωd^2 - 24 Δd Δp Ωd^2 + 12 Δp^2 Ωd^2 - 8 Δd Δs Ωd^2 +
      8 Δp Δs Ωd^2 - Ωc^2 Ωd^2 + Ωd^4 + 4 Δc^2 (4 Δd^2 - 4 Δd Δp + Ωd^2) -
      2 γa^2 (4 Δc^2 + 26 Δd^2 + 10 Δp^2 + 2 Δc (13 Δd - 7 Δp - 2 Δs) +
      6 Δp Δs - 2 Δd (18 Δp + 5 Δs) - Ωc^2 + 4 Ωd^2) + 4 Δc (8 Δd^3 - 4 Δd^2 (4 Δp + Δs) -
      (4 Δp + Δs) Ωd^2 + Δd (8 Δp^2 + 4 Δp Δs - Ωc^2 + 4 Ωd^2)) - 2 I γa (24 Δd^3 +
      4 Δc^2 (3 Δd - Δp) - 4 Δp^3 - 4 Δp^2 Δs - 4 Δd^2 (13 Δp + 4 Δs) + Δp Ωc^2 + Δs Ωc^2 -
      2 I dephasing Ωd^2 - 10 Δp Ωd^2 - 3 Δs Ωd^2 + Δc (36 Δd^2 + 8 Δp^2 + 4 Δp Δs -
      4 Δd (11 Δp + 3 Δs) - Ωc^2 + 7 Ωd^2) + Δd (32 Δp^2 + 20 Δp Δs - 3 Ωc^2 + 10 Ωd^2))))/
      ((γa + 2 I Δd) (2 γa^2 - 4 Δc^2 + 4 Δd Δp - 4 Δp^2 + 4 Δd Δs - 8 Δp Δs - 4 Δs^2 +
      2 I γa (3 Δc + Δd - 3 (Δp + Δs)) + Δc (-4 Δd + 8 (Δp + Δs)) + Ωd^2) (4 I γa^3 (Δc - Δp) -
      16 Δc^2 Δd Δp - 16 Δc Δd^2 Δp + 16 Δc^2 Δp^2 + 48 Δc Δd Δp^2 + 16 Δd^2 Δp^2 - 32 Δc Δp^3 -
      32 Δd Δp^3 + 16 Δp^4 - 4 Δc Δd Ωc^2 - 4 Δd^2 Ωc^2 + 8 Δc Δp Ωc^2 + 8 Δd Δp Ωc^2 -
      8 Δp^2 Ωc^2 + Ωc^4 - 4 Δc^2 Ωd^2 - 4 Δc Δd Ωd^2 + 8 Δc Δp Ωd^2 + 8 Δd Δp Ωd^2 -
      8 Δp^2 Ωd^2 - 2 Ωc^2 Ωd^2 + Ωd^4 + 2 γa^2 (-4 Δc^2 - 6 Δc Δd + 14 Δc Δp + 6 Δd Δp -
      10 Δp^2 + Ωc^2 + Ωd^2) - 2 I γa (4 Δc^2 (Δd - 3 Δp) - 4 Δd^2 Δp + Δd (20 Δp^2 -
      3 Ωc^2 - Ωd^2) + Δc (4 Δd^2 - 24 Δd Δp + 28 Δp^2 - 3 Ωc^2 - Ωd^2) + 4 Δp (-4 Δp^2 +
      Ωc^2 + Ωd^2)) + 2 dephasing (2 γa^3 + 2 I γa^2 (2 Δc + 3 Δd - 5 Δp) + γa (-4 Δd^2 -
      4 Δc (Δd - 3 Δp) + 20 Δd Δp - 16 Δp^2 + Ωc^2 + Ωd^2) + 2 I (4 Δd^2 Δp - 8 Δd Δp^2 +
      4 Δp^3 - Δp Ωc^2 + Δd Ωd^2 - Δp Ωd^2 + Δc (4 Δd Δp - 4 Δp^2 + Ωd^2)))))) /.
      {γa -> 1, dephasing -> 10^-4};

      imFUN2 = ComplexExpand[Im[expression]];






      performance-tuning simplifying-expressions complex






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 4 hours ago









      MarcoB

      37.5k556113




      37.5k556113










      asked 5 hours ago









      Steven SagonaSteven Sagona

      1866




      1866






















          1 Answer
          1






          active

          oldest

          votes


















          5












          $begingroup$

          Not an elegant solution but it works



          num = Numerator[expression];
          den = Denominator[expression];
          {reNum, imNum} = ComplexExpand[ReIm[num]];
          {reDen, imDen} = ComplexExpand[ReIm[den]];
          (imNum reDen - reNum imDen)/(reDen^2 + imDen^2)


          I think the problem is the denominator which is huge but I am surprised that my approach is not included in ComplexExpand






          share|improve this answer









          $endgroup$













          • $begingroup$
            This works for me, thanks. It is interesting though that you call ComplexExpand[ReIm[num]] inside your function. I guess I should always make sure I don't have fractions-inside-fractions before calling this. Also for completion it might be helpful for others to know that the real part is: (reNum reDen + imNum imDen)/(reDen^2 + imDen^2)
            $endgroup$
            – Steven Sagona
            4 hours ago











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "387"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f193509%2fimaginary-part-of-expression-too-difficult-to-calculate%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          5












          $begingroup$

          Not an elegant solution but it works



          num = Numerator[expression];
          den = Denominator[expression];
          {reNum, imNum} = ComplexExpand[ReIm[num]];
          {reDen, imDen} = ComplexExpand[ReIm[den]];
          (imNum reDen - reNum imDen)/(reDen^2 + imDen^2)


          I think the problem is the denominator which is huge but I am surprised that my approach is not included in ComplexExpand






          share|improve this answer









          $endgroup$













          • $begingroup$
            This works for me, thanks. It is interesting though that you call ComplexExpand[ReIm[num]] inside your function. I guess I should always make sure I don't have fractions-inside-fractions before calling this. Also for completion it might be helpful for others to know that the real part is: (reNum reDen + imNum imDen)/(reDen^2 + imDen^2)
            $endgroup$
            – Steven Sagona
            4 hours ago
















          5












          $begingroup$

          Not an elegant solution but it works



          num = Numerator[expression];
          den = Denominator[expression];
          {reNum, imNum} = ComplexExpand[ReIm[num]];
          {reDen, imDen} = ComplexExpand[ReIm[den]];
          (imNum reDen - reNum imDen)/(reDen^2 + imDen^2)


          I think the problem is the denominator which is huge but I am surprised that my approach is not included in ComplexExpand






          share|improve this answer









          $endgroup$













          • $begingroup$
            This works for me, thanks. It is interesting though that you call ComplexExpand[ReIm[num]] inside your function. I guess I should always make sure I don't have fractions-inside-fractions before calling this. Also for completion it might be helpful for others to know that the real part is: (reNum reDen + imNum imDen)/(reDen^2 + imDen^2)
            $endgroup$
            – Steven Sagona
            4 hours ago














          5












          5








          5





          $begingroup$

          Not an elegant solution but it works



          num = Numerator[expression];
          den = Denominator[expression];
          {reNum, imNum} = ComplexExpand[ReIm[num]];
          {reDen, imDen} = ComplexExpand[ReIm[den]];
          (imNum reDen - reNum imDen)/(reDen^2 + imDen^2)


          I think the problem is the denominator which is huge but I am surprised that my approach is not included in ComplexExpand






          share|improve this answer









          $endgroup$



          Not an elegant solution but it works



          num = Numerator[expression];
          den = Denominator[expression];
          {reNum, imNum} = ComplexExpand[ReIm[num]];
          {reDen, imDen} = ComplexExpand[ReIm[den]];
          (imNum reDen - reNum imDen)/(reDen^2 + imDen^2)


          I think the problem is the denominator which is huge but I am surprised that my approach is not included in ComplexExpand







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 4 hours ago









          HughHugh

          6,58421945




          6,58421945












          • $begingroup$
            This works for me, thanks. It is interesting though that you call ComplexExpand[ReIm[num]] inside your function. I guess I should always make sure I don't have fractions-inside-fractions before calling this. Also for completion it might be helpful for others to know that the real part is: (reNum reDen + imNum imDen)/(reDen^2 + imDen^2)
            $endgroup$
            – Steven Sagona
            4 hours ago


















          • $begingroup$
            This works for me, thanks. It is interesting though that you call ComplexExpand[ReIm[num]] inside your function. I guess I should always make sure I don't have fractions-inside-fractions before calling this. Also for completion it might be helpful for others to know that the real part is: (reNum reDen + imNum imDen)/(reDen^2 + imDen^2)
            $endgroup$
            – Steven Sagona
            4 hours ago
















          $begingroup$
          This works for me, thanks. It is interesting though that you call ComplexExpand[ReIm[num]] inside your function. I guess I should always make sure I don't have fractions-inside-fractions before calling this. Also for completion it might be helpful for others to know that the real part is: (reNum reDen + imNum imDen)/(reDen^2 + imDen^2)
          $endgroup$
          – Steven Sagona
          4 hours ago




          $begingroup$
          This works for me, thanks. It is interesting though that you call ComplexExpand[ReIm[num]] inside your function. I guess I should always make sure I don't have fractions-inside-fractions before calling this. Also for completion it might be helpful for others to know that the real part is: (reNum reDen + imNum imDen)/(reDen^2 + imDen^2)
          $endgroup$
          – Steven Sagona
          4 hours ago


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Mathematica Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f193509%2fimaginary-part-of-expression-too-difficult-to-calculate%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Bundesstraße 106

          Verónica Boquete

          Ida-Boy-Ed-Garten