2
$\begingroup$

I cannot figure out why I'm getting a negative value running NIntegrate to calculate my triple integral. Below is my code:

S = 40
p1 = 0.37
p2 = 0.43
p3 = .05
UND = 1 - (p1 + p2 + p3)
b1 = S*p1
b2 = S*p2
b3 = S*p3
b4 = S*UND
x1 = 48
x2 = 47
x3 = 4
x4 = 1

NIntegrate[(x^(x1 + b1 - 1))*(y^(x2 + b2 - 1))*(z^(x3 + b3 - 1))*((1 -
   x - y - z)^(x4 + b4 - 1)), {z, 0, 1}, {x, z, (1 - z)/2}, {y, 0, x}]

I want to triple integrate the function:

f(x,y,z) = (x^(x1 + b1 - 1))*(y^(x2 + b2 - 1))*(z^(x3 + b3 - 1))*((1 -x - y - z)^(x4 + b4 - 1))

I want to do the following:

S S S f(x,y,z) dy dx dz

where: y goes from 0 to x

x goes from z to (1-z)/2

z goes from 0 to 1

Can anyone tell me what I'm doing wrong please?

$\endgroup$
8
  • $\begingroup$ Are you sure about the value of cp ? $\endgroup$
    – Valacar
    Commented Jun 12, 2017 at 8:11
  • $\begingroup$ @Valacar yes, that's fine. It isn't used in the integral anyway. $\endgroup$
    – ProgSnob
    Commented Jun 12, 2017 at 8:34
  • $\begingroup$ Welcome to Mma.SE! Thanks for sharing your code in a well formatted form. It would further help if you remove anything on it that is superfluous and provide a minimum working example, easier to read. Also, please take the tour, it will help you understand the site. If you write an excellent question it will inspire great answers. Finally, please clarify if you are you having a problem with the mathematics or with Wolfram Mathematica programming. $\endgroup$
    – rhermans
    Commented Jun 12, 2017 at 11:07
  • $\begingroup$ Your x range switches direction part way through, is that what you expect? $\endgroup$
    – SPPearce
    Commented Jun 12, 2017 at 11:58
  • $\begingroup$ @KraZug no, x shouldn't change direction... can you elaborate how that is happening? $\endgroup$
    – ProgSnob
    Commented Jun 12, 2017 at 12:06

1 Answer 1

2
$\begingroup$

As @KraZug points out:

Plot[{Callout[z, "z", {.9, Above}], 
  Callout[(1 - z)/2, "(1-z) / 2", {.1, Above}]}, {z, 0, 1}, 
 AxesLabel -> {"Z", None}]

enter image description here

In[2]:= Reduce[(1-z)/2>z]
Out[2]= z<1/3

So for z>1/3, the second integration range reverses.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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