0
$\begingroup$

I'm using the code

ContourPlot3D[
  NumericQ[
    Integrate[
      Piecewise[
        {{Exp[-1/(1 - x^4 - y^4)]*
            Exp[I*ω*10*({Cos[ϕ], Sin[θ]} - {Cos[π/2], Sin[π/2]})], 
          Sqrt[x^2 + y^2] < 1}, 
        {0, Sqrt[x^2 + y^2] >= 1}}, 
        PerformanceGoal -> "Speed"], 
      {x, -2, 2}, {y, -2, 2}]], 
  {ϕ, 0, 2*π}, {θ, 0, 2*π}, {ω, -2, 2}, 
  PerformanceGoal -> "Speed", MaxRecursion -> 0]

I had the parameters set higher before, namely {x,-10,10}, etc., and I didn't use the MaxRecursion nor PerformanceGoal, but after four days of running I still had no result. Even now, I have had it running for most of the day and still no result.

Is this normal? Can I speed it up?

Edit: Note that the piecewise function I'm trying to plot is:

$$\frac{e^{10i\omega}}{40\pi}\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}\exp\left(-\frac{1}{1-x^{4}-y^{4}}\right)\exp\left(10i\omega\left(\begin{pmatrix} \cos\phi\\\sin\theta \end{pmatrix}-\begin{pmatrix} \cos\frac{\pi}{2}\\\sin\frac{\pi}{2} \end{pmatrix}\right)\begin{pmatrix} x\\y \end{pmatrix}\right)\,dx\,dy, \text{ if }\sqrt{x^2+y^2}<1\text{ and }0\text{ otherwise}.$$

$\endgroup$

closed as off-topic by m_goldberg, corey979, Sascha, Feyre, MarcoB Dec 26 '16 at 22:33

  • The question does not concern the technical computing software Mathematica by Wolfram Research. Please see the help center to find out about the topics that can be asked here.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ The code makes no sense. There are many braces that make no sense where they are. There is a PerformanceGoal -> "Speed" inside Piecewise. NumericQ doesn't seem to make much sense here either. $\endgroup$ – AccidentalFourierTransform Dec 25 '16 at 20:01
  • $\begingroup$ @AccidentalFourierTransform Indeed, the PeformanceGoal->"Speed" was misplaced in Piecewise. And NumericQ is there otherwise Mathematica does not perform the integral operation since it has non-numerical values. $\endgroup$ – Jason Born Dec 25 '16 at 20:04
  • $\begingroup$ the integrand has non-numerical values because your Piecewise function is not correctly built. Read the documentation on how this function is used. $\endgroup$ – AccidentalFourierTransform Dec 25 '16 at 20:06
  • $\begingroup$ @AccidentalFourierTransform I already read it and I just made the code a bit more efficient by changing it to Piecewise[{{Exp[-1/(1 - x^4 - y^4)]* Exp[I*\[Omega]*10*({Cos[\[Phi]], Sin[\[Theta]]} - {Cos[\[Pi]/2], Sin[\[Pi]/2]})], Sqrt[x^2 + y^2] < 1}}, 0]. I think the problem maybe lies with the two dimensional vectors {Cos[\[Phi]], Sin[\[Theta]]} and the other one? $\endgroup$ – Jason Born Dec 25 '16 at 20:27
  • 3
    $\begingroup$ I'm voting to close this question as off-topic because it is too localized; i.e, it applies only to the local situation and needs of its poster and answers will not benefit others. $\endgroup$ – m_goldberg Dec 26 '16 at 16:42
3
$\begingroup$

Your problem has very little to do ContourPlot3D. The problem lies in the Piecewise expression you are giving NIntegrate. It simply doesn't evaluate to a scalar for a large part of its domain. Consider

With[{ϕ = 1, θ = 1, ω = 1},
  With[{x = -.5, y = .5}, 
    Piecewise[
      {{Exp[-1/(1 - x^4 - y^4)] Exp[I ω 10 ({Cos[ϕ], Sin[θ]} - {0, 1})], 
        Sqrt[x^2 + y^2] < 1},
       {0, Sqrt[x^2 + y^2] >= 1}}]]]

This returns

{0.203152 - 0.245827 I, -0.00462201 - 0.318873 I}

A list of complex numbers is simply not going to work as the value of an integrand. NIntegrate needs a integrand that evaluates to real or complex scalar at each point in its domain. For what you want to do, it had better be a real.

You need to reformulate the expression you are trying integrate.

$\endgroup$
  • $\begingroup$ When I formulate it like ContourPlot3D[ Integrate[ Piecewise[{{Exp[-1/(1 - x^4 - y^4)]* Exp[I*\[Omega]*10*(x*Cos[\[Phi]] + y*Sin[\[Theta]] - x*Cos[\[Pi]/2] - y*Sin[\[Pi]/2])], Sqrt[x^2 + y^2] < 1}}, 0], {x, -10, 10}, {y, -10, 10}], {\[Phi], 0, 2*\[Pi]}, {\[Theta], 0, 2*\[Pi]}, {\[Omega], -10, 10}] I get the error SystemException["MemoryAllocationFailure"]. Likewise when I use @Re before the piecewise expression. $\endgroup$ – Jason Born Dec 26 '16 at 13:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.