'Numerical integration for a slow converging integral
I basically have a problem with numerical integrations of this type:
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import quad
# Parameter
T = 94
Eps_inf = 3.05
Eps_s = 19.184544603857724
tau_0 = 1.27*10**-16
tau_CD = 0.34580390675331274
gamma = 0.49
C_pek = 1/Eps_inf - 1/Eps_s
hbar = 6.582119569*10**-16
# Functions
def func(w):
return -4 * 1/(np.pi * C_pek) * Eps(w).imag/abs(Eps(w))**2
def Eps(w):
return Eps_inf + (Eps_s - Eps_inf)/(1 + (1j * w * tau_CD))**gamma
w = np.logspace(-9,80,100000)
y = func(w)
IntegrandS = quad(lambda w: func(w),0,np.inf,limit=100000)[0]
print(f'quadResult: {IntegrandS}')
This gives me the warning: The integral is probably divergent, or slowly convergent.
And the function is indeed slowly converging:

If I put in the upper limit of the integration just a big numer like 1e15 it gives me a result but that result will never converge for higher and higher integration limits.
Is there anyway to treat this function, so that the quad function (or any other integration method, i also tried scipys trapz, giving me the same problem) can deal with this function?
Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
