First time here? Check out the FAQ!

Ask Your Question
0

How do i plot a piecewise function with functional constraints?

asked 5 years ago

mattiav gravatar image

I have to plot a function T(x,x) which equals xy if xy>0 and x+y otherwise. I have defined the function:

def T(x,y):
   if (x*y>0):
    return x*y
   else:
    return x+y

but it does not work.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 5 years ago

eric_g gravatar image

To plot a Python function (i.e. a function defined by means of def), simply provide the function's name to the plot function. In your case this is T and not T(x, y):

plot3d(T, (-2, 2), (-2, 2))

works well with the function T that you have defined.

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

1 follower

Stats

Asked: 5 years ago

Seen: 394 times

Last updated: Dec 17 '19