# Obtaining the volume of function with double integrals in Mathematica

I want to obtain the volume of a function with a double integral. To solve this problem y have to evaluate in respect to x +-sqrt(y-y^2) but when I try to substitute I get this error:

Error:

NIntegrate[func1, {x, -Sqrt[y - y^2], Sqrt[y - y^2]}, {y, 0, 1}]

NIntegrate[func2, {x, -Sqrt[y - y^2], Sqrt[y - y^2]}, {y, 0, 1}]

My code:

func1 = 1 - y^2 - x^2

func2 = 1 - y

NIntegrate[func1, {x, -Sqrt[y - y^2], Sqrt[y - y^2]}, {y, 0, 1}]

NIntegrate[func2, {x, -Sqrt[y - y^2], Sqrt[y - y^2]}, {y, 0, 1}]

NIntegrate Is the only way I find to solve a double Integral and get a numerical number, yet I can’t use those limits

Is there a way to get around this error?

• Outermost limits of a multiple integral should come first in NIntegrate[], per the docs. NIntegrate[1 - x^2 - y^2, {y, 0, 1}, {x, -Sqrt[y - y^2], Sqrt[y - y^2]}] (Compare this with the more natural specification NIntegrate[1 - x^2 - y^2, {x, y} ∈ Disk[{0, 1/2}, 1/2]].) – J. M.'s torpor Apr 18 '20 at 7:07
• This is not an error, but a feature. NIntegrate can only provide a numerical result if the integrand is a numerical function (it is here), and likewise are the limits of integration (they are not). – yarchik Apr 18 '20 at 7:08
• J. M., your solution also worked. Thanks – alejandro.javier Apr 18 '20 at 7:25

I do not know why you are using NIntegrate since the limit for inner integral is symbolic.

ClearAll[y, x];
Integrate[
Integrate[(1 - x^2 - y^2), {x, -Sqrt[y - y^2], Sqrt[y - y^2]}], {y, 0, 1}]


  N[%]
(*0.490874*)


NIntegrate Is the only way I find to solve a double Integral

Sorry, I do not understand the above. Why? Integrate does work.

• There is no need to call Integrate[] twice if you follow Mathematica's convention for multiple integrals: Integrate[1 - x^2 - y^2, {y, 0, 1}, {x, -Sqrt[y - y^2], Sqrt[y - y^2]}] – J. M.'s torpor Apr 18 '20 at 7:19
• @J.M. I know that. But because I do not want to worry about the correct order, I always do it this way. By writing explicit double integrals. For me, it is more clear and I do not have to guess (I fell into the order trap before many times. There are many questions on this on this site by users confused on result they obtained that way). It is also how I would do it by hand. So for me, it is just more clear, even thought it is not as short to write. – Nasser Apr 18 '20 at 7:28
• Learning a lot thanks – alejandro.javier Apr 18 '20 at 7:28