Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm new in mathematica and I'm stucked on how I can get the volume of a solid created by the inequation:

(radFld[Grp, "Bx", {x, y, z}] - Btotal)/Btotal <= Value

where radFld is a function from the plug-in Radia and it does calculs given an x and z to find a magnetic field of the configuration of magnetics given by Grp. In other words: radFld[Grp, "Bx", {x, y, z}] - Btotal)/Btotal = f(x,y,z)

Also, "vmax" is a constant.

To get the volume, I tried this:

Integrate[Boole[(radFld[Grp, "Bx", {x, y, z}] - Btotal)/Btotal <= vmax], {x, -3, 3}, {y, -3, 3}, {z, -10, 10}]

but my results seems not to be correct, as it goes from 0 to 540 and does not assume any other value between this range, whatever is "vmax".

Also, I tried this to make sure the region has been modified with "vmax":

RegionPlot3D[(radFld[Grp, "Bx", {x, y, z}] - Btotal)/Btotal] <= vmax , {x, -3, 3}, {y, -3, 3}, {z, -10, 10}]

and I got different regions for different "vmax".

Is there any other suggestion to get the volume or of what I am doing wrong?

Thanks in advance

share|improve this question
    
Hi Felipe, welcome to Mathematica SE. –  Murta Jan 30 '13 at 11:10
1  
Hi Luiz! Welcome to this site. I think an explicit form of your inequality (i.e. (radFld[Grp, "Bx", {x, y, z}] - Btotal)/Btotal <= Value) should be helpful for others to understand what happens here. –  Silvia Jan 30 '13 at 11:18
    
Hi, Murta and Silvia! The problem is that I don't have the explicit form of radFld[]. When I used the code: Integrate[Boole[(radFld[Grp, "Bx", {x, y, z}] - Btotal)/Btotal <= vmax], {x, -3, 3}, {y, -3, 3}, {z, -10, 10}] I was just using the same method shown on Mathematica website: reference.wolfram.com/mathematica/ref/Boole.html, when they calculate the area of a circle (3rd example of Basic Examples) –  Luiz Felipe Santos Jan 30 '13 at 12:09
1  
Have you tried NIntegrate? –  Michael E2 Jan 30 '13 at 13:47
2  
It's almost certain that your problem has to do with the particulars of your integrand. If you can't provide radFld, it would be good to provide at least a minimal example function that shows the problem. –  Jens Mar 23 '13 at 16:41
show 6 more comments

closed as too localized by J. M. Apr 21 '13 at 15:15

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

This is too long for a comment, but I can remove this answer later. I don't really understand your sentence

but my results seems not to be correct, as it goes from 0 to 540 and does not assume any other value between this range, whatever is "vmax".

Maybe you can try to rephrase this, so that it will become crystal clear, what you mean ;-)

Additionally, the approach you already mentioned should work. Let's assume a simple example: a sphere. We can define a sphere in the same way you defined your function

f[v_] := Sqrt[v.v]
RegionPlot3D[f[{x, y, z}] < 1, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]

Mathematica graphics

Now you can use NIntegrate in the same you already showed with Integrate

NIntegrate[Boole[f[{x, y, z}] < 1], {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]

and you get 4.18879 which happens to be $$\frac{4}{3}\pi$$ which is of course the correct solution. You can try other radii and you'll see that the result is correct.

share|improve this answer
add comment

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