Ask Your Question
2

How do I plot a function undefined in some areas?

asked 8 years ago

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):
    try:
        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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 8 years ago

Try returning NaN (not a number).

Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 8 years ago

Seen: 541 times

Last updated: Sep 20 '16