Is there a bug in heaviside function?

asked 1 year ago

dozius gravatar image

updated 1 year ago

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?

Preview: (hide)

Comments

works fine for me in SageMath version 10.3.beta7

FrédéricC gravatar imageFrédéricC ( 1 year ago )
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 ( 1 year ago )
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 ( 1 year ago )