No surface appear when plotting a function with given constraints
Solution 1:
You define x1
and x2
as:
x1=linspace(0,2,50)
x2=linspace(0,2,50)
so each value of them is between 0
and 2
. Then you edit them with:
x1, x2 = meshgrid(x1, x2)
At this point, x1
and x2
are no longer arrays, but matrices. Anyway, as before, each element within them is still between 0
and 2
.
If you apply this filter:
f[-x1<=0] = nan
then each element of f
becomes nan
, since all elements of x1
are positive, so the expression -x1<=0
evaluates to False
for every element of x1
. The same logic applies for the filter:
f[-x2<=0] = nan
So, indeed, every element of f
is nan
and the plot is empty.
If you try to remove both of the above filters, then you get:
f[3*x1-x1*x2+4*x2-7<=0] = nan
f[2*x1+x2-3<=0] = nan
f[3*x1-4*x2**2-4*x2<=0] = nan