question about plot3d



On 11/17/2012 09:15 AM, Dmitry Shkirmanov wrote:
> f(x,y):=block([],
> if (y<-sqrt(1-x^2) or  y>sqrt(1-x^2)) then return(false),
> sin(x*y));
> plot3d(f(x,y),[x,-1,1],[y,-1,1])$
>
> returns graph of sin(x*y) on the whole square [x,-1,1],[y,-1,1].
> It looks like a bug. Am i wrong?
It is not a bug but a feature. plot3d expects either an expression or 
the name of a function.

By introducing return, your function f no longer produces an expression. 
Thus, when you write f(x,y) inside plot3d, the program is expecting an 
expression so it tries to get one, even before substituting values for x 
and y; the expression passed is sin(x*y) and your command becomes 
equivalent to having written plot3d(sin(x*y),[x,-1,1],[y,-1,1])

When you are dealing with a function, as the one above, and not with 
expression, use only the name of the function; the following will work 
as you expected:

plot3d(f,[x,-1,1],[y,-1,1])$

Regards,
Jaime