0
$\begingroup$

Suppose I need to plot a function $z = x^2 - y^2$ using a 3 dimensional surface plot (Plot3D feature). Assume the $x$ limit for this plot is [x_min, x_max] and y limit is [y_min, y_max]. In my case, x_max is a function of co-ordinate y. How do I incorporate this in the Plot3D command ?

Eg. Plot3D[x^2-y^2, {xlim, x_min, x_max(y)}, {ylim, y_min, y_max}] does not work.

$\endgroup$
6
$\begingroup$

There can be dependency in the limits, the trick is to order the independent variables first:

Plot3D[x^2 - y^2, {y, 0, 1}, {x, 0, y^3}]

enter image description here

$\endgroup$
2
$\begingroup$
Plot3D[x^2 - y^2, 
      {x, 0, 2}, {y, 0, 2},
 RegionFunction -> Function[{x, y}, 0 < x < y^3 + 4 && 0 < y < 2]]

Here, the upper limit of the region is explicit in 0 < x < y^3 + 4.

$\endgroup$
  • $\begingroup$ I am sorry but I didn't understand how we are using the upper limit of x here as a function of y. Say x_max = y^3 + 4. How do we incorporate that using your method. $\endgroup$ – Astronomer Mar 28 '17 at 20:33
  • $\begingroup$ Equivalently, you can give a region as a plotting domain: Plot3D[x^2 - y^2, {x, y} ∈ ImplicitRegion[0 < x < y^3 + 4 && 0 < y < 2, {x, y}]] $\endgroup$ – J. M. will be back soon Mar 29 '17 at 1:40

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