3
$\begingroup$

I would like to plot entropy on a 2-simplex, i.e., I want to plot a function for x,y,z s.t. x+y+z=1. My strategy is to take bounds {x,0,1}, {y,0,1-x}, and compute z=1-x-y. However, there is some problem with logarithm in this approach. The following yields an empty plot:

Plot3D[x + Log[y], {x, 0, 1}, {y, 0, 1 - x}]

However, for example the following works just fine:

Plot3D[Log[x] + y, {x, 0, 1}, {y, 0, 1 - x}]

What is the issue with putting y in logarithm here?

EDIT: It works fine in version 12.0.0, didn't work in 11.3.0 [for Linux x86 (64-bit) (March 7, 2018)]

$\endgroup$
4
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Michael E2
    Jul 2, 2019 at 14:56
  • $\begingroup$ You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is useful for learning how to format your questions and answers. You may also find this meta Q&A helpful $\endgroup$
    – Michael E2
    Jul 2, 2019 at 14:56
  • $\begingroup$ What version of Mathematica are you using? $\endgroup$
    – Michael E2
    Jul 2, 2019 at 15:00
  • 1
    $\begingroup$ I've tagged the Q version-11.3, unless the community thinks this should be tagged a bug, in which case the version tag should be removed and the bugs header be edited into the question. I wonder if the plot fails in other earlier versions. $\endgroup$
    – Michael E2
    Jul 2, 2019 at 17:38

3 Answers 3

2
$\begingroup$

I'm not sure why the second example works while the first one doesn't, but a better strategy might be to specify a region to plot over instead of using the range plotting parameters.

R = ImplicitRegion[0 <= y <= 1 - x, {{x, 0, 1}, y}];

Plot3D[x + Log[y], {x, y} \[Element] R]

or in this case simply

Plot3D[x + Log[y], {x, y} \[Element] Simplex[2]]

both of which give

plot

$\endgroup$
2
$\begingroup$

Try RegionFunction

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

enter image description here

$\endgroup$
1
$\begingroup$

It works for me:

Plot3D[x + Log[y], {x, 0, 1}, {y, 0, 1 - x}]

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Ah, I see, so it might be just a bug? I am using version 11.3.0 for Linux x86 (64-bit) (March 7, 2018). I'll install 12.0.0 and see. $\endgroup$ Jul 2, 2019 at 16:15
  • $\begingroup$ Confirm, works fine in 12.0.0. $\endgroup$ Jul 2, 2019 at 16:56

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.