class_docstr: Heaviside step function.
  
  Explanation
  ===========
  
  The Heaviside step function has the following properties:
  
  1) $\frac{d}{d x} \theta(x) = \delta(x)$
  2) $\theta(x) = \begin{cases} 0 & \text{for}\: x < 0 \\ \frac{1}{2} &
     \text{for}\: x = 0 \\1 & \text{for}\: x > 0 \end{cases}$
  3) $\frac{d}{d x} \max(x, 0) = \theta(x)$
  
  Heaviside(x) is printed as $\theta(x)$ with the SymPy LaTeX printer.
  
  The value at 0 is set differently in different fields. SymPy uses 1/2,
  which is a convention from electronics and signal processing, and is
  consistent with solving improper integrals by Fourier transform and
  convolution.
  
  To specify a different value of Heaviside at ``x=0``, a second argument
  can be given. Using ``Heaviside(x, nan)`` gives an expression that will
  evaluate to nan for x=0.
  
  .. versionchanged:: 1.9 ``Heaviside(0)`` now returns 1/2 (before: undefined)
  
  Examples
  ========
  
  >>> from sympy import Heaviside, nan
  >>> from sympy.abc import x
  >>> Heaviside(9)
  1
  >>> Heaviside(-9)
  0
  >>> Heaviside(0)
  1/2
  >>> Heaviside(0, nan)
  nan
  >>> (Heaviside(x) + 1).replace(Heaviside(x), Heaviside(x, 1))
  Heaviside(x, 1) + 1
  
  See Also
  ========
  
  DiracDelta
  
  References
  ==========
  
  .. [1] https://mathworld.wolfram.com/HeavisideStepFunction.html
  .. [2] https://dlmf.nist.gov/1.16#iv
class_docstr_tok: ["Heaviside","step","function",".","Explanation","===========","The","Heaviside","step","function","has","the","following","properties",":","1",")","$","\\frac","{","d","}","{","d","x","}","\\theta","(","x",")","=","\\delta","(","x",")","$","2",")","$","\\theta","(","x",")","=","\\begin","{","cases","}","0","&","\\text","{","for","}","\\",":","x","<","0","\\\\","\\frac","{","1","}","{","2","}","&","\\text","{","for","}","\\",":","x","=","0","\\\\1","&","\\text","{","for","}","\\",":","x",">","0","\\end","{","cases","}","$","3",")","$","\\frac","{","d","}","{","d","x","}","\\max","(","x",",","0",")","=","\\theta","(","x",")","$","Heaviside","(","x",")","is","printed","as","$","\\theta","(","x",")","$","with","the","SymPy","LaTeX","printer",".","The","value","at","0","is","set","differently","in","different","fields",".","SymPy","uses","1\/2",",","which","is","a","convention","from","electronics","and","signal","processing",",","and","is","consistent","with","solving","improper","integrals","by","Fourier","transform","and","convolution",".","To","specify","a","different","value","of","Heaviside","at","``","x=0","``",",","a","second","argument","can","be","given",".","Using","``","Heaviside","(","x",",","nan",")","``","gives","an","expression","that","will","evaluate","to","nan","for","x=0",".","..","versionchanged",":",":","1.9","``","Heaviside","(","0",")","``","now","returns","1\/2","(","before",":","undefined",")","Examples","========",">",">",">","from","sympy","import","Heaviside",",","nan",">",">",">","from","sympy.abc","import","x",">",">",">","Heaviside","(","9",")","1",">",">",">","Heaviside","(","-9",")","0",">",">",">","Heaviside","(","0",")","1\/2",">",">",">","Heaviside","(","0",",","nan",")","nan",">",">",">","(","Heaviside","(","x",")","+","1",")",".replace","(","Heaviside","(","x",")",",","Heaviside","(","x",",","1",")",")","Heaviside","(","x",",","1",")","+","1","See","Also","========","DiracDelta","References","==========","..","[","1","]","https",":","\/\/mathworld.wolfram.com\/HeavisideStepFunction.html","..","[","2","]","https",":","\/\/dlmf.nist.gov\/1.16","#","iv"]
docstr: Represents Heaviside in a Piecewise form.
  
  Examples
  ========
  
  >>> from sympy import Heaviside, Piecewise, Symbol, nan
  >>> x = Symbol('x')
  
  >>> Heaviside(x).rewrite(Piecewise)
  Piecewise((0, x < 0), (1/2, Eq(x, 0)), (1, True))
  
  >>> Heaviside(x,nan).rewrite(Piecewise)
  Piecewise((0, x < 0), (nan, Eq(x, 0)), (1, True))
  
  >>> Heaviside(x - 5).rewrite(Piecewise)
  Piecewise((0, x < 5), (1/2, Eq(x, 5)), (1, True))
  
  >>> Heaviside(x**2 - 1).rewrite(Piecewise)
  Piecewise((0, x**2 < 1), (1/2, Eq(x**2, 1)), (1, True))
docstr_tok: ["Represents","Heaviside","in","a","Piecewise","form",".","Examples","========",">",">",">","from","sympy","import","Heaviside",",","Piecewise",",","Symbol",",","nan",">",">",">","x","=","Symbol","(","'","x","'",")",">",">",">","Heaviside","(","x",")",".rewrite","(","Piecewise",")","Piecewise","(","(","0",",","x","<","0",")",",","(","1\/2",",","Eq","(","x",",","0",")",")",",","(","1",",","True",")",")",">",">",">","Heaviside","(","x",",","nan",")",".rewrite","(","Piecewise",")","Piecewise","(","(","0",",","x","<","0",")",",","(","nan",",","Eq","(","x",",","0",")",")",",","(","1",",","True",")",")",">",">",">","Heaviside","(","x","-","5",")",".rewrite","(","Piecewise",")","Piecewise","(","(","0",",","x","<","5",")",",","(","1\/2",",","Eq","(","x",",","5",")",")",",","(","1",",","True",")",")",">",">",">","Heaviside","(","x","*","*","2","-","1",")",".rewrite","(","Piecewise",")","Piecewise","(","(","0",",","x","*","*","2","<","1",")",",","(","1\/2",",","Eq","(","x","*","*","2",",","1",")",")",",","(","1",",","True",")",")"]
code: def _eval_rewrite_as_Piecewise(self, arg, H0=None, **kwargs):
      """
      Represents Heaviside in a Piecewise form.
  
      Examples
      ========
  
      >>> from sympy import Heaviside, Piecewise, Symbol, nan
      >>> x = Symbol('x')
  
      >>> Heaviside(x).rewrite(Piecewise)
      Piecewise((0, x < 0), (1/2, Eq(x, 0)), (1, True))
  
      >>> Heaviside(x,nan).rewrite(Piecewise)
      Piecewise((0, x < 0), (nan, Eq(x, 0)), (1, True))
  
      >>> Heaviside(x - 5).rewrite(Piecewise)
      Piecewise((0, x < 5), (1/2, Eq(x, 5)), (1, True))
  
      >>> Heaviside(x**2 - 1).rewrite(Piecewise)
      Piecewise((0, x**2 < 1), (1/2, Eq(x**2, 1)), (1, True))
  
      """
      if H0 == 0:
          return Piecewise((0, arg <= 0), (1, True))
      if H0 == 1:
          return Piecewise((0, arg < 0), (1, True))
      return Piecewise((0, arg < 0), (H0, Eq(arg, 0)), (1, True))
  
imports: from sympy.core import S, diff
  from sympy.core.function import Function, ArgumentIndexError
  from sympy.core.logic import fuzzy_not
  from sympy.core.relational import Eq, Ne
  from sympy.functions.elementary.complexes import im, sign
  from sympy.functions.elementary.piecewise import Piecewise
  from sympy.polys.polyerrors import PolynomialError
  from sympy.polys.polyroots import roots
  from sympy.utilities.misc import filldedent
label_desc: Use image node_id 5 for calling the Heaviside obj's underlying member method code with example usage: obj._eval_rewrite_as_Piecewise(arg, H0) and returns: Piecewise, Piecewise, Piecewise