# Mathematica integration

• Mathematica
Hi guys,
I need a hint on how to solve this integral using mathematica

I = Integral ( A(x)*x^2*cos(nx) )dx , (0 to infinity)

A is a function of x and infact i have the values of A for different values of x which was obtained experimentally.

I need to find the value of I(the integral) for many values of n say from (n=1 to 250)

Any thoughts would be greatly helpful. Let me know if the question is not clear

Thanks a lot,

Related MATLAB, Maple, Mathematica, LaTeX News on Phys.org
Integrate[A (x)*x^2*Cos[n*x], {x, 0, Infinity}] does not converge so no definite integral... if I understood that correctly.

edit: Integrate[a[x]*x^2*Cos[n*x], {x, 0, Infinity}]. Or is this what you want? a is a function of x in this one not a variable. Here too you will not get a definite integral.

Last edited:
Hepth
Gold Member
Only if A is a negative exponential will it converge :

$$A =\sum _{i=1}^{\infty } A_i e^{-c_i x^i}$$

Since you have experimental values of A, construct an interpolating function then do the numerical integral. Eg

pts=RandomReal[{0,100},50]//Sort;
data=Table[{x,(100+RandomReal[{-.01,.01}])Exp[-.01 x^2]},{x,pts}];
A=Interpolation[data]
Plot[{A[x],100 Exp[-.01 x^2]},{x,0,100},PlotRange->All,PlotStyle->{Automatic,Dashed}]

But note that the interpolation function is only good within your data range.

Plot[A[x],{x,99,1001},PlotRange->All]
A[100000000000]

But if A[x] really does drop off exponentially (as Hepth points out that it must), then you're probably ok to truncate the integral - eg

int=Table[NIntegrate[A[x] x^2 Cos[n x],{x,0,100}],{n,1,100}]
ListPlot[int[[1;;20]],Joined->True,PlotRange->All]

If you have some more information and can guess what the functional form of A(x) is, then it might be better to use the function Fit[data,funs,vars] to the data instead of interpolate.