Ask Your Question
0

How do i plot a piecewise function with functional constraints?

asked 2019-12-17 15:34:09 +0200

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-12-17 23:33:00 +0200

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.

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

1 follower

Stats

Asked: 2019-12-17 15:34:09 +0200

Seen: 276 times

Last updated: Dec 17 '19