I have the following complex function:

Fnew[a_, b_, c_, d_, e_, f_, g_] := (4 Sqrt[a/b] b E^(-(((c + d)^2 + (2 I a + b (c + d - 2 e) + 2 I f)^2/b^2)/(4 g^2))) Sqrt[a/(b g^2)] (\[Pi] Erf[(2 a - I b (c + d - 2 e) + 2 f)/(2 b g)] + I (Log[-(b/(2 I a + b (c + d - 2 e) + 2 I f))] - 
  Log[b/(2 I a + b (c + d - 2 e) + 2 I f)])))/((2 a - I b (c + d - 2 e) + 2 f) Sqrt[\[Pi]])

where all of the quantities a,c,d,e,f,g are real. I want the following contour plot

ContourPlot[Integrate[Abs[Fnew[1, 1, c, d, e, 0, g]]^2, {c, -\[Infinity], \[Infinity]}, {d, -\[Infinity], \[Infinity]}], {e, 0, 20}, {g, 0, 50}]

However the difficulty is in finding the integral of Abs[Fnew[1, 1, c, d, e, 0, g]]^2 first. Mathematica returns the same input.

Any suggestions on how to calculate this integral or generate the contour plot?

  • $\begingroup$ ContourPlot only handles 2 dimensional functions! $\endgroup$ – Ulrich Neumann May 15 at 13:05
  • $\begingroup$ @UlrichNeumann, indeed! I am trying to plot the function over the variables e and g. $\endgroup$ – Sid May 15 at 13:27
  • $\begingroup$ Sorry! Perhaps you can take a step further bei substituting the integrand Abs[...]^2 by ComplexExpand[# Conjugate[#] &[Fnew[1, 1, c, d, e, 0, g]]] // Simplify $\endgroup$ – Ulrich Neumann May 15 at 13:44

A workaround could be the numerical integration:

integrand[c_?NumericQ, d_?NumericQ, e_?NumericQ, g_?NumericQ] = 
ComplexExpand[# Conjugate[#] &[Fnew[1, 1, c, d, e, 0,g]]] // Simplify

f[e_?NumericQ, g_?NumericQ] :=NIntegrate[integrand[c, d, e,g], {c, -\[Infinity], \[Infinity]}, {d, -\[Infinity],\[Infinity]}]

For example

f[1, 1] 

But evaluation is very slow, though ContourPlot[f[e,g],...] might run a long time.

  • $\begingroup$ Using ComplexExpand[# Conjugate[#] instead of Abs[]^2 is in fact exactly what I had before. Using Conjugate usually is a little tricky since it conjugates all parameters rather than just changing I for -I. Also, how long would it take to generate a contour plot using f[e,g]? $\endgroup$ – Sid May 15 at 15:02
  • $\begingroup$ Setting , AccuracyGoal -> 3, PrecisionGoal -> 3 inside NIntegrate the calculation of one point lasts ~5seconds. ContourPlot might take >500seconds... $\endgroup$ – Ulrich Neumann May 15 at 15:19
  • $\begingroup$ ok, i guess I'll have to do a ListContourPlot. What should be a good step size for this? $\endgroup$ – Sid May 15 at 15:22

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.