Ask Your Question

Simple ReLU plot

asked 2024-03-15 06:11:57 +0200

ramesh1600 gravatar image

I am trying to plot this simple ReLU function max(0,x).
But the line is struck at y=0. Can somebody help ?

Here is my code:
plot(max(0,x), -2, 2)

edit retag flag offensive close merge delete


sage: max_symbolic?

FrédéricC gravatar imageFrédéricC ( 2024-03-15 15:29:30 +0200 )edit

thanks. max_symbolic works.

ramesh1600 gravatar imageramesh1600 ( 2024-03-16 14:11:08 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2024-03-15 16:49:32 +0200

Cyrille gravatar image

updated 2024-03-15 16:50:53 +0200

You can try

   f(x) = max_symbolic(x,0);
   plot(f(x), -2, 2)
edit flag offensive delete link more


This worked. Thank you very much. I went and read the max_symbolic documentation, I could not understand why max does not work, but the max_symbolic resolved my problem. Is there a simpler explanation for why python max does not work in the plotting ?

ramesh1600 gravatar imageramesh1600 ( 2024-03-16 13:58:40 +0200 )edit

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


Asked: 2024-03-15 06:10:57 +0200

Seen: 128 times

Last updated: Mar 15