Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

i need to integrate over my data, which is denoted as {q, I},here I is the Intensity i need to obtain the form of the following integration( its not a numeric integration, because it contain x, next we need to plot over x ranges)

 gamma[x_]:=Integrate[i*q^2*Cos[q*x],{q,0,Infinity}]/Integrate[i*q^2,{q,0,Infinity}]

and here problems come, the data i posted next is just from q ranges 0.1-1.8, how can i Integrate from o to Infinity, i need to extrapolation. function I1 is the extrapolation function of q ranges 0-0.1

 I1 = 11922 Exp[-217.2136 q^2];

function I3 is the extrapolation function of q ranges 1.8-Infinity

 I3 = 23.6631/q^4

and I2 is from the data set in the following

i hope i expressed it clear

data={{0.06781, 8484.9}, {0.07145, 8104.34}, {0.07508, 7511.06}, {0.07872, 
  6941.88}, {0.08236, 6731.36}, {0.08599, 5949.97}, {0.08963, 
  5077.74}, {0.09327, 4354.2}, {0.0969, 3756.52}, {0.10054, 
  3259.68}, {0.10418, 2853.38}, {0.10781, 2504.39}, {0.11145, 
  2212.84}, {0.11509, 1959.85}, {0.11873, 1746.78}, {0.12236, 
  1563.75}, {0.126, 1407.37}, {0.12964, 1268.35}, {0.13327, 
  1146.27}, {0.13691, 1042.39}, {0.14055, 953.417}, {0.14418, 
  870.465}, {0.14782, 799.707}, {0.15146, 737.023}, {0.15509, 
  679.906}, {0.15873, 628.893}, {0.16237, 584.248}, {0.16601, 
  545.282}, {0.16964, 507.971}, {0.17328, 475.35}, {0.17692, 
  444.392}, {0.18055, 416.804}, {0.18419, 392.803}, {0.18783, 
  371.445}, {0.19146, 351.733}, {0.1951, 334.393}, {0.19874, 
  315.427}, {0.20237, 300.287}, {0.20601, 285.826}, {0.20965, 
  273.292}, {0.21329, 262.379}, {0.21692, 251.135}, {0.22056, 
  239.252}, {0.2242, 230.232}, {0.22783, 222.497}, {0.23147, 
  213.946}, {0.23511, 205.512}, {0.23874, 197.638}, {0.24238, 
  191.972}, {0.24602, 186.409}, {0.24965, 180.46}, {0.25329, 
  175.138}, {0.25693, 169.796}, {0.26056, 165.13}, {0.2642, 
  161.325}, {0.26784, 157.513}, {0.27148, 153.733}, {0.27511, 
  149.522}, {0.27875, 146.791}, {0.28239, 143.153}, {0.28602, 
  140.23}, {0.28966, 137.172}, {0.2933, 134.419}, {0.29693, 
  132.738}, {0.30057, 130.481}, {0.30421, 129.09}, {0.30784, 
  126.987}, {0.31148, 124.435}, {0.31512, 121.708}, {0.31876, 
  120.509}, {0.32239, 118.925}, {0.32603, 117.507}, {0.32967, 
  116.602}, {0.3333, 114.86}, {0.33694, 114.622}, {0.34058, 
  113.327}, {0.34421, 112.26}, {0.34785, 110.94}, {0.35149, 
  110.31}, {0.35512, 109.351}, {0.35876, 109.165}, {0.3624, 
  107.605}, {0.36604, 107.1}, {0.36967, 107.072}, {0.37331, 
  106.396}, {0.37695, 105.881}, {0.38058, 105.079}, {0.38422, 
  104.814}, {0.38786, 104.518}, {0.39149, 104.239}, {0.39513, 
  104.218}, {0.39877, 104.616}, {0.4024, 104.247}, {0.40604, 
  104.502}, {0.40968, 104.512}, {0.41332, 104.647}, {0.41695, 
  104.856}, {0.42059, 104.842}, {0.42423, 104.808}, {0.42786, 
  106.149}, {0.4315, 106.071}, {0.43514, 106.709}, {0.43877, 
  107.227}, {0.44241, 107.229}, {0.44605, 108.764}, {0.44968, 
  109.394}, {0.45332, 110.322}, {0.45696, 110.856}, {0.4606, 
  111.624}, {0.46423, 112.749}, {0.46787, 114.406}, {0.47151, 
  115.42}, {0.47514, 116.616}, {0.47878, 117.699}, {0.48242, 
  119.237}, {0.48605, 121.019}, {0.48969, 123.189}, {0.49333, 
  124.483}, {0.49696, 125.923}, {0.5006, 128.118}, {0.50424, 
  129.74}, {0.50788, 131.626}, {0.51151, 133.838}, {0.51515, 
  136.143}, {0.51879, 138.442}, {0.52242, 141.053}, {0.52606, 
  143.342}, {0.5297, 145.457}, {0.53333, 147.548}, {0.53697, 
  149.772}, {0.54061, 152.372}, {0.54424, 154.745}, {0.54788, 
  156.967}, {0.55152, 159.494}, {0.55516, 161.299}, {0.55879, 
  163.617}, {0.56243, 166.065}, {0.56607, 168.23}, {0.5697, 
  169.203}, {0.57334, 170.825}, {0.57698, 172.429}, {0.58061, 
  173.287}, {0.58425, 174.083}, {0.58789, 175.532}, {0.59152, 
  176.836}, {0.59516, 177.118}, {0.5988, 176.328}, {0.60244, 
  176.706}, {0.60607, 175.924}, {0.60971, 175.741}, {0.61335, 
  175.363}, {0.61698, 175.389}, {0.62062, 174.525}, {0.62426, 
  173.079}, {0.62789, 171.666}, {0.63153, 170.46}, {0.63517, 
  168.736}, {0.6388, 167.342}, {0.64244, 165.309}, {0.64608, 
  163.865}, {0.64972, 161.676}, {0.65335, 159.474}, {0.65699, 
  157.696}, {0.66063, 155.701}, {0.66426, 153.095}, {0.6679, 
  150.474}, {0.67154, 148.005}, {0.67517, 145.32}, {0.67881, 
  143.644}, {0.68245, 141.367}, {0.68608, 138.666}, {0.68972, 
  136.463}, {0.69336, 133.792}, {0.697, 131.181}, {0.70063, 
  128.582}, {0.70427, 126.332}, {0.70791, 123.564}, {0.71154, 
  121.367}, {0.71518, 118.912}, {0.71882, 116.346}, {0.72245, 
  113.677}, {0.72609, 110.937}, {0.72973, 108.678}, {0.73336, 
  106.565}, {0.737, 104.007}, {0.74064, 101.485}, {0.74427, 
  99.3778}, {0.74791, 96.6665}, {0.75155, 94.4102}, {0.75519, 
  92.0078}, {0.75882, 89.8159}, {0.76246, 87.9642}, {0.7661, 
  86.4317}, {0.76973, 84.2645}, {0.77337, 82.3022}, {0.77701, 
  80.6899}, {0.78064, 78.6728}, {0.78428, 76.7569}, {0.78792, 
  75.3695}, {0.79155, 73.8918}, {0.79519, 72.5105}, {0.79883, 
  71.0565}, {0.80247, 69.4262}, {0.8061, 67.8192}, {0.80974, 
  66.4008}, {0.81338, 65.1667}, {0.81701, 63.8111}, {0.82065, 
  62.6912}, {0.82429, 61.6939}, {0.82792, 60.6722}, {0.83156, 
  59.6988}, {0.8352, 58.3351}, {0.83883, 57.1573}, {0.84247, 
  56.3272}, {0.84611, 55.2564}, {0.84975, 54.3547}, {0.85338, 
  53.3978}, {0.85702, 52.1346}, {0.86066, 51.3827}, {0.86429, 
  50.4844}, {0.86793, 49.6377}, {0.87157, 48.8713}, {0.8752, 
  48.2443}, {0.87884, 47.7294}, {0.88248, 46.8157}, {0.88611, 
  46.0304}, {0.88975, 45.1212}, {0.89339, 44.7745}, {0.89703, 
  43.9961}, {0.90066, 43.0952}, {0.9043, 42.5257}, {0.90794, 
  42.2893}, {0.91157, 41.8312}, {0.91521, 40.9686}, {0.91885, 
  40.3532}, {0.92248, 39.7576}, {0.92612, 39.4586}, {0.92976, 
  38.8747}, {0.93339, 38.4161}, {0.93703, 37.7528}, {0.94067, 
  37.3574}, {0.94431, 36.8382}, {0.94794, 36.3011}, {0.95158, 
  35.9058}, {0.95522, 35.4485}, {0.95885, 34.9093}, {0.96249, 
  34.32}, {0.96613, 34.0316}, {0.96976, 33.591}, {0.9734, 
  33.3216}, {0.97704, 33.0267}, {0.98067, 32.4282}, {0.98431, 
  32.3091}, {0.98795, 32.0845}, {0.99159, 31.6361}, {0.99522, 
  31.2284}, {0.99886, 30.7767}, {1.0025, 30.4388}, {1.00613, 
  30.2196}, {1.00977, 29.8235}, {1.01341, 29.5197}, {1.01704, 
  29.344}, {1.02068, 29.0606}, {1.02432, 28.5289}, {1.02795, 
  28.102}, {1.03159, 28.0264}, {1.03523, 28.0783}, {1.03887, 
  27.6681}, {1.0425, 27.5522}, {1.04614, 27.1552}, {1.04978, 
  26.8587}, {1.05341, 26.6213}, {1.05705, 26.3301}, {1.06069, 
  26.1524}, {1.06432, 25.8047}, {1.06796, 25.5832}, {1.0716, 
  25.5029}, {1.07523, 25.203}, {1.07887, 24.9392}, {1.08251, 
  24.9243}, {1.08615, 24.8342}, {1.08978, 24.4551}, {1.09342, 
  24.0326}, {1.09706, 23.5549}, {1.10069, 23.5307}, {1.10433, 
  23.4796}, {1.10797, 23.2503}, {1.1116, 23.079}, {1.11524, 
  23.1125}, {1.11888, 22.941}, {1.12251, 22.6978}, {1.12615, 
  22.4483}, {1.12979, 22.5276}, {1.13343, 22.0572}, {1.13706, 
  22.0038}, {1.1407, 21.9636}, {1.14434, 21.7319}, {1.14797, 
  21.4474}, {1.15161, 21.4931}, {1.15525, 21.2675}, {1.15888, 
  20.9086}, {1.16252, 20.9773}, {1.16616, 20.7104}, {1.16979, 
  20.607}, {1.17343, 20.5066}, {1.17707, 20.5538}, {1.18071, 
  20.4422}, {1.18434, 20.2128}, {1.18798, 20.0675}, {1.19162, 
  20.1379}, {1.19525, 19.774}, {1.19889, 19.5749}, {1.20253, 
  19.4279}, {1.20616, 19.1179}, {1.2098, 19.1727}, {1.21344, 
  19.2947}, {1.21707, 18.9027}, {1.22071, 18.7805}, {1.22435, 
  18.6712}, {1.22798, 18.5499}, {1.23162, 18.4297}, {1.23526, 
  18.612}, {1.2389, 18.4414}, {1.24253, 18.1845}, {1.24617, 
  17.9992}, {1.24981, 18.079}, {1.25344, 17.7912}, {1.25708, 
  17.7384}, {1.26072, 17.474}, {1.26435, 17.475}, {1.26799, 
  17.5717}, {1.27163, 17.2923}, {1.27526, 17.2294}, {1.2789, 
  17.2249}, {1.28254, 17.2097}, {1.28618, 16.8087}, {1.28981, 
  16.8752}, {1.29345, 16.8982}, {1.29709, 16.8445}, {1.30072, 
  16.847}, {1.30436, 16.5705}, {1.308, 16.4896}, {1.31163, 
  16.4364}, {1.31527, 16.3896}, {1.31891, 16.213}, {1.32254, 
  16.2278}, {1.32618, 16.0167}, {1.32982, 16.1231}, {1.33346, 
  16.0964}, {1.33709, 16.0232}, {1.34073, 15.7609}, {1.34437, 
  15.8084}, {1.348, 15.6584}, {1.35164, 15.6287}, {1.35528, 
  15.6796}, {1.35891, 15.7029}, {1.36255, 15.546}, {1.36619, 
  15.2124}, {1.36982, 15.2086}, {1.37346, 15.0757}, {1.3771, 
  14.923}, {1.38074, 15.1161}, {1.38437, 14.9677}, {1.38801, 
  15.0016}, {1.39165, 14.8281}, {1.39528, 14.8684}, {1.39892, 
  14.6861}, {1.40256, 14.5675}, {1.40619, 14.4593}, {1.40983, 
  14.6113}, {1.41347, 14.5008}, {1.4171, 14.3918}, {1.42074, 
  14.3476}, {1.42438, 14.3555}, {1.42802, 14.3623}, {1.43165, 
  14.339}, {1.43529, 14.2684}, {1.43893, 13.9455}, {1.44256, 
  13.9627}, {1.4462, 14.0328}, {1.44984, 13.8979}, {1.45347, 
  13.7776}, {1.45711, 13.8756}, {1.46075, 13.6197}, {1.46438, 
  13.7516}, {1.46802, 13.647}, {1.47166, 13.6387}, {1.4753, 
  13.5843}, {1.47893, 13.649}, {1.48257, 13.5493}, {1.48621, 
  13.3301}, {1.48984, 13.3416}, {1.49348, 13.3377}, {1.49712, 
  13.2524}, {1.50075, 13.0905}, {1.50439, 13.1987}, {1.50803, 
  13.1023}, {1.51166, 13.162}, {1.5153, 13.0719}, {1.51894, 
  13.1163}, {1.52258, 12.9534}, {1.52621, 12.9181}, {1.52985, 
  12.8718}, {1.53349, 12.9131}, {1.53712, 12.8463}, {1.54076, 
  12.7041}, {1.5444, 12.7167}, {1.54803, 12.458}, {1.55167, 
  12.4296}, {1.55531, 12.5131}, {1.55894, 12.556}, {1.56258, 
  12.5933}, {1.56622, 12.5091}, {1.56986, 12.4594}, {1.57349, 
  12.4128}, {1.57713, 12.3223}, {1.58077, 12.2438}, {1.5844, 
  12.324}, {1.58804, 12.1571}, {1.59168, 12.1936}, {1.59531, 
  12.2051}, {1.59895, 12.2231}, {1.60259, 12.1543}, {1.60622, 
  12.0448}, {1.60986, 12.1679}, {1.6135, 11.9565}, {1.61714, 
  11.9209}, {1.62077, 12.0175}, {1.62441, 11.9823}, {1.62805, 
  11.8246}, {1.63168, 11.8108}, {1.63532, 11.7502}, {1.63896, 
  11.9085}, {1.64259, 11.8103}, {1.64623, 11.7951}, {1.64987, 
  11.7338}, {1.6535, 11.7665}, {1.65714, 11.9399}, {1.66078, 
  11.7594}, {1.66442, 11.6693}, {1.66805, 11.6262}, {1.67169, 
  11.545}, {1.67533, 11.5728}, {1.67896, 11.6337}, {1.6826, 
  11.5396}, {1.68624, 11.5791}, {1.68987, 11.4263}, {1.69351, 
  11.4017}, {1.69715, 11.4476}, {1.70078, 11.4972}, {1.70442, 
  11.4669}, {1.70806, 11.245}, {1.7117, 11.266}, {1.71533, 
  11.2994}, {1.71897, 11.2909}, {1.72261, 11.2059}, {1.72624, 
  11.0628}, {1.72988, 11.1528}, {1.73352, 11.0958}, {1.73715, 
  11.1332}, {1.74079, 11.0329}, {1.74443, 11.1295}, {1.74806, 
  10.9499}, {1.7517, 10.9342}, {1.75534, 11.01}, {1.75897, 
  10.9982}, {1.76261, 11.1398}, {1.76625, 10.951}, {1.76989, 
  10.8068}, {1.77352, 10.868}, {1.77716, 10.9951}, {1.7808, 
  10.8887}, {1.78443, 10.8111}, {1.78807, 10.8324}, {1.79171, 
  10.6965}, {1.79534, 10.8346}, {1.79898, 10.772}, {1.80262, 
  10.7567}, {1.80625, 10.739}, {1.80989, 10.7422}, {1.81353, 
  10.7291}, {1.81717, 10.9083}, {1.8208, 10.7915}, {1.82444, 
  10.6635}, {1.82808, 10.6627}, {1.83171, 10.7432}, {1.83535, 
  10.7494}, {1.83899, 10.7241}, {1.84262, 10.6604}, {1.84626, 
  10.6429}, {1.8499, 10.4885}, {1.85353, 10.4682}, {1.85717, 
  10.5412}, {1.86081, 10.481}, {1.86445, 10.609}, {1.86808, 
  10.4196}, {1.87172, 10.4364}, {1.87536, 10.2673}, {1.87899, 
  8.81155}, {1.88263, 7.66905}}
