ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 05 Feb 2024 18:54:00 +0100Is there a bug in heaviside function?https://ask.sagemath.org/question/75810/is-there-a-bug-in-heaviside-function/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? Mon, 05 Feb 2024 10:45:19 +0100https://ask.sagemath.org/question/75810/is-there-a-bug-in-heaviside-function/Comment by dan_fulea for <p>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? </p>
https://ask.sagemath.org/question/75810/is-there-a-bug-in-heaviside-function/?comment=75828#post-id-75828Make 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.Mon, 05 Feb 2024 18:54:00 +0100https://ask.sagemath.org/question/75810/is-there-a-bug-in-heaviside-function/?comment=75828#post-id-75828Comment by Emmanuel Charpentier for <p>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? </p>
https://ask.sagemath.org/question/75810/is-there-a-bug-in-heaviside-function/?comment=75814#post-id-75814WorksForMe(TM) in 10.3.beta6.
How do you define `f` ? More generaly, can you give us your *code* ?Mon, 05 Feb 2024 12:18:41 +0100https://ask.sagemath.org/question/75810/is-there-a-bug-in-heaviside-function/?comment=75814#post-id-75814Comment by FrédéricC for <p>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? </p>
https://ask.sagemath.org/question/75810/is-there-a-bug-in-heaviside-function/?comment=75813#post-id-75813works fine for me in SageMath version 10.3.beta7Mon, 05 Feb 2024 11:57:08 +0100https://ask.sagemath.org/question/75810/is-there-a-bug-in-heaviside-function/?comment=75813#post-id-75813