1
$\begingroup$

I have the following function which I want to plot using Plot3D:

(-1 + w + 3 s w)/(2 (-1 + w + 4 s w))

, which is only meaningful for the defined ranges:

(1/4 < s <= 1/2 && 1/(4 s) < w <= 1) || (s > 1/2 && 
   3/(2 + 8 s) < w <= 1)

Is it possible to plot fx like this:

Plot3D[(-1 + w + 3 s w)/(2 (-1 + w + 4 s w)), {s, 0, 3}, {w, 0, 1}]

using the defined ranges instead of numbers?

Does it even make sense to do so?

The current output with the example above looks like this:

enter image description here

$\endgroup$
  • $\begingroup$ Do you have V10? Plot3D[(-1 + w + 3 s w)/(2 (-1 + w + 4 s w)), {s, w} \[Element] ImplicitRegion[(1/4 < s <= 1/2 && 1/(4 s) < w <= 1) || (s > 1/2 && 3/(2 + 8 s) < w <= 1), {s, w}]] $\endgroup$ – Kuba Jun 27 '16 at 12:58
  • $\begingroup$ I am not familiar with V10. $\endgroup$ – Saud Jun 27 '16 at 13:04
  • 1
    $\begingroup$ RegionFunction[] was introduced in v6.0, @Sumit 's answer should work. $\endgroup$ – Feyre Jun 27 '16 at 13:05
  • $\begingroup$ I meant version number. $\endgroup$ – Kuba Jun 27 '16 at 13:05
3
$\begingroup$

You can use RegionFunction to specify the range.

Plot3D[(-1 + w + 3 s w)/(2 (-1 + w + 4 s w)), {s, 0, 3}, {w, 0, 1}, 
 RegionFunction -> Function[{s, w, z}, (1/4 < s <= 1/2 && 1/(4 s) < w <= 1)
 || (s > 1/2 && 3/(2 + 8 s) < w <= 1)]]

enter image description here

$\endgroup$
  • $\begingroup$ Seems to do the job. Thx! One question though. Why do you include "z"? $\endgroup$ – Saud Jun 27 '16 at 13:12
  • 2
    $\begingroup$ @Saud, because RegionFunction expects a function of three variables, even if you only need two for this example. $\endgroup$ – J. M. will be back soon Jun 27 '16 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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