2
$\begingroup$

I am doing some evaluations which return functions of three variables similar to the following:

Q[x_,y_,z_] = 1/2 (1 - (-1 + 2 y z + 2 x (y + z)) Abs[(
 1 + 4 x^2 + 2 y (-2 + 2 y + z) + 2 x (-2 + 3 y + z))/(-1 + 
  2 y z + 2 x (y + z))] + (x y + (x + y) z) Abs[
 2 - (4 x y)/(y z + x (y + z))])

I want to create a RegionPlot3D of $Q-\frac{1}{2}>0$ in the region with $x,y,z \in[0,1]$, along with another constraint $x+y+z\leq1$, but notice that this function $Q$, as it is currently written, will encounter some infinity problems. For example, the point $x=y=z=0$, will lead to an infinity inside the second Abs term, due to the xy+yz+zx in the denominator. In practice, however, this term is premultiplied with xy+yz+zx, so that should not actually cause an issue. For this simple example, I can just manually simplify both of the Abs terms by taking the premultiplying factor inside the Abs and cancel the corresponding term (also making sure I keep a Sign[] of the term moved inside the absolute value). As an example, the first absolute value term should be

(-1 + 2 y z + 2 x (y + z)) Abs[(1 + 4 x^2 + 2 y (-2 + 2 y + z) 
+ 2 x (-2 + 3 y + z))/(-1 + 2 y z + 2 x (y + z))] 
= Sign[-1 + 2 y z + 2 x (y + z)] Abs[1 + 4 x^2 + 2 y (-2 + 2 y + z) + 2 x (-2 + 3 y + z)] 

With these simplification, when I make a RegionPlot3D I get no error. However, in practice the functions I am looking at have many terms of this form and it is becoming impractical to do these simplifications by hand. So, my question is, how can I tell Mathematica to do that? I have tried both Simplify and FullSimplify and both fail to make that simplification. Thanks!

$\endgroup$

2 Answers 2

1
$\begingroup$

You may construct a list of exclusions

 Plot[... , Exclusion-> ...] 

e.g. for infinities by zero denominators by

     (FindInstance[0 == #, Union@Cases[{#}, _Symbol, \[Infinity]]] &) /@ 
     (1/ Cases[ Q[x, y, z], _^(_?Negative), \[Infinity]]) 

      {{{x -> -(3/2), y -> 1, z -> -4}}, {{x -> 0, y -> 0, z -> 0}}}

Other singular terms can be found by similar methods replacing the pattern of a negative power

   _^(_?Negative)  

by another special pattern and determining its singularities by specialized methods.

$\endgroup$
1
  • $\begingroup$ Thanks but that is not what I want to do. For example, the point $x=y=z=0$ is not really a singular point, after appropriately simplifying the expression. So, I don't want such a point discarded but instead the functional form of my expression simplified. $\endgroup$
    – JohnnyB
    Commented Jun 12 at 6:48
1
$\begingroup$

This can be done as follows.

red = Reduce[(1 - (-1 + 2*y*z + 2*x*(y + z))*
      RealAbs[(1 + 4*x^2 + 2*y*(-2 + 2*y + z) + 
          2*x*(-2 + 3*y + z))/(-1 + 2*y*z + 2*x*(y + z))] + (x*
         y + (x + y)*z)*RealAbs[2 - (4*x*y)/(y*z + x*(y + z))])/
   2 (1 - (-1 + 2*y*z + 2*x*(y + z))*
      RealAbs[(1 + 4*x^2 + 2*y*(-2 + 2*y + z) + 
          2*x*(-2 + 3*y + z))/(-1 + 2*y*z + 2*x*(y + z))] + (x*
         y + (x + y)*z)*RealAbs[2 - (4*x*y)/(y*z + x*(y + z))])/
   2 > 1/2 && x >= 0 && x <= 1 && y >= 0 && y <= 1 && z >= 0 && 
z <= 1];
RegionPlot3D[red, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}, PlotPoints -> 50]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks but this only works efficiently in cases where the function is fairly simple. In practice I have very long expression where reduce takes forever to calculate and even when it does, the function still contains singularities (which are actually not there). So, unfortunately this also does not address my question $\endgroup$
    – JohnnyB
    Commented Jun 17 at 4:04
  • $\begingroup$ @JonnyB: What was asked, that was answered. You may present your "very long expression" in a separate question. Deep regard anyway. $\endgroup$
    – user64494
    Commented Jun 17 at 6:23
  • $\begingroup$ Well, from the beginning sentence as well as the end of the question it should be clear that this Q is only an example and in practice I am dealing with much longer and complicated expressions... So, your answer does not address my question in general but in any case I do thank you for trying to help! $\endgroup$
    – JohnnyB
    Commented Jun 17 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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