share|improve this question
    
Hi crystal, welcome to Mathematica.SE. I have formatted your code in a way that can be easily copy pasted. It is advised that you do that yourself in future questions so there is a good section in the help centre regarding markdown that is worth reading. Don't forget to upvote the questions and answers you find helpful in the site. –  gpap Apr 22 at 14:39
    
Can you clarify the question? What is the relationship between the data and the integration? Also -- do you really mean I in the integration (the variable I is Sqrt[-1]). –  bill s Apr 22 at 14:58
    
I is the Intensity, not the sqrt[-1], it is dependent variable, and q is the independent variable, and the data is documented in {q,I} –  crystal Apr 22 at 15:03

2 Answers 2

Ok, here is my stab at understanding the issue. To begin, this is how I am interpreting the integral (it is always a good idea to clearly mark the dependence of your symbols):

$$\frac{\int_0^{\infty } i(q)\,q^2 \cos (q\,x) \, dq}{\int_0^{\infty } i(q) \, q^2 \, dq}$$

where $i(q)$ is the intensity as a function of $q$. So, lets interpolate over the data in the appropriate region and use the given functions for extrapolation:

i[q_] := Piecewise[{{11922 Exp[-217.2136 q^2], q <= 0.1}, 
                    {Interpolation[data, InterpolationOrder -> 1][q], 0.1 < q <= 1.8},
                    {23.6631/q^4, q > 1.8}}]

