# Calculating volume [closed]

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

-
Hi Felipe, welcome to Mathematica SE. – Murta Jan 30 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 at 11:18
– Luiz Felipe Santos Jan 30 at 12:09

1
Have you tried `NIntegrate`? – Michael E2 Jan 30 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 at 16:41
show 6 more comments

## closed as too localized by J. M.♦Apr 21 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, see the FAQ.

## 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}]
````

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.

-
lang-mma
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9198434948921204, "perplexity_flag": "middle"}