# Use of dummy variables in double integrals

**URL:** <https://community.wolfram.com/t/use-of-dummy-variables-in-double-integrals/438>\
**Category:** Questions\
**Tags:** physics, mathematica, numerical-computation\
**Created:** [August 23, 2013, 6:22pm UTC](https://community.wolfram.com/t/use-of-dummy-variables-in-double-integrals/438 "2013-08-23T18:22:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsaab](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/tsaab/32/15920_2.png) [@tsaab](https://community.wolfram.com/u/tsaab)\
**Post date:** [August 23, 2013, 6:22pm UTC](https://community.wolfram.com/t/use-of-dummy-variables-in-double-integrals/438/1 "2013-08-23T18:22:16Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![ccarter](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/ccarter/32/36312_2.png) [@ccarter](https://community.wolfram.com/u/ccarter)\
**Post date:** [August 23, 2013, 7:31pm UTC](https://community.wolfram.com/t/use-of-dummy-variables-in-double-integrals/438/2 "2013-08-23T19:31:25Z")

</div>

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…

```auto
ff2[Q_?NumberQ, w_, A_, p_, sig_] := NIntegrate[ff1[x0, w, A, p] PDF[NormalDistribution[Q, sig], x0], {x0, Q - sig, Q + sig}]

```

```auto
Timing[ff3[2, 10, 2, 0, 1]]

```

Gives:

```auto
{69.890998, 2.69798}

```

without a warning.

So your integrations are probably going to be a bit slow…

---

<div class="post-metadata">

**Author:** ![seanc](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/seanc/32/34005_2.png) [@seanc](https://community.wolfram.com/u/seanc)\
**Post date:** [August 23, 2013, 7:50pm UTC](https://community.wolfram.com/t/use-of-dummy-variables-in-double-integrals/438/3 "2013-08-23T19:50:21Z")

</div>

For a short explanation of why ?NumericQ is used in these kinds of situations, please see this article: [http://support.wolfram.com/kb/3820](http://support.wolfram.com/kb/3820)

---

<div class="post-metadata">

**Author:** ![tsaab](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/tsaab/32/15920_2.png) [@tsaab](https://community.wolfram.com/u/tsaab)\
**Post date:** [August 28, 2013, 11:56am UTC](https://community.wolfram.com/t/use-of-dummy-variables-in-double-integrals/438/4 "2013-08-28T11:56:09Z")

</div>

Thank you both. That was helpful.
