1
$\begingroup$

I have the following function:

enter image description here

I need to plot a 3-D with coordinates f (p, q), p and q. I mean, I enter values for p and q, so that the integral of f (p, q) must be a number. This number must be placed in a coordinate axis and their respective points p and q must be palced in the other two coordinates axes to generate a point (in the 3-D space). Variables p and q range from minus infinity to plus infinity.

I've tried to solve the problem this way: enter image description here

However, I didn't succeed. Mathematica does not accept the limit 1-z of the integral. Also, it does accept the varying values of p and q. What can I do to solve this problem?

Thank you in advance.

Thanks a lot, you helped me so much. But I have another question. When I tried to plot the imaginary part too, I didn't succeed, why? Notice that when I plot with the variation of p and q which range from -Sqrt2 up to Sqrt2, the graphic is ploted:

F[p_, q_] := NIntegrate[1/(q^2 y (1 - y) + p^2 z (1 - z) - 1), {z, 0, 1}, {y, 0, 1 - z}]
GraphicsGrid[{{Plot3D[
    Im[F[p, q]], {p, -Sqrt[2], Sqrt[2]}, {q, -Sqrt[2], Sqrt[2]}, AxesLabel -> {p, q, F}], 
    Plot3D[Re[F[p, q]], {p, -Sqrt[2], Sqrt[2]}, {q, -Sqrt[2], Sqrt[2]},
     AxesLabel -> {p, q, F}]}}]

But how can I increase the range of p and q?

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$ – bbgodfrey Nov 20 '15 at 22:46
  • 3
    $\begingroup$ Please include your actual Mathematica code, not an image of it, in your question. $\endgroup$ – bbgodfrey Nov 20 '15 at 22:46
  • $\begingroup$ This answer might help you with formatting your mathematica code to look good on Mathematica.SE: meta.mathematica.stackexchange.com/a/1585/4597 $\endgroup$ – Sascha Nov 20 '15 at 23:08
  • $\begingroup$ This is also very closely related: mathematica.stackexchange.com/q/10533/21606 $\endgroup$ – Lukas Nov 20 '15 at 23:58
  • 1
    $\begingroup$ @Lucy You will need to log in under the account you posted in order to accept the answer that solves your problem. It is the standard way to show your gratitude to those who helped you voluntarily. You will also be able to edit the question without our having to approve it. Please see mathematica.stackexchange.com/help/merging-accounts or other help pages if you can't get back into your original account. $\endgroup$ – Michael E2 Nov 22 '15 at 23:14
6
$\begingroup$

To avoid the error encounterd in the Question, combine the two NIntegrate into one. Note also that the integrand is singular for p^2 + q^2 >= 2.

F[p_, q_] := NIntegrate[1/(q^2 y (1 - y) + p^2 z (1 - z) - 1), {z, 0, 1}, {y, 0, 1 - z}]
Plot3D[F[p, q], {p, -Sqrt[2], Sqrt[2]}, {q, -Sqrt[2], Sqrt[2]}, AxesLabel -> {p, q, F}]

enter image description here

Note that the order of the integrations matters even for the combined NIntegrate. Putting the limits on y at the end of NIntegrate causes the integral over y to be performed first.

Addendum

Alternatively, the inner integral in the Question can be performed symbolically, and the outer integral performed numerically.

inner = Integrate[1/(q^2 y (1 - y) + p^2 z (1 - z) - 1), {y, 0, 1 - z}, 
    Assumptions -> 0 < z < 1 && p^2 + q^2 < 4 && (p | q) ∈ Reals]
(* (2 (ArcTan[q/Sqrt[4 - q^2 + 4 p^2 (-1 + z) z]] - 
       ArcTan[(q (-1 + 2 z))/Sqrt[4 - q^2 + 4 p^2 (-1 + z) z]]))/
   (q Sqrt[4 - q^2 + 4 p^2 (-1 + z) z]) *)
F[p0_, q0_] := NIntegrate[inner /. {p -> p0, q -> q0}, {z, 0, 1}]

yielding the same result when plotted.

Second Addendum

In response to the additional query added to the Question, it is difficult to obtain plots for p^2 + q^2 > 4 due to singularities in the integrand. However, the singularities in inner appear to be first order, so numerically integrating across them may give reasonably accurate answers, at least for large p^2 + q^2, where the singularities are near z = 0 and z = 1. Using the definition of F from the first Addendum then gives for the real and imaginary parts of F.

Plot3D[Re[F[p, q]], {p, -5, 5}, {q, -5, 5}, AxesLabel -> {p, q, F}, 
    PlotRange -> {-1.2, .8}]

enter image description here

Plot3D[Im[F[p, q]], {p, -5, 5}, {q, -5, 5}, AxesLabel -> {p, q, F}]

enter image description here

Numerical problems for p^2 + q^2 just larger than 4 are evident.

$\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.