0

I need some help with NIntegrate. I pasted the code that I wrote below; I know that up to "de" is correct.

What I would like to do is NIntegrate de w.r.t phi{0,0.1} and curlE{-10,10}. The final answer should be just a number, but I am not sure if I am going about this wrong.

 e = 1.60217657*10^-19;
 n = 10^-10/e;
 r = 1.5;
 sigma = 50*10^-6;
 p[phi_] := (r*phi^3)/(24 sigma);
 g[curlEprime_] := Exp[-((curlEprime)^2/2)];

 gSomething[phi_, curlE_] :=  With[{p = p[phi]}, p^(-(1/3)) (g[curlE - p] - g[curlE - 4             p]) + NIntegrate[
1/(curlE - curlEprime)^(1/3) g'[curlEprime], {curlEprime, curlE - p, curlE}]]

 de[phi_, curlE_] := (2*e^2*n)/(3^(1/3)*Sqrt[2 Pi]*r^(2/3)*
 sigma^(4/3))*gSomething[phi, curlE]

 de1[phi_, curlE_] := NIntegrate[de[phi, curlE], {phi, 0, 0.103}]

 de2[curlE_] := NIntegrate[de1[curlE], {curlE, -1, 1}]

So, at the end de2 should give a numerical value.

user1886681
  • 265
  • 1
  • 14
  • It appears de1[curlE] is missing an argument (or its definition has one in excess) – Peltio May 18 '14 at 07:34
  • Hmmm I'm not sure if i follow what you mean. I looked through it...no argument should be missing. – user1886681 May 18 '14 at 07:46
  • 1
    You defined de1[phi_, curlE_] and then you called de1[curlE], which - to my knowledge - has no definition attached. – Peltio May 18 '14 at 07:50
  • after fixing that read this http://mathematica.stackexchange.com/questions/8899/how-do-i-prevent-nintegrateinumr-errors-within-other-functions – george2079 May 18 '14 at 13:22
  • So I tried the following: de1[phi,curlE] and de1[phi_,curlE_] in de2, but neither option worked. Sorry I am just not understanding what I am doing wrong :( – user1886681 May 18 '14 at 21:20

1 Answers1

1

Ok so this seemed to help. Can anyone proof read my code to make sure I am doing it correctly?

e = 1.60217657*10^-19;
n = 10^-10/e;
r = 1.5;
sigma = 50*10^-6;
p[phi_] := (r*phi^3)/(24 sigma);
g[curlEprime_] := Exp[-((curlEprime)^2/2)];

gSomething[phi_?NumericQ, curlE_?NumericQ] := With[{p = p[phi]}, 
p^(-(1/3)) (g[curlE - p] - g[curlE - 4 p]) + 
NIntegrate[
1/(curlE - curlEprime)^(1/3) g'[curlEprime], {curlEprime, 
 curlE - p, curlE}]]

de[phi_?NumericQ, 
curlE_?NumericQ] := (2*e^2*n)/(3^(1/3)*Sqrt[2 Pi]*r^(2/3)*
 sigma^(4/3))*gSomething[phi, curlE]

de1[curlE_?NumericQ] := NIntegrate[de[phi, curlE], {phi, 0, 0.103}]

NIntegrate[de1[curlE], {curlE, -1, 1}]

OUTPUT:2.9971*10^-25

user1886681
  • 265
  • 1
  • 14