I have a function U1 which contains a linear combination of trigonometric function, I wanted to Numerically integrate this function U1. Since each trigonometric functions associated with some unknown coefficients. I use coefficient rules to separate the unknown coefficients and associated functions. I later used Nintegrate to carry out numerical integration. But I am getting warnings," Numerical integration converging too slowly, suspect singularity" (NIntegrate::slwcon
, NIntegrate::ncvb
).
how to overcome this?
L2 = 1;
fixedfree = Table[Sin[(2*i - 1)/(2*L2)*\[Pi]*x2], {i, 1, 3}];
fixedfixed = Table[Sin[(i*\[Pi]*x2)/L2], {i, 1, 3}];
barmodes = Flatten[{fixedfree, fixedfixed}];
U1 = Expand[
Total[Table[b[i]*barmodes[[i]], {i, 1, Length[barmodes]}]]];
U1x = Expand[D[U1, {x2, 1}]];
in3 = Expand[(U1x)^2];
in4 = Expand[(U1)^2];
var2 = Table[b[i], {i, 1, Length[barmodes]}]
rules3 = CoefficientRules[in3, var2];
rules3[[All, 2]] = NIntegrate[rules3[[All, 2]], {x2, 0, L2}];
v2 = 0.5*a2*Y2*(FromCoefficientRules[rules3, var2])
rules4 = CoefficientRules[in4, var2];
rules4[[All, 2]] = NIntegrate[rules4[[All, 2]], {x2, 0, L2}];
t2 = 0.5*r*a2*q^2*(FromCoefficientRules[rules4, var2])
Integrate
instead ofNIntegrate
instantly finds all your integrals exactly and with zero error or warning messages $\endgroup$