1
$\begingroup$

Because this is such a simple example I am not going to explain the calculations. I am strictly wondering why I do get errors when plotting it.

Plot3D[(Subscript[x, 1] - 2)^2 + (Subscript[x, 2] - 1)^2, {Subscript[
x, 1], -10, 10}, {Subscript[x, 2], -10, 10}, 
RegionFunction -> Function[{Subscript[x, 1], Subscript[x, 2]}, 
 Subscript[x, 1]^2 - Subscript[x, 2] <= 
 0 && -Subscript[x, 1] - Subscript[x, 2] + 2 <= 2]]

Im not sure what I am doing wrong?

$\endgroup$
1
  • $\begingroup$ Works without error in MMA 10.0.1 $\endgroup$ Dec 7, 2014 at 6:00

1 Answer 1

3
$\begingroup$
Plot3D[(Subscript[x, 1] - 2)^2 + (Subscript[x, 2] - 1)^2,
        {Subscript[x, 1], -10, 10}, {Subscript[x, 2], -10, 10}, 
 RegionFunction -> Function[{x, y}, x^2 - y <= 0 && -x - y + 2 <= 2]]

enter image description here

Note the error message generated by:

Function[{Subscript[x, 1], Subscript[x, 2]}, 
 Subscript[x, 1]^2 - Subscript[x, 2] <= 
   0 && -Subscript[x, 1] - Subscript[x, 2] + 2 <= 2]

enter image description here

See also the explanation and examples in the docs on Function::flpar.

Update:

What If I only want to mark out that area but not remove the rest if the function...

Plot3D[{ConditionalExpression[(x - 2)^2 + (y - 1)^2, Not[x^2 - y <= 0 && -x - y + 2 <= 2]], 
  ConditionalExpression[(x - 2)^2 + (y - 1)^2, x^2 - y <= 0 && -x - y + 2 <= 2]},
  {x, -10, 10}, {y, -10, 10}, PlotStyle -> {Blue, Red}]

enter image description here

$\endgroup$
2
  • $\begingroup$ What If I only want to mark out that area but not remove the rest if the function. By for Eg. The patch that this plot is given being a different colour than the rest. $\endgroup$
    – ALEXANDER
    Dec 7, 2014 at 0:34
  • $\begingroup$ @ALEXANDER, please see the update. $\endgroup$
    – kglr
    Dec 7, 2014 at 1:13

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.