I don't know if this extrapolation is really good, look at the following plot:

LogPlot[i[q], {q, 0, 3}, PlotRange -> All]

enter image description here

and even more so when the integrand is plotted (lets look at say x=2):

Plot[i[q] q^2 Cos[q 2], {q, 0, 3}, PlotRange -> All]

enter image description here

nonetheless, lets proceed and integrate. The denominator is just a constant so only needs to be done once:

norm  = NIntegrate[i[q]*q^2, {q, 0, ∞}]
(* 69.2087 *)

now, for gamma[x]

gamma[x_?NumericQ] := 
 NIntegrate[i[q] q^2 Cos[q x], {q, 0, \[Infinity]}, 
   PrecisionGoal -> 4]/norm

generate some points

gammapts = ParallelTable[{x, gamma[x]}, {x, 0, 50, 1/2}];

and plot

ListLinePlot[gammapts, PlotRange -> All]

enter image description here

share|improve this answer

Well, a good question. One way is to use interpolation. I will take a part of your data just for the sake of example:

data = {{0.06781, 8484.9}, {0.07145, 8104.34}, {0.07508, 
7511.06}, {0.07872, 6941.88}, {0.08236, 6731.36}, {0.08599, 
5949.97}, {0.08963, 5077.74}, {0.09327, 4354.2}, {0.0969, 
3756.52}, {0.10054, 3259.68}, {0.10418, 2853.38}, {0.10781, 
2504.39}, {0.11145, 2212.84}, {0.11509, 1959.85}, {0.11873, 
1746.78}, {0.12236, 1563.75}, {0.126, 1407.37}, {0.12964, 
1268.35}, {0.13327, 1146.27}, {0.13691, 1042.39}, {0.14055, 
953.417}, {0.14418, 870.465}, {0.14782, 799.707}, {0.15146, 
737.023}, {0.15509, 679.906}, {0.15873, 628.893}, {0.16237, 
584.248}, {0.16601, 545.282}, {0.16964, 507.971}, {0.17328, 
475.35}, {0.17692, 444.392}, {0.18055, 416.804}, {0.18419, 
392.803}, {0.18783, 371.445}, {0.19146, 351.733}, {0.1951, 
334.393}, {0.19874, 315.427}, {0.20237, 300.287}, {0.20601, 
285.826}, {0.20965, 273.292}, {0.21329, 262.379}, {0.21692, 
251.135}, {0.22056, 239.252}, {0.2242, 230.232}, {0.22783, 
222.497}, {0.23147, 213.946}, {0.23511, 205.512}, {0.23874, 
197.638}, {0.24238, 191.972}, {0.24602, 186.409}, {0.24965, 
180.46}, {0.25329, 175.138}, {0.25693, 169.796}};

