How to use the flavio.math.integrate.nintegrate function in flavio

To help you get started, we’ve selected a few flavio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flav-io / flavio / flavio / physics / bdecays / bvll / test_bvll.py View on Github external
def test_bvll_integrate_pole(self):
        def f(q2):
            # dummy function with a pole at q2=0
            return 1e-10*(1 + 0.1*q2 + 0.01*q2**2)/q2
        from flavio.math.integrate import nintegrate
        from flavio.physics.bdecays.bvll.observables import nintegrate_pole
        self.assertAlmostEqual(nintegrate_pole(f, 0.1, 10)/nintegrate(f, 0.1, 10, epsrel=0.001),
                               1, delta=0.01)
        self.assertAlmostEqual(nintegrate_pole(f, 0.001, 0.01)/nintegrate(f, 0.001, 0.01, epsrel=0.001),
                               1, delta=0.01)
        self.assertAlmostEqual(nintegrate_pole(f, 0.0005, 2)/nintegrate(f, 0.0005, 2, epsrel=0.0001),
                               1, delta=0.03)
        # try whether it also works with a well-behaved function
        def g(q2):
            return 1e-10*(1 + 0.1*q2 + 0.01*q2**2)
        self.assertAlmostEqual(nintegrate_pole(g, 0.1, 10)/nintegrate(g, 0.1, 10, epsrel=0.001),
                               1, delta=0.01)
        self.assertAlmostEqual(nintegrate_pole(g, 0.001, 0.01)/nintegrate(g, 0.001, 0.01, epsrel=0.001),
                               1, delta=0.01)
        self.assertAlmostEqual(nintegrate_pole(g, 0.0005, 2)/nintegrate(g, 0.0005, 2, epsrel=0.001),
                               1, delta=0.01)
github flav-io / flavio / flavio / physics / bdecays / bvll / test_bvll.py View on Github external
def test_bvll_integrate_pole(self):
        def f(q2):
            # dummy function with a pole at q2=0
            return 1e-10*(1 + 0.1*q2 + 0.01*q2**2)/q2
        from flavio.math.integrate import nintegrate
        from flavio.physics.bdecays.bvll.observables import nintegrate_pole
        self.assertAlmostEqual(nintegrate_pole(f, 0.1, 10)/nintegrate(f, 0.1, 10, epsrel=0.001),
                               1, delta=0.01)
        self.assertAlmostEqual(nintegrate_pole(f, 0.001, 0.01)/nintegrate(f, 0.001, 0.01, epsrel=0.001),
                               1, delta=0.01)
        self.assertAlmostEqual(nintegrate_pole(f, 0.0005, 2)/nintegrate(f, 0.0005, 2, epsrel=0.0001),
                               1, delta=0.03)
        # try whether it also works with a well-behaved function
        def g(q2):
            return 1e-10*(1 + 0.1*q2 + 0.01*q2**2)
        self.assertAlmostEqual(nintegrate_pole(g, 0.1, 10)/nintegrate(g, 0.1, 10, epsrel=0.001),
                               1, delta=0.01)
        self.assertAlmostEqual(nintegrate_pole(g, 0.001, 0.01)/nintegrate(g, 0.001, 0.01, epsrel=0.001),
                               1, delta=0.01)
        self.assertAlmostEqual(nintegrate_pole(g, 0.0005, 2)/nintegrate(g, 0.0005, 2, epsrel=0.001),
                               1, delta=0.01)
github flav-io / flavio / flavio / physics / bdecays / bpnunu.py View on Github external
def bpnunu_dbrdq2_int_summed(q2min, q2max, wc_obj, par, B, P):
    def obs(q2):
        return bpnunu_dbrdq2_summed(q2, wc_obj, par, B, P)
    return flavio.math.integrate.nintegrate(obs, q2min, q2max)/(q2max-q2min)
github flav-io / flavio / flavio / physics / bdecays / bplnu.py View on Github external
def BR_binned(q2min, q2max, wc_obj, par, B, P, lep):
    def integrand(q2):
        return dBRdq2(q2, wc_obj, par, B, P, lep)
    return flavio.math.integrate.nintegrate(integrand, q2min, q2max)
github flav-io / flavio / flavio / physics / bdecays / bvll / lfv.py View on Github external
def bvlilj_obs_int(function, q2min, q2max, wc, par, B, V, l1, l2):
    def obs(q2):
        return bvlilj_obs(function, q2, wc, par, B, V, l1, l2)
    return flavio.math.integrate.nintegrate(obs, q2min, q2max)
github flav-io / flavio / flavio / physics / bdecays / bvnunu.py View on Github external
def bvnunu_BRtot_summed(wc_obj, par, B, V):
    def obs(q2):
        return bvnunu_dbrdq2_summed(q2, wc_obj, par, B, V)
    mB = par['m_'+B]
    mV = par['m_'+V]
    q2max = (mB-mV)**2
    q2min = 0
    return flavio.math.integrate.nintegrate(obs, q2min, q2max)
github flav-io / flavio / flavio / physics / kdecays / kpilnu.py View on Github external
def BR_binned(q2min, q2max, wc_obj, par, K, P, lep):
    def integrand(q2):
        return dBRdq2(q2, wc_obj, par, K, P, lep)
    return flavio.math.integrate.nintegrate(integrand, q2min, q2max)
github flav-io / flavio / flavio / physics / bdecays / bvnunu.py View on Github external
def bvnunu_dbrdq2_int_summed(q2min, q2max, wc_obj, par, B, V):
    def obs(q2):
        return bvnunu_dbrdq2_summed(q2, wc_obj, par, B, V)
    return flavio.math.integrate.nintegrate(obs, q2min, q2max)/(q2max-q2min)