class_docstr: The DiracDelta function and its derivatives.
  
  Explanation
  ===========
  
  DiracDelta is not an ordinary function. It can be rigorously defined either
  as a distribution or as a measure.
  
  DiracDelta only makes sense in definite integrals, and in particular,
  integrals of the form ``Integral(f(x)*DiracDelta(x - x0), (x, a, b))``,
  where it equals ``f(x0)`` if ``a <= x0 <= b`` and ``0`` otherwise. Formally,
  DiracDelta acts in some ways like a function that is ``0`` everywhere except
  at ``0``, but in many ways it also does not. It can often be useful to treat
  DiracDelta in formal ways, building up and manipulating expressions with
  delta functions (which may eventually be integrated), but care must be taken
  to not treat it as a real function. SymPy's ``oo`` is similar. It only
  truly makes sense formally in certain contexts (such as integration limits),
  but SymPy allows its use everywhere, and it tries to be consistent with
  operations on it (like ``1/oo``), but it is easy to get into trouble and get
  wrong results if ``oo`` is treated too much like a number. Similarly, if
  DiracDelta is treated too much like a function, it is easy to get wrong or
  nonsensical results.
  
  DiracDelta function has the following properties:
  
  1) $\frac{d}{d x} \theta(x) = \delta(x)$
  2) $\int_{-\infty}^\infty \delta(x - a)f(x)\, dx = f(a)$ and $\int_{a-
     \epsilon}^{a+\epsilon} \delta(x - a)f(x)\, dx = f(a)$
  3) $\delta(x) = 0$ for all $x \neq 0$
  4) $\delta(g(x)) = \sum_i \frac{\delta(x - x_i)}{\|g'(x_i)\|}$ where $x_i$
     are the roots of $g$
  5) $\delta(-x) = \delta(x)$
  
  Derivatives of ``k``-th order of DiracDelta have the following properties:
  
  6) $\delta(x, k) = 0$ for all $x \neq 0$
  7) $\delta(-x, k) = -\delta(x, k)$ for odd $k$
  8) $\delta(-x, k) = \delta(x, k)$ for even $k$
  
  Examples
  ========
  
  >>> from sympy import DiracDelta, diff, pi
  >>> from sympy.abc import x, y
  
  >>> DiracDelta(x)
  DiracDelta(x)
  >>> DiracDelta(1)
  0
  >>> DiracDelta(-1)
  0
  >>> DiracDelta(pi)
  0
  >>> DiracDelta(x - 4).subs(x, 4)
  DiracDelta(0)
  >>> diff(DiracDelta(x))
  DiracDelta(x, 1)
  >>> diff(DiracDelta(x - 1), x, 2)
  DiracDelta(x - 1, 2)
  >>> diff(DiracDelta(x**2 - 1), x, 2)
  2*(2*x**2*DiracDelta(x**2 - 1, 2) + DiracDelta(x**2 - 1, 1))
  >>> DiracDelta(3*x).is_simple(x)
  True
  >>> DiracDelta(x**2).is_simple(x)
  False
  >>> DiracDelta((x**2 - 1)*y).expand(diracdelta=True, wrt=x)
  DiracDelta(x - 1)/(2*Abs(y)) + DiracDelta(x + 1)/(2*Abs(y))
  
  See Also
  ========
  
  Heaviside
  sympy.simplify.simplify.simplify, is_simple
  sympy.functions.special.tensor_functions.KroneckerDelta
  
  References
  ==========
  
  .. [1] https://mathworld.wolfram.com/DeltaFunction.html
