Solve Integral A(x)*x^2*cos(nx) w/ Mathematica

  • Context: Mathematica 
  • Thread starter Thread starter randomvar
  • Start date Start date
  • Tags Tags
    Integration Mathematica
Click For Summary
SUMMARY

The discussion focuses on solving the integral I = ∫ A(x)*x²*cos(nx) dx from 0 to infinity using Mathematica. Participants clarify that the integral does not converge unless A(x) is a negative exponential function. A suggested approach involves constructing an interpolating function from experimental values of A and performing a numerical integration using NIntegrate. Additionally, the use of the Fit function is recommended for better approximation of A(x) if its functional form can be guessed.

PREREQUISITES
  • Understanding of integral calculus, specifically improper integrals.
  • Familiarity with Mathematica syntax and functions, particularly Integrate and NIntegrate.
  • Knowledge of interpolation techniques and numerical methods.
  • Experience with fitting functions to data using Mathematica's Fit function.
NEXT STEPS
  • Learn how to use Mathematica's NIntegrate for numerical integration of functions.
  • Study interpolation methods in Mathematica, including the Interpolation function.
  • Explore the Fit function in Mathematica for approximating experimental data.
  • Investigate conditions for convergence of integrals, particularly with oscillatory functions.
USEFUL FOR

Mathematicians, physicists, and engineers who need to evaluate complex integrals numerically, particularly those involving oscillatory functions and experimental data fitting.

randomvar
Messages
1
Reaction score
0
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,
 
Physics 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:
Only if A is a negative exponential will it converge :

<br /> A =\sum _{i=1}^{\infty } A_i e^{-c_i x^i}<br />
 
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.
 

Similar threads

  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 34 ·
2
Replies
34
Views
5K