0
$\begingroup$

I have a Mathematica code that generates a complicated output that runs into more than 200+ lines of output. Here is my code:

ClearAll["Global`*"]
h = q/(2 g) + I (1/(2 g))*f;


rules = {a :> -h/q, b :> -1/g, z :> (q*t)/g};
rulse = {a :> -Conjugate[h]/q, b :> -1/g, z :> (-q*t)/g};

L = Normal[(Gamma[1 - b + a]/Gamma [1 - b]) E^(z - h*t) Gamma[
      1 - a] ((-(Gamma[b - 1]/Pi)) ((-z^(1 - b)) Sin[
            Pi a] + (-z)^(1 - b) Sin[Pi (b - a)]) Series[
         Hypergeometric1F1[1 - a, 2 - b, -z], {z, 0, 3}] + (1/
          Gamma[1 + a - b]) Series[
         HypergeometricU[-a + b, b, -z], {z, 0, 3}])] /. rules;

K = Normal[(Gamma[1 - b + a]/
       Gamma [1 - b]) E^(z + Conjugate[h]*t) Gamma[
      1 - a] ((-(Gamma[b - 1]/Pi)) ((-z^(1 - b)) Sin[
            Pi a] + (-z)^(1 - b) Sin[Pi (b - a)]) Series[
         Hypergeometric1F1[1 - a, 2 - b, -z], {z, 0, 3}] + (1/
          Gamma[1 + a - b]) Series[
         HypergeometricU[-a + b, b, -z], {z, 0, 3}])] /. rulse;

Integrate[K, {t, -Infinity, 0}, 
  Assumptions -> {g < -1/2, q > 0, f \[Element] Reals}] + 
 Integrate[L, {t, 0, Infinity}, 
  Assumptions -> {g < -1/2, q > 0, f \[Element] Reals}]

Running the above code and generating an output takes around 10 minutes on my machine. Here is a screenshot of the output:

enter image description here

Even trying Fullsimplify or Multinomiallist takes more than 3+ hours, without any results. I just want to collect the $f^xg^yq^z$ terms together, without any expansion of $(If+q)^k$ terms or the Gamma function terms.

I am a beginner in Mathematica and I am unable to write any custom functions for the same.

Edit: Sorry for not stating my problem clearly. As you can see from the output, it looks like a complex number. However, I have checked theoretically that all the imaginary parts cancel out and only real parts remain. But, my question is how to get Mathematica do the same. Thank you for the help

$\endgroup$
1
$\begingroup$

One can change $p$, $q$ and $g$ in the sub-expressions not to be expanded on formal variables:

expr1 = expr /. {I f + q -> \[FormalF] + I \[FormalQ]} /. 
  Gamma[$_] :> Gamma[$ /. {f -> \[FormalF], q -> \[FormalQ], g -> \[FormalG]}]

and then apply CoefficientList (or Series if powers of $g$ etc are not integer) to find coefficients.

$\endgroup$
  • $\begingroup$ Actually, most of the expressions are conjugates of one another. So, I want Mathematica to cancel out all the imaginary parts. I tried Conjugateexpand, but in vain. $\endgroup$ – kasa May 1 '18 at 11:22
  • $\begingroup$ Even if the imaginary part is zero it doesn't mean that the expression containing gamma functions can be somehow simplified. Say $\Gamma(1+i)+\Gamma(1-i)$ is real, but Mma cannot simplify it and chances it can be somehow be rewritten in without $i$ seem fin to me. $\endgroup$ – Andrew May 1 '18 at 11:36
  • $\begingroup$ Oh.. I see! Nevertheless, Using Collect[expr1, {f, g, q}] is taking more than 2+ hours. Can you please help me out in pointing where I am going wrong? $\endgroup$ – kasa May 1 '18 at 11:39

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.