import inspect import sympy def angular_func_sympy(FL, AFB, S3, S4, S5, S7, S8, S9, costheta_l, costheta_k, phi): sintheta_k = sympy.sqrt(1.0 - costheta_k * costheta_k) sintheta_l = sympy.sqrt(1.0 - costheta_l * costheta_l) sintheta_2k = (1.0 - costheta_k * costheta_k) sintheta_2l = (1.0 - costheta_l * costheta_l) sin2theta_k = (2.0 * sintheta_k * costheta_k) cos2theta_l = (2.0 * costheta_l * costheta_l - 1.0) sin2theta_l = (2.0 * sintheta_l * costheta_l) pdf = ((3.0 / 4.0) * (1.0 - FL) * sintheta_2k + FL * costheta_k * costheta_k + (1.0 / 4.0) * (1.0 - FL) * sintheta_2k * cos2theta_l + -1.0 * FL * costheta_k * costheta_k * cos2theta_l + S3 * sintheta_2k * sintheta_2l * sympy.cos(2.0 * phi) + S4 * sin2theta_k * sin2theta_l * sympy.cos(phi) + S5 * sin2theta_k * sintheta_l * sympy.cos(phi) + (4.0 / 3.0) * AFB * sintheta_2k * costheta_l + S7 * sin2theta_k * sintheta_l * sympy.sin(phi) + S8 * sin2theta_k * sin2theta_l * sympy.sin(phi) + S9 * sintheta_2k * sintheta_2l * sympy.sin(2.0 * phi)) return pdf """ kwargs = dict( FL = sympy.Symbol('FL'), AFB = sympy.Symbol('AFB'), S3 = sympy.Symbol('S3'), S4 = sympy.Symbol('S4'), S5 = sympy.Symbol('S5'), S7 = sympy.Symbol('S7'), S8 = sympy.Symbol('S8'), S9 = sympy.Symbol('S9'), costheta_l = sympy.Symbol('costheta_l'), costheta_k = sympy.Symbol('costheta_k'), phi = sympy.Symbol('phi') ) lower_ctl = sympy.Symbol('lower_ctl') upper_ctl = sympy.Symbol('upper_ctl') lower_ctk = sympy.Symbol('lower_ctk') upper_ctk = sympy.Symbol('upper_ctk') lower_phi = sympy.Symbol('lower_phi') upper_phi = sympy.Symbol('upper_phi') sympy_val = angular_func_sympy(**kwargs) print('starting integration') integral = sympy.integrate(sympy_val, (kwargs['costheta_l'], -1, 1), (kwargs['costheta_k'], -1, 1), (kwargs['phi'], -sympy.pi, sympy.pi),) # integral = sympy.integrate(sympy_val, # kwargs['costheta_l'], # kwargs['costheta_k'], # kwargs['phi']) print(integral) fun = sympy.lambdify((lower_ctl, lower_ctk, lower_phi),integral, 'tensorflow') print(inspect.getsource(fun)) """