DiracDelta does not seem to be implemented numerically. As you spotted, integrate() does the job, whereas Integral() Fails, this is definitely a bug.
You can't evaluate the integral numerically, even if it was implemented. Vinzent On 1 Jul., 17:01, wflynny <[email protected]> wrote: > I tried the following code. The first portion is strictly trying to > integrate sympy's DiracDelta numerically. It obviously fails. The > second, however, is trying to use sympy to do it in different ways. > > import sympy as sp > from sympy import oo,I,cos,sin,exp > from scipy.integrate import quad, inf > > >>> print quad(lambda x: sp.DiracDelta(x), -1, 1) > >>> print quad(lambda x: sp.DiracDelta(x), -100, 100) > >>> print quad(lambda x: sp.DiracDelta(x), -10000000, 10000000) > >>> print quad(lambda x: sp.DiracDelta(x), -inf, inf) > > Warning: The maximum number of subdivisions (50) has been achieved. > If increasing the limit yields no improvement it is advised to > analyze > the integrand in order to determine the difficulties. If the > position of a > local difficulty can be determined (singularity, discontinuity) one > will > probably gain from splitting up the interval and calling the > integrator > on the subranges. Perhaps a special-purpose integrator should be > used. > (-1.#IND, 1.#QNAN) > Warning: The maximum number of subdivisions (50) has been achieved. > If increasing the limit yields no improvement it is advised to > analyze > the integrand in order to determine the difficulties. If the > position of a > local difficulty can be determined (singularity, discontinuity) one > will > probably gain from splitting up the interval and calling the > integrator > on the subranges. Perhaps a special-purpose integrator should be > used. > (-1.#IND, 1.#QNAN) > Warning: The maximum number of subdivisions (50) has been achieved. > If increasing the limit yields no improvement it is advised to > analyze > the integrand in order to determine the difficulties. If the > position of a > local difficulty can be determined (singularity, discontinuity) one > will > probably gain from splitting up the interval and calling the > integrator > on the subranges. Perhaps a special-purpose integrator should be > used. > (-1.#IND, 1.#QNAN) > (0.0, 0.0) > > >>> x = sp.Symbol('x') > >>> e = sp.DiracDelta(x) > >>> print sp.integrate(e, (x,-oo,oo)) > >>> print sp.Integral(e, (x,-oo,oo)) > >>> print sp.Integral(e, (x,-oo,oo)).evalf() > >>> print sp.Integral(e, (x,-oo,oo)).evalf(method='mpmath') > >>> print sp.Integral(e, (x,-oo,oo)).evalf(method='scipy') > >>> print sp.Integral(e, (x,-oo,oo)).evalf(method='numpy') > >>> print sp.Integral(e, (x,-oo,oo)).evalf(method='') > > 1 > Integral(DiracDelta(x), (x, -oo, oo)) > Integral(DiracDelta(x), (x, -oo, oo)) > Integral(DiracDelta(x), (x, -oo, oo)) > Integral(DiracDelta(x), (x, -oo, oo)) > Integral(DiracDelta(x), (x, -oo, oo)) > Integral(DiracDelta(x), (x, -oo, oo)) > > I figure the first couple should work. The last two were just wild > guesses. Is there way to numerically integrate or at least quickly > symbolically integrate the DiracDelta? Maybe using mpmath? > > -wflynny --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
