# Multiple plots on same graph for different parameter?

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}

• 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 :/ 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

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] • 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! 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)! Apr 30 '14 at 20:09