# export Nintegrate

I use the following NIntegrate to calculate my integral. When I use, Export, I get the f(r) value in the text file but not r. How can I export {r,f[r]} using NIntegrate, Table and Export ?

Here my code

mu0 := 4*Pi*10^(-7)
R := 7.6

Ms := 3.41

Hp := 0.25/mu0/
10^9

DeltaMs :=
0.25/mu0/10^9

A := 8.2*10^(-11)

(*DD:=0.45*10^(-3)                              DM constant in J/m^2*)

lD[DD_] := 10^9*2*DD*mu0/Ms^2
lD[0.00045]
lM = 10^9*Sqrt[2*A*mu0/Ms^2]
h2[Hp_, q_, RH_] := Hp^2*RH^0/(1 + q^2*RH^2)^2
Heff[q_, H_, A_] := H + 2*A/(Ms/mu0)*q^2*10^(18)
p[q_, H_, A_] :=
Ms/Heff[q, H,
A]
nenner[q_, H_, DD_, A_] := 1 - p[q, H, A]^2*lD[DD]^2*q^2
chi[Hp_, q_, H_, DD_, RH_,
A_] := (4*p[q, H, A]^3*h2[Hp, q, RH]*lD[DD]*q)/nenner[q, H, DD, A]^2
p[q_, H_] := Ms/Heff[q, H]
nennerav[q_, H_, DD_] := 1 - p[q, H]^2*lD[DD]^2*q^2
FFav[q_, H_, DD_] := (4*p[q, H]^3*h2[q]*lD[DD]*q)/nennerav[q, H, DD]^2
norm = NIntegrate[
chi[1675.58, q, 5, 0.0004489, 7.6, 8.19*10^(-11)]*1*q^2, {q, 0.001,
100}]
results =
Table[1/norm*
NIntegrate[
chi[1675.58, q, 5, 0.0004489, 7.6, 8.19*10^(-11)]*
SphericalBesselJ[0, q*r]*q^2, {q, 0.001, 100},
Method -> {"GlobalAdaptive", Method -> GaussKronrodRule},
PrecisionGoal -> 4], {r, 0, 30}]
Export["Cr.txt", results, "Table"]

• Add r in your table: Table[{r, 1/norm*NIntegrate[...]},{r,0,30}], then your Export[...] should give what you want. – Alx Jan 29 '20 at 8:41
• Thanks, it works – Bigprophete Jan 29 '20 at 8:48

I am not quite sure that I correctly understand what are you after. I think you want this: results =Table[{r,1/norm*NIntegrate[chi[1675.58, q, 5, 0.0004489, 7.6, 8.19*10^(-11)]*SphericalBesselJ[0, q*r]*q^2, {q, 0.001, 100},Method -> {"GlobalAdaptive", Method -> "GaussKronrodRule"}, PrecisionGoal -> 4]}, {r, 0, 30}]. As a minor correction, "GaussKronrodRule" is a string and must be written in quotes.