0
$\begingroup$

I have a problem with the following function, I want to integrate my function on r for r between 0 and infinity and then plot it, but I can't compute it, I get the following error...

Integrate::ilim: Invalid integration variable or limit(s) in {3,0,[Infinity]}. NIntegrate::itraw: Raw object 3 cannot be used as an iterator.

Here my code,

mu0 = 4*Pi*10^(-7)
Ms = 0.0926/mu0 
bH = 2.91*10^8 
R = 4
(*Function*)
Heff[q_, A_, Hi_] := (Hi/mu0 + 2*A/(Ms*mu0)*(q*10^(10))^2) 
p[q_, A_, Hi_] := Ms/Heff[q, A, Hi]
Vp[r_] := 4/3*Pi*(r*10^(-9))^3 
FF[q_, r_] := 9*SphericalBesselJ[1, q*10^(10)*r*10^(-9)]^2/(q*10^(10)*r*10^(-9))^2 
RH[q_, A_, Hi_] := (1/4)*p[q, A, Hi]^2*(2 + 1/(1 + p[q, A, Hi])^(0.5)) 
RM[q_, A_, Hi_] := ((1 + p[q, A, Hi])^(0.5) - 1)/2
Mz2[q_, dM_, r_] := ((dM/mu0)^2/(8*Pi)^3)*Vp[r]^2*FF[q, r];
h2[q_, Hp_, r_] := ((Hp/mu0)^2/(8^3*Pi^3))*Vp[r]^2*FF[q, r]; 


f[r_, C_, p_] := (1/(C*r*10^(-9)*p))*Exp[-(Log[r*10^(-9)] -Log[R*10^(-9)])^2/(2*p^2)]  

Sigma1[q_, A_, Hi_, dM_, Hp_, r_, C_, p_] := 
         Integrate[(Mz2[q, dM, r]*RM[q, A, Hi] + h2[q, Hp, r]*RH[q, A, Hi])*
           f[r, C, p], {r, 0, Infinity}]

p3 = Plot[
  Sigma1[q, 8.15*10^(-12), 0.5, 0.05, 0.030 , 3, 2, 0.14], {q, 0.001, 
   0.3},
  PlotRange -> All,
  ScalingFunctions -> {"Log", "Log"},
  PlotStyle -> {Thickness[0.0055], Black},
  AspectRatio -> 1,
  Frame -> True,
  FrameStyle -> Black,
  BaseStyle -> {FontSize -> 20, FontFamily -> "Arial"}]
$\endgroup$
  • $\begingroup$ Hi, thanks, I edited and added f[r,C,p] $\endgroup$ – Bigprophete Oct 16 '18 at 13:05
2
$\begingroup$

Once you evaluate a definite integral wrt a variable then that's it. You cannot use it in your function Sigma1[q_, A_, Hi_, dM_, Hp_, r_, C_, p_] . Remove it from here and its value in the plot then everything will be ok. I used NIntegrate for quick evaluation.

Sigma1[q_, A_, Hi_, dM_, Hp_, C_, p_] := 
     NIntegrate[(Mz2[q, dM, r]*RM[q, A, Hi] + h2[q, Hp, r]*RH[q, A, Hi])*
       f[r, C, p], {r, 0, Infinity}]

p3 = Plot[
  Sigma1[q, 8.15*10^(-12), 0.5, 0.05, 0.030, 2, 0.14], {q, 0.001, 
   0.3}, PlotRange -> All, ScalingFunctions -> {"Log", "Log"}, 
  PlotStyle -> {Thickness[0.0055], Black}, AspectRatio -> 1, 
  Frame -> True, FrameStyle -> Black, 
  BaseStyle -> {FontSize -> 20, FontFamily -> "Arial"}]

enter image description here

$\endgroup$
  • $\begingroup$ I see, thanks a lot $\endgroup$ – Bigprophete Oct 16 '18 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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