Hi people!
I was trying to do Dirac's delta from gaussian definition to pedagogical
purposes but I had a problem about the return as you can see below; so why
does not sympy return a numeric value in this case and how can it make that?
===============================================================
import sympy as sy
import numpy as np
x=sy.Symbol('x')
a=sy.cos(x) #Test function
def Dirac(x, x0, alpha):
f=(alpha/(np.pi**0.5))*sy.exp(-alpha**2*(x-x0)**2)
return f
dic=sy.integrate(a*Dirac(x, 10, 50), (x, -sy.oo, sy.oo))
dic.simplify()
output
sqrt(pi)*(-225.675833419103*cos(1)**4 - 722.162666941128*cos(1)**8 -
0.564189583547756 + 288.865066776451*cos(1)**10 +
28.2094791773878*cos(1)**2 + 631.892333573487*cos(1)**6)*exp(-1/10000)
Also I had a better return if I change np.pi to say.pi but there is still a
problem, it is not a concrete value.
output
(-400*cos(1)**4 - 1280*cos(1)**8 - 1 + 512*cos(1)**10 + 50*cos(1)**2 +
1120*cos(1)**6)*exp(-1/10000)
Of course as I increase alpha value the output will be equal to cos
function evaluated in 10.
Thanks.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/be1dc3b5-1639-4178-a1e5-9255b5c16cd1%40googlegroups.com.