0
|
6571 Views
|
3 Replies
|
3 Total Likes
View groups...
Share
GROUPS:

# Use of dummy variables in double integrals

Posted 10 years ago
 Hi all,This may be a "simple" language issue that I have overlooked, but I am enountering the ollowing situation when trying to run some NIntegrate calculations.If i define the following 3 functions: integralMax = 100;  ff1[Q_, w_, A_, p_] := A Sin[w Q + p]^2/Q;    (* a simplified version of the function I'm using *) ff2[Q_, w_, A_, p_, sig_] := NIntegrate[ ff1[x0, w, A, p] PDF[NormalDistribution[Q, sig], x0], {x0, Q - sig, Q + sig}];  ff3[Qth_?NumberQ, w_, A_, p_, sig_] :=NIntegrate[ff2[Q0, w, A, p, sig], {Q0, Qth, integralMax }];ff1 represents an event rate vs variable Q.ff2 represents a "quasi" convolution of ff1 with some resolution fn (p.s. using the built in covolve fn on my working version of ff1 does not compute within a days time on my computer)ff3 is the integral from a starting point Q to a maximum value.When I run ff3, for example:ff3[2, 10, 2, 0, 1]I get :NIntegrate::nlim: x0 = -1.+Q0 is not a valid limit of integration. >>NIntegrate::nlim: x0 = -1.+Q0 is not a valid limit of integration. >>NIntegrate::nlim: x0 = -1.+Q0 is not a valid limit of integration. >>General::stop: Further output of NIntegrate::nlim will be suppressed during this calculation. >>followed by a valid numerical result. As far as I can tell, the function work like I want them to, eventhough the NIntegrate::nlim errors pop up.Is there a "correct Mathematica" way to implement this ?Thanks
3 Replies
Sort By:
Posted 10 years ago
 Thank you both. That was helpful.
Posted 10 years ago
 For a short explanation of why ?NumericQ is used in these kinds of situations, please see this article: http://support.wolfram.com/kb/3820
Posted 10 years ago
 The  "NIntegrate::nlim: x0 = -1.+Q0 is not a valid limit of integration."goes away if you define ff2 with the same ?NumberQ pattern restriction that you used for ff3...ff2[Q_?NumberQ, w_, A_, p_, sig_] := NIntegrate[ ff1[x0, w, A, p] PDF[NormalDistribution[Q, sig], x0], {x0, Q - sig, Q + sig}]Timing[ff3[2, 10, 2, 0, 1]]Gives:{69.890998, 2.69798}without a warning.So your integrations are probably going to be a bit slow...