Then

f = Interpolation[data];

Now this may be plotted:

Plot[f[x], {x, First[data][[1]], Last[data][[1]]}]

yielding this: enter image description here and integrated:

 Integrate[f[x], {x, First[data][[1]], Last[data][[1]]}]

(*   314.699  *)
share|improve this answer
    
Thank you so much, but my function is a little bit complex. –  crystal Apr 22 at 15:10
    
i want to calculate and plot gamma function over {x,0,50}, gamma function is as follows:gamma = (NIntegrate[I1*q^2*Cos[q x], {q, 0, 0.1}] + NIntegrate[f[x, q]*q^2*Cos[q x], {q, 0.1, 1.8}] + NIntegrate[I3*q^2*Cos[q x], {q, 1.8, Infinity}])/( NIntegrate[I1*q^2, {q, 0, 0.1}] + NIntegrate[I2*q^2, {q, 0.1, 1.8}] + NIntegrate[I3*q^2, {q, 1.8, Infinity}]) –  crystal Apr 22 at 15:11
    
and I1 = 11922 Exp[-217.2136 q^2] I3 = 23.6631/q^4 ; and I2 will be an interpolationfuction from previous data –  crystal Apr 22 at 15:12
    
@crystal Your comment is not clear. I think a good idea would be to edit your question and explain your need there. In particular you should explain what are I1, I2, I3 and what is their relation to your data. –  Alexei Boulbitch Apr 22 at 15:15
    
okay, see latest version –  crystal Apr 22 at 15:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.