# Find the solid and it´s volume formed by the intersection of two surfaces

I am trying to plot the solid formed by the intersection of the surface between

p1 = Plot3D[1 + x^2 - y^2, {x, -1.2, 1.2}, {y, -1.2, 1.2}]


and

p2 = Plot3D[3 Log[1 + x^2], {x, -1.4, 1.4}, {y, -1, 1}]


I am also trying to get the volume of said solid. I've tried the solution given in How to plot and find the volume of a solid?, but I am only recently starting in this language and can't manage to adapt it to work with my functions. Any help will be apreciated. Thank you.

Here is the code for the two surfaces and its intersection.

• FWIW ImplicitRegion \ Volume handles this in v.11. Judging by the poor quality of the discretization I am suspicious of the result ( 1.24717 ) Apr 23, 2018 at 18:52
• oh, that seems to agree with @Bills answer so maybe ok.. Apr 23, 2018 at 18:56

Clearly the maximum x extent will be when y==0. Use Reduce to find the x extent.

Reduce[1+x^2-0^2==3 Log[1+x^2],x]


Use Reduce to find the y extent for a given x.

Reduce[1+x^2-y^2==3 Log[1+x^2],y]


Then Integrate over the y extent for each x to find the volume.

NIntegrate[1+x^2-y^2-3 Log[1+x^2],
{x,-Sqrt[E^(-ProductLog[-1/3])-1],Sqrt[E^(-ProductLog[-1/3])-1]},
{y,-Sqrt[1+x^2-3*Log[1+x^2]],Sqrt[1+x^2-3*Log[1+x^2]]}]


In exactly the same way Plot3D the volume between them.

Plot3D[{1+x^2-y^2,3 Log[1+x^2]},
{x,-Sqrt[E^(-ProductLog[-1/3])-1],Sqrt[E^(-ProductLog[-1/3])-1]},
{y,-Sqrt[1+x^2-3*Log[1+x^2]],Sqrt[1+x^2-3*Log[1+x^2]]}]


Check all this very carefully to make certain no mistakes have been made.

• Hi, first of all thank you very much for your help I really appreciate it. Ther seems to be no problem with the volume calculation but whe I try the 3d plot I get an error. Plot3D::plln: Limiting value -Sqrt[1+x^2-3 Log[1+x^2]] in {y,-Sqrt[1+x^2-3 Log[1+x^2]],Sqrt[1+x^2-3 Log[1+x^2]]} is not a machine-sized real number. I hope you can help me with this. Thank you. Apr 23, 2018 at 18:54
• @Damian Muciño What version of MMA are you using? Perhaps that will let someone else try it using your version and see if they can duplicate the problem. I just tried this again in version 11.3 without error. It is an ugly ugly patch which I don't even want to admit doing, but what happens if you narrow the x extent in the plot by adding .01 to the lower limit and subtracting .01 from the upper limit? Does that perhaps make the error go away without degrading the quality? And what happens if you explore PlotPoints->nn for some nn to increase or decrease the number of points plotted?
– Bill
Apr 23, 2018 at 19:28
• @Damian Muciño And what happens if you include WorkingPrecision->64 (or 32 or 24 or 128 or ...) plot option to increase the number of bits used to do the calculations during the plot?
– Bill
Apr 23, 2018 at 19:36

A different way to discretize is to work with each surface separately and take their intersection.

ToBMR[g_Graphics3D] := With[{s = DiscretizeGraphics[g]},
BoundaryMeshRegion[MeshCoordinates[s], MeshCells[s, 2]]
];

p1 = Plot3D[1 + x^2 - y^2, {x, -1.5, 1.5}, {y, -1.5, 1.5},
Filling -> Bottom, PlotRange -> {-2, Automatic}, PlotPoints -> 50];

p2 = Plot3D[3 Log[1 + x^2], {x, -1.5, 1.5}, {y, -1.5, 1.5},
PlotStyle -> Red, Filling -> Top, PlotPoints -> 50];

m1 = ToBMR[p1];
m2 = ToBMR[p2];



Volume[saddle]

1.24449


Here's the same calculation with PlotPoints -> 200:

Volume[saddle]

1.24697


per comment:

r = ImplicitRegion[
3 Log[1 + x^2] < z <
1 + x^2 - y^2, {{x, -1.4, 1.4},y,z}];
Volume[r]


1.2471664022353517

DiscretizRegion and RegionPlot have a hard time with it though.

DiscretizeRegion[r, MaxCellMeasure -> .0001, MeshQualityGoal -> 1]


This does not work at all in v10.1 by the way.

Edit. Another way to get the figure:

Plot3D[{1 + x^2 - y^2, 3 Log[1 + x^2]}, {x, -1, 1}, {y, -1, 1},
RegionFunction -> Function[{x, y}, 3 Log[1 + x^2] <= 1 + x^2 - y^2]]


and another volume:

NIntegrate[
Boole[3 Log[1 + x^2] <= z <= 1 + x^2 - y^2], {x, -1, 1}, {y, -1,
1}, {z, -1, 3}]


1.247166402235352

• I tried the same and was quite shocked about the bad quality... Apr 23, 2018 at 19:12
• @Henrik Schumacher Welcome to the world of endless trial and error fumbling with Plot options to try to get a "desktop publishing" quality image to satisfy the user. It often takes far longer to get exactly the picture you want than it took to get the calculation.correct.
– Bill
Apr 23, 2018 at 19:18
• Yeah the quality may not be tha best, but for now I think it gives the idea of what I wanted, I´ll try to improve it maybe by moving a thing here or ther, never the less thank you very much for your help. Apr 23, 2018 at 20:26