GSL Incorrect values with numerical Integration -
i have integrand reads
static double integrand(double k , void * params) { long double *p = (long double *)params; long double masssquared = p[0]; long double temp = p[1]; long double sign = p[2]; long double exp = std::exp(-std::sqrt(k*k+masssquared/(temp*temp))); double res = 0; if(sign == -1) { res = k*k*std::log(1-exp(-std::sqrt(k*k+masssquared/(temp*temp)))); } else if(sign == +1) { res = k*k*std::log(1+exp(-std::sqrt(k*k+masssquared/(temp*temp)))); } return res; };
this 1 in class called veffclass.
my integration routine be
long double veffclass::numintinf(long double low, double sign, long double masssquared, long double temp) { //long double res = 0; double = std::sqrt(std::log(c_threshold)*std::log(c_threshold)- masssquared/(temp*temp)); long double stepsize = (up-low)/c_intsteps; long double par[3] = {masssquared, temp, sign}; if(temp == 0) return 0; gsl_integration_workspace *w = gsl_integration_workspace_alloc(5e+5); double result, error; gsl_function f; f.function = &veffclass::integrand; f.params = ∥ gsl_integration_qags(&f, c_threshold, up, 1e-07, 0, 5e+5, w, &result, &error); gsl_integration_workspace_free(w); return result; }
with c_threshold = 1e-3;
if run numintinf(10^-3, +1 , 100, 500) result 1.83038. result given maple ~ 6*10^9 . if use simple simpsons 1/3 method differes 1% maple result.
can point me error?
thanks suggestions
whenever ask question involves numerical results (and bugs) need provide concise code can analyze , run reproduce original problem. yes, information missing. need
(1) concise code (we don't need veffclass
!) gsl integration (you partially provided - code still quite complicated stack overflow purposes).
(2) concise code implementation of simpson-rule.
(3) snapshot of maple calculation.
(2) , (3) quite important because question arises due fact methods (2) , (3) disagree (1), assumed incorrect answer. why did assume (1) incorrect , not other way around? have analytical solution check numbers?
when analyzed, in wolfram mathematica, integrand parameters values provided in comment, got answer consistent gsl calculation. can't reproduce problem , without (2) + (3) can guess went wrong...
i attached snapshot of mathematica notebook.
Comments
Post a Comment