0
$\begingroup$

I am trying to plot a multiple variable integral. But somehow this is not working. This is my code.

a = 5;
b = .1;
f = (1 + Exp[(k - a)]);
B = f*(1/(z - (q^2 + k*q*x) + I*b) + 
    1/(z - (q^2 - k*q*x) + I*b));
ListContourPlot[
NIntegrate[Re[B], {x, -1, 1}, {k, -a, a}], {z, 0, 5, 
 1}, {q, 0, 5, 1}]

I shall be more interested in keeping the steps size of z and q fixed. Any help will be highly appreciated

$\endgroup$
1
$\begingroup$

Try this:

a = 5; b = .1; f = (1 + Exp[(k - a)]);
g[x_] := f*(1/(z - (q^2 + k*q*x) + I*b) + 1/(z - (q^2 - k*q*x) + I*b));
ListContourPlot[Table[NIntegrate[Re[g[x]], {x, -1, 1}, {k, -a, a}], {z, 0, 5, 1},{q,0, 5, 1}]]

It seems your function is singular at the origin and other points of (z,q), so you may get to see warnings.

$\endgroup$
  • $\begingroup$ Is there any way to deal with these singularities in mathematica? Because i am seeing warning sign even at z and q not equal to zero. $\endgroup$ – Hazoor Imran Jun 20 at 6:46
  • $\begingroup$ @HazoorImran, Sorry Not a much idea about it. $\endgroup$ – math Jun 20 at 7:27
0
$\begingroup$

It is possible to do the x integration exactly. To do so, I will use ComplexExpand and exact values:

a = 5;
b = 1/10;
g[x_] = ComplexExpand @ Re[(1/(z-(q^2+k q x) + b I) + 1/(z-(q^2-k q x) + b I))];

h[k_, q_, z_] = Integrate[
    FullSimplify[g[x]],
    {x, -1, 1},
    Assumptions -> (q | k | z) \[Element] Reals
]

-(Log[(1 + 100 (-q (k + q) + z)^2)/(1 + 100 ((k - q) q + z)^2)]/(k q))

Then, the second integral can be done numerically without messages:

int[q_?NumericQ, z_] := NIntegrate[h[k, q, z] (1 + Exp[k - a]), {k, -a, a}]

Visualization:

ContourPlot[int[q, z], {q, 0, 5}, {z, 0, 5}]

enter image description here

$\endgroup$

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.