Is there a bug in heaviside function?

asked 2024-02-05 10:45:19 +0200

dozius gravatar image

updated 2024-02-05 11:57:26 +0200

FrédéricC gravatar image

Hi all, I have defined a function f = heaviside(x), and then ploted it over [-1,1]. It should plot 0 in [-1,0] and 1 in [0,1]. However, the plot I get is 1 over the whole domain [-1,1]. If I redefine f as f = heaviside(x-0.00000001) -i.e. shifted by a very small value- I get the expected plot. The same happens with unit step function. Is this a bug, or I am missing somthing?

edit retag flag offensive close merge delete

Comments

works fine for me in SageMath version 10.3.beta7

FrédéricC gravatar imageFrédéricC ( 2024-02-05 11:57:08 +0200 )edit
1

WorksForMe(TM) in 10.3.beta6.

How do you define f ? More generaly, can you give us your code ?

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-02-05 12:18:41 +0200 )edit
1

Make sure that x is a variable when defining f. In my case, the following worked:

sage: var('x');
sage: f = heaviside(x)
sage: plot(f, (-1,1))
Launched png viewer for Graphics object consisting of 1 graphics primitive

And the graph was as expected.

dan_fulea gravatar imagedan_fulea ( 2024-02-05 18:54:00 +0200 )edit