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 would like to be able to Plot a function (with an implicit Integrate command) with various values for a certain parameter (phi in the code below for values 0.01 and 0.02) all on the same Plot to compare.Below is my code:

e = 1.60217657*10^-19;
n = 10^-9/e;
R = 1.5;
sigma = 50*10^-6;
p = (R*phi^3)/(24 sigma);
g = D[Exp[-((curlEprime)^2/2)], curlEprime];

G = p^(-(1/3)) (Exp[-((curlE - p)^2/2)] - Exp[-((curlE - 4 p)^2/2)]) +
Integrate[1/(curlE - curlEprime)^(1/3) g, {curlEprime, curlE - p, curlE}];

de = (2 e^2 n)/(3^(1/3) Sqrt[2 Pi] R^(2/3) sigma^(4/3)) G

Plot[de, {curlE, -10, 10}] /. phi -> {0.01, 0.02}
share|improve this question
Define all your variable depending on phi as var[phi_]:=. Then Plot[de[phi],...] should work. –  Öskå Apr 29 '14 at 22:01
Thanks for the reply. tried it but no luck :/ –  user1886681 Apr 29 '14 at 22:19
You need p[phi_], g[curlEPrime_], G[phi_, curlE_, curlEprime_] and de[phi_, curlE_, curlEprime_]. I haven't looked in the details so I might be wrong about curlEprime but here is the idea. Then you will be able to plot Plot[de[#,..] /@ {0.01, 0.02},...]. –  Öskå Apr 29 '14 at 23:00

1 Answer 1

Below you'll find a slightly changed version of your code (note the new definition of g - saves some space). Basically, as Öskå wrote in his comments above, you need to define functions of phi, curlEprime and curlE. Also, it seems that the integral could not be derived in a symbolic way.

Furthermore, you should not name your variable with capital letters (see here), hence the small changes bellow:

e = 1.60217657*10^-19;
n = 10^-9/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]

phi = {.01, .02};
Quiet@Plot[de[#, curlE] & /@ phi, {curlE, -10, 10}, 
  PlotRange -> All, Evaluated -> True, PlotLegends -> ToString /@ phi]

enter image description here

share|improve this answer
I added the Plot and a comment about Capital letters, if you mind feel free to reverse the edit. Plus, if you are on V9 please add PlotLegends -> ToString /@ phi and update the image :) –  Öskå Apr 30 '14 at 9:37
Done, thank you! –  Gregory Rut Apr 30 '14 at 9:52
WOW! Thank you so much. First of all, the code ran super fast (mine took about 5-10 minutes) and second of all the plots are beautiful (varied phi from 0.01 to 0.11)! –  user1886681 Apr 30 '14 at 20:09

Your Answer


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.