Ask Your Question

How do I plot a function undefined in some areas?

asked 2016-09-18 22:02:42 +0200

Lazza gravatar image

I am trying to plot f(x,z) which is undefined in some areas. When I try to plot some other function, I can get it to work easily because Sage restricts the plot to the area where the function is real. E.g.:

plot3d(sqrt(1-x^2-y^2), (x,-5,5), (y,-5,5))

The border is a bit weird, but it works. I cannot get a working plot with my code, however. I also tried to wrap the function with a try ... except statement but I don't know what to return:

var("x y z")
def wrap(exp, a, b):
        return exp(x=a, z=b)
    except ValueError:
        return None

plot3d(lambda x,y: wrap(f, x, y), (x, -t, t), (y, -t, t)).show(aspect_ratio=1)

My function is f and it contains variables x and z.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-09-20 21:37:59 +0200

Try returning NaN (not a number).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2016-09-18 22:02:42 +0200

Seen: 443 times

Last updated: Sep 20 '16