0
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ It appears de1[curlE] is missing an argument (or its definition has one in excess) $\endgroup$ – Peltio May 18 '14 at 7:34
  • $\begingroup$ Hmmm I'm not sure if i follow what you mean. I looked through it...no argument should be missing. $\endgroup$ – user1886681 May 18 '14 at 7:46
  • 1
    $\begingroup$ You defined de1[phi_, curlE_] and then you called de1[curlE], which - to my knowledge - has no definition attached. $\endgroup$ – Peltio May 18 '14 at 7:50
  • $\begingroup$ after fixing that read this mathematica.stackexchange.com/questions/8899/… $\endgroup$ – george2079 May 18 '14 at 13:22
  • $\begingroup$ 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 :( $\endgroup$ – user1886681 May 18 '14 at 21:20
1
$\begingroup$

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

$\endgroup$

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.