4
$\begingroup$

The command Integrate oftentimes produces output that seems to be a mix of real and complex components even though the result is a real function. The question is how to instruct Mathematica to simplify the output so that no complex component appear in the solution.

Specifically, at issue is calculating the volume, in terms of $c \in [0,1]$, of the region shaded in the following

f[x_,y_,z_] := x*y*z+(1 - x)*(1 - y)*(1 - z)
Manipulate[
  RegionPlot3D[f[x, y, z] <= c, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}], 
  {c, 0, 1, .01}]

For $1/4<c<1$ the region is a portion of a hyperboloid of two sheets as cut by the unit cube. In this case the integration is relatively easy to do by hand or by Mathematica.

My question is how can I calculate the volume for $0<c<1/4$ where the surface is a hyperboloid of one sheet? (I have done it by hand, and my result agrees with "Michael E2" solution below, but like to have the same result with Mathematica.)

Various approaches that I use on Mathematica display the answer with imaginary components and expressions involving $Log[2^n]$ for various unusually large values of $n$. Here is one try

V[c_] := 
  Assuming[
    0 < c && c < 1/4, 
    Integrate[
      Boole[
            x*y*z + (1 - x)*(1 - y)*(1 - z) <= c], 
      {x, 0, 1}, {y, 0,  1}, {z, 0, 1}]]]

My lengthy output includes unexpected expressions such as $60 I \pi - 372 I c \pi + 528 I c^2 \pi$ and $Log[281474976710656]$ (which is $48 Log[2]$).

I have also attempted the integration by cutting the region into components; one component in particular (which has a vertical tangent plane) gives an answer including complex numbers.

I can calculate the integral as an indefinite one and then take the limit of the result. This approach does get rid of the appearance of complex components. However I was looking for a shorter method.

$\endgroup$

closed as off-topic by Daniel Lichtblau, m_goldberg, Coolwater, LCarvalho, MarcoB Jan 1 '18 at 18:10

  • The question does not concern the technical computing software Mathematica by Wolfram Research. Please see the help center to find out about the topics that can be asked here.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ The result produced by version 11.2 is OK. E.g. N[V[1/10]] outputs $0.118982\, +2.5480742429328936 \,\,10^{-16} i $, where the imaginary part is caused by roundoff errors. It often happens that a symbolic result is not expressed in terms of real numbers (for example, the irreducible case when solving a cubic equation, when all the roots of the equation are actually real). $\endgroup$ – user64494 Dec 25 '17 at 7:20
  • 6
    $\begingroup$ I'm voting to close this question as off-topic because the result appears to be correct. $\endgroup$ – Daniel Lichtblau Dec 25 '17 at 16:29
  • 1
    $\begingroup$ With a little work you can simplify it down to c + (1 - 4 c)^(3/2) ArcTanh[Sqrt[1 - 4 c]] + (1/2 - 3 c) Log[c]. $\endgroup$ – Michael E2 Dec 26 '17 at 4:30
  • 3
    $\begingroup$ ComplexExpand often can help. For instance FullSimplify[ComplexExpand[V[c], TargetFunctions -> {Re, Im}], 0 < c < 1/4] gets rid of the terms with I. It took a long time, it seemed. Note in this case the useful identity is Log[-u] = I Pi + Log[u] and ArcTanh can be written in terms of Log, which was my first thought. I don't really know how to get Mathematica to use them in the way I had in mind, though $\endgroup$ – Michael E2 Dec 26 '17 at 5:34
  • 3
    $\begingroup$ If you're asking how to keep Integrate from producing results with I, I think it is probably impossible. The algorithm surely uses complex analysis on definite integrals to analyze branch cuts, and branch cuts that involve a parameter (e.g. c) are even harder to deal with. $\endgroup$ – Michael E2 Dec 26 '17 at 19:01
6
$\begingroup$

With version 11.2, the explicit solution is

Assuming[0 < c < 1/4, Integrate[Boole[x*y*z + (1 - x)*(1 - y)*(1 - z) <= c], 
    {x, 0, 1}, {y, 0, 1}, {z, 0, 1}]]
FullSimplify[%, 0 < c < 1/4]

(* c + 1/3 I (1 - 4 c)^(3/2) π + 2 c ArcTanh[Sqrt[1 - 4 c]] + 1/3 (1 - 4 c)^(3/2) 
   (ArcCoth[Sqrt[1 - 4 c]] + ArcTanh[(1 - 2 c)/Sqrt[1 - 4 c]]) - 4 c Log[2] 
   + 3 c Log[1 - Sqrt[1 - 4 c]] + c Log[1 + Sqrt[1 - 4 c]] + Log[c]/2 - 5 c Log[c] *)

Although this symbolic solution may appear to be complex due to its second term, the term (ArcCoth[Sqrt[1 - 4 c]] + ArcTanh[(1 - 2 c)/Sqrt[1 - 4 c]]) also is complex, so that the entire expression is real.

Plot[%, {c, 0, 1/4}, PlotRange -> {0, .7}, AxesLabel -> {c, V[c]}, 
    LabelStyle -> Directive[Bold, Black, Medium], ImageSize -> Large]

enter image description here

Addendum

MichaelE2 suggested in a comment below that

 FullSimplify[% // TrigToExp, 0 < c < 1/4]

could eliminate the spurious complex term, and it does:

(* 1/6 (2 (1 - 4 c)^(3/2) ArcTanh[(Sqrt[1 - 4 c] (-1 + c))/(-1 + 3 c)] + 
   3 (2 c + Log[c] - 6 c Log[c])) *)

Mathematically, this simplification is possible, because inverse hyperbolic functions can be expressed in terms of logarithmic functions.

$\endgroup$
  • 3
    $\begingroup$ FullSimplify[% // TrigToExp, 0 < c < 1/4] takes care of the spurious imaginary terms. $\endgroup$ – Michael E2 Dec 26 '17 at 4:14

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