Message Boards Message Boards

2 Replies
2 Total Likes
View groups...
Share this post:

Why does my RegionFunction restriction not work with a boundary y=x-c?

Posted 10 years ago

I have desperately tried for hours to understand what I did wrong with this short and pretty basic code:

c=1 Plot3D[{(c^2*Pi)/(x^2*Pi)}, {x, 1, 3}, {y, 0, c}, RegionFunction -> Function[{x, y, z}, 0 <= y <= x - c]]

The graph I get is this one: BadGraph

Looking at the z axis, it becomes quite obvious that this doesn't make any sense. If c=1, then the value of z should be z=1 for x=1. The strange thing is that the Plot works totally fine if I a) delete the Region restriction or b) remove the power of 2 from x, then it's just a nicely behaving plane:


I have no idea what's going on. Does anybody know how I can implement the restriction I want without messing up the graph? And what's the reason for this strange behaviour?

Thanks in advance!

2 Replies

In plotting functions Mathematica makes a determination of how much of the function to show according to some algorithm that determines where the interesting parts of the function are. To override this use the PlotRange option. In your case this will show the full graph:

Plot3D[{(c^2*Pi)/(x^2*Pi)}, {x, 1, 3}, {y, 0, c}, 
 RegionFunction -> Function[{x, y, z}, 0 <= y <= x - c], 
 PlotRange -> All]
POSTED BY: David Reiss

Thank you so much! I had the function plotted with several others via Show[], and I thought that since these other ones have a bigger range, my function would adjust to that range - obviously it does that before being put into the Show-Box, I didn't think of that. Now it works!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract