# Triple Integral help

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?

• Are you sure about the value of cp ? Jun 12, 2017 at 8:11
• @Valacar yes, that's fine. It isn't used in the integral anyway. Jun 12, 2017 at 8:34
• 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. Jun 12, 2017 at 11:07
• Your x range switches direction part way through, is that what you expect? Jun 12, 2017 at 11:58
• @KraZug no, x shouldn't change direction... can you elaborate how that is happening? Jun 12, 2017 at 12:06

Plot[{Callout[z, "z", {.9, Above}],

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