class_docstr_tok: ["The","DiracDelta","function","and","its","derivatives",".","Explanation","===========","DiracDelta","is","not","an","ordinary","function",".","It","can","be","rigorously","defined","either","as","a","distribution","or","as","a","measure",".","DiracDelta","only","makes","sense","in","definite","integrals",",","and","in","particular",",","integrals","of","the","form","``","Integral","(","f","(","x",")","*","DiracDelta","(","x","-","x0",")",",","(","x",",","a",",","b",")",")","``",",","where","it","equals","``","f","(","x0",")","``","if","``","a","<","=","x0","<","=","b","``","and","``","0","``","otherwise",".","Formally",",","DiracDelta","acts","in","some","ways","like","a","function","that","is","``","0","``","everywhere","except","at","``","0","``",",","but","in","many","ways","it","also","does","not",".","It","can","often","be","useful","to","treat","DiracDelta","in","formal","ways",",","building","up","and","manipulating","expressions","with","delta","functions","(","which","may","eventually","be","integrated",")",",","but","care","must","be","taken","to","not","treat","it","as","a","real","function",".","SymPy","'s","``","oo","``","is","similar",".","It","only","truly","makes","sense","formally","in","certain","contexts","(","such","as","integration","limits",")",",","but","SymPy","allows","its","use","everywhere",",","and","it","tries","to","be","consistent","with","operations","on","it","(","like","``","1\/oo","``",")",",","but","it","is","easy","to","get","into","trouble","and","get","wrong","results","if","``","oo","``","is","treated","too","much","like","a","number",".","Similarly",",","if","DiracDelta","is","treated","too","much","like","a","function",",","it","is","easy","to","get","wrong","or","nonsensical","results",".","DiracDelta","function","has","the","following","properties",":","1",")","$","\\frac","{","d","}","{","d","x","}","\\theta","(","x",")","=","\\delta","(","x",")","$","2",")","$","\\int_","{","-\\infty","}","^\\infty","\\delta","(","x","-","a",")","f","(","x",")","\\",",","dx","=","f","(","a",")","$","and","$","\\int_","{","a-","\\epsilon","}","^","{","a+\\epsilon","}","\\delta","(","x","-","a",")","f","(","x",")","\\",",","dx","=","f","(","a",")","$","3",")","$","\\delta","(","x",")","=","0","$","for","all","$","x","\\neq","0","$","4",")","$","\\delta","(","g","(","x",")",")","=","\\sum_i","\\frac","{","\\delta","(","x","-","x_i",")","}","{","\\|g","'","(","x_i",")","\\|","}","$","where","$","x_i","$","are","the","roots","of","$","g","$","5",")","$","\\delta","(","-x",")","=","\\delta","(","x",")","$","Derivatives","of","``","k","``","-th","order","of","DiracDelta","have","the","following","properties",":","6",")","$","\\delta","(","x",",","k",")","=","0","$","for","all","$","x","\\neq","0","$","7",")","$","\\delta","(","-x",",","k",")","=","-\\delta","(","x",",","k",")","$","for","odd","$","k","$","8",")","$","\\delta","(","-x",",","k",")","=","\\delta","(","x",",","k",")","$","for","even","$","k","$","Examples","========",">",">",">","from","sympy","import","DiracDelta",",","diff",",","pi",">",">",">","from","sympy.abc","import","x",",","y",">",">",">","DiracDelta","(","x",")","DiracDelta","(","x",")",">",">",">","DiracDelta","(","1",")","0",">",">",">","DiracDelta","(","-1",")","0",">",">",">","DiracDelta","(","pi",")","0",">",">",">","DiracDelta","(","x","-","4",")",".subs","(","x",",","4",")","DiracDelta","(","0",")",">",">",">","diff","(","DiracDelta","(","x",")",")","DiracDelta","(","x",",","1",")",">",">",">","diff","(","DiracDelta","(","x","-","1",")",",","x",",","2",")","DiracDelta","(","x","-","1",",","2",")",">",">",">","diff","(","DiracDelta","(","x","*","*","2","-","1",")",",","x",",","2",")","2","*","(","2","*","x","*","*","2","*","DiracDelta","(","x","*","*","2","-","1",",","2",")","+","DiracDelta","(","x","*","*","2","-","1",",","1",")",")",">",">",">","DiracDelta","(","3","*","x",")",".is_simple","(","x",")","True",">",">",">","DiracDelta","(","x","*","*","2",")",".is_simple","(","x",")","False",">",">",">","DiracDelta","(","(","x","*","*","2","-","1",")","*","y",")",".expand","(","diracdelta=True",",","wrt=x",")","DiracDelta","(","x","-","1",")","\/","(","2","*","Abs","(","y",")",")","+","DiracDelta","(","x","+","1",")","\/","(","2","*","Abs","(","y",")",")","See","Also","========","Heaviside","sympy.simplify.simplify.simplify",",","is_simple","sympy.functions.special.tensor_functions.KroneckerDelta","References","==========","..","[","1","]","https",":","\/\/mathworld.wolfram.com\/DeltaFunction.html"]
docstr: Compute a simplified representation of the function using
  property number 4. Pass ``wrt`` as a hint to expand the expression
  with respect to a particular variable.
  
  Explanation
  ===========
  
  ``wrt`` is:
  
  - a variable with respect to which a DiracDelta expression will
  get expanded.
  
  Examples
  ========
  
  >>> from sympy import DiracDelta
  >>> from sympy.abc import x, y
  
  >>> DiracDelta(x*y).expand(diracdelta=True, wrt=x)
  DiracDelta(x)/Abs(y)
  >>> DiracDelta(x*y).expand(diracdelta=True, wrt=y)
  DiracDelta(y)/Abs(x)
  
  >>> DiracDelta(x**2 + x - 2).expand(diracdelta=True, wrt=x)
  DiracDelta(x - 1)/3 + DiracDelta(x + 2)/3
  
  See Also
  ========
  
  is_simple, Diracdelta
docstr_tok: ["Compute","a","simplified","representation","of","the","function","using","property","number","4",".","Pass","``","wrt","``","as","a","hint","to","expand","the","expression","with","respect","to","a","particular","variable",".","Explanation","===========","``","wrt","``","is",":","-","a","variable","with","respect","to","which","a","DiracDelta","expression","will","get","expanded",".","Examples","========",">",">",">","from","sympy","import","DiracDelta",">",">",">","from","sympy.abc","import","x",",","y",">",">",">","DiracDelta","(","x","*","y",")",".expand","(","diracdelta=True",",","wrt=x",")","DiracDelta","(","x",")","\/Abs","(","y",")",">",">",">","DiracDelta","(","x","*","y",")",".expand","(","diracdelta=True",",","wrt=y",")","DiracDelta","(","y",")","\/Abs","(","x",")",">",">",">","DiracDelta","(","x","*","*","2","+","x","-","2",")",".expand","(","diracdelta=True",",","wrt=x",")","DiracDelta","(","x","-","1",")","\/3","+","DiracDelta","(","x","+","2",")","\/3","See","Also","========","is_simple",",","Diracdelta"]
code: def _eval_expand_diracdelta(self, **hints):
      """
      Compute a simplified representation of the function using
      property number 4. Pass ``wrt`` as a hint to expand the expression
      with respect to a particular variable.
  
      Explanation
      ===========
  
      ``wrt`` is:
  
      - a variable with respect to which a DiracDelta expression will
      get expanded.
  
      Examples
      ========
  
      >>> from sympy import DiracDelta
      >>> from sympy.abc import x, y
  
      >>> DiracDelta(x*y).expand(diracdelta=True, wrt=x)
      DiracDelta(x)/Abs(y)
      >>> DiracDelta(x*y).expand(diracdelta=True, wrt=y)
      DiracDelta(y)/Abs(x)
  
      >>> DiracDelta(x**2 + x - 2).expand(diracdelta=True, wrt=x)
      DiracDelta(x - 1)/3 + DiracDelta(x + 2)/3
  
      See Also
      ========
  
      is_simple, Diracdelta
  
      """
      wrt = hints.get("wrt", None)
      if wrt is None:
          free = self.free_symbols
          if len(free) == 1:
              wrt = free.pop()
          else:
              raise TypeError(
                  filldedent(
                      """
              When there is more than 1 free symbol or variable in the expression,
              the 'wrt' keyword is required as a hint to expand when using the
              DiracDelta hint."""
                  )
              )
  
      if not self.args[0].has(wrt) or (
          len(self.args) > 1 and self.args[1] != 0
      ):
          return self
      try:
          argroots = roots(self.args[0], wrt)
          result = 0
          valid = True
          darg = abs(diff(self.args[0], wrt))
          for r, m in argroots.items():
              if r.is_real is not False and m == 1:
                  result += self.func(wrt - r) / darg.subs(wrt, r)
              else:
                  # don't handle non-real and if m != 1 then
                  # a polynomial will have a zero in the derivative (darg)
                  # at r
                  valid = False
                  break
          if valid:
              return result
      except PolynomialError:
          pass
      return self
  
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 3 for calling the DiracDelta obj's underlying member method code with example usage: obj._eval_expand_diracdelta() and returns: self, self, result