I'm trying to produce a relativistic voigt distribution, the convolution of a relativistic Breit-Wigner distribution and a gaussian function.
MWE:
double relativisticBreitwigner_pdf(double energy, double width, double mass){
double massSquare = pow(mass,2);
double widthSquare = pow(width,2);
double gamma = sqrt(massSquare*(massSquare+widthSquare));
double k = (2*sqrt(2)*mass*width*gamma)/(M_PI*sqrt(massSquare + gamma) );
return k/(pow((pow(energy,2)-massSquare),2) + massSquare*widthSquare);
}
double gaussian_pdf(double energy, double sigma, double mass){
return (1.0/(sigma*sqrt(2*M_PI)))*exp(-(1.0/2.0)*pow((energy-mass)/sigma,2.0));
}
double relativisticVoigt_pdf(double energy, double width, double mass, double sigma, double range=100.0){
auto f = [&](double dummy) { return ( relativisticBreitwigner_pdf(dummy+mass,width,mass)*gaussian_pdf(energy-dummy,sigma,mass) );};
boost::math::quadrature::tanh_sinh<double> integrator;
return integrator.integrate(f,-range,range);
// return boost::math::quadrature::trapezoidal(f,-range,range,sqrt(std::numeric_limits<double>::epsilon()),10000); }
This function relativisticVoigt_pdf(...) correctly produces a relativistic voigt distribution, however there are many 'dips' in the distribution which are incorrect which are due to the value returned from integrator.integrate(f,-range,range); not being correct.
If I reduce the integration range the size/number of these dips is smaller, but then the range of the relativistic voigt distribution is cutoff.
Attached a screenshot showing the relativistic voigt in black with that problem (compared to a nonrelativistic voigt in pink that doesn't have this problem just to check that the values outside of the dips are valid, the black curve should be close to the pink curve but slightly above it to the left of the peak and slightly below it to the right of the peak, as can be seen happens).
I assume the problem is to do with rounding errors in the integration method due to the many small numbers involved, but this is just a guess. Is there a more robust/reliable integrator that works well in this regime?