Volume integral in Julia?


Is something like this possible in Julia, here an example from Matlab:

Where it is possible to perform a volume integral using non-constant values in the limits?

EDIT: Just to make it a bit easier I pasted in the Matlab code:

fun = @(x,y,z) x.*cos(y) + x.^2.*cos(z)

xmin = -1;
xmax = 1;
ymin = @(x)-sqrt(1 - x.^2);
ymax = @(x) sqrt(1 - x.^2);
zmin = @(x,y)-sqrt(1 - x.^2 - y.^2);
zmax = @(x,y) sqrt(1 - x.^2 - y.^2);

q = integral3(fun,xmin,xmax,ymin,ymax,zmin,zmax,'Method','tiled')

Kind regards

For example, you can just use HCubature.jl with a change of variables to map the domain to a box. For example, see: 2D integration over non-rectangular domain using cubature - #7 by stevengj

(You could also do nested calls to a 1d quadrature routine like quadgk, though this requires some care for the tolerance of the inner integrals.)

Okay, this might be easy for some, but for me right now, I am not able to do this change of variable easily. What I want to calculate is the volume of a cylinder intersected by a plane as shown in this youtube video:

With the equation of the plane:

2x + z = 4

And the equation for the cylinder:

x^2 + y^2 = 9

Could you teach me/guide me on how do I decompose this triple integral into a final 1d integral?

Kind regards

You can find some examples, though not this specific one, here: Calculus with Julia - 59  Multi-dimensional integrals