# Plotting a function based of a complicated integral

I would like to have help in making a plot of a complicated function based a definite integral.   - desired graph

My calculation: ClearAll[F, z];
F[z_] := 0.5*(1 + Erf[z/Sqrt]);
q[B_, g_, m_] :=
(1/Sqrt[2*Pi])*
Integrate[F[z]^(-1 + m)/E^(0.5*((-Sqrt[B])*g + z)^2), {z, -1000, 1000}];
p[B_, g_, m_] := 1 - q[B, g, m];
Plot[{p[B, 0.2, 8]}, {Log[B, 2], -4, 4}]


First: Log[B,2] - Error.

Second: It's very long considers.

How to make my plot in the Mathematica?

• added to question May 12, 2015 at 4:37
• Plot[{p[B, 0.2, 8]}, {Log[B, 2], -4, 4}] isn't syntactically correct. Take a look at the plot range specification on the docs May 12, 2015 at 5:03
• I think you might want to use Plot[{p[B, 0.2, 8]}, {B, 1/16, 16}] May 12, 2015 at 5:17
• Also you could try to translate It fails with an error. long considered? into Linear-B and then backwards.Damn @m_goldberg you spoiled my joke :) May 12, 2015 at 5:29
• @belisarius. My bad and I express my profound regret. Sometimes my aggressive editing makes things worse rather than better, especially when I truly only guessing what the OP intends. May 12, 2015 at 5:37

I think the graph in your book contains an error. When we look closely at the graph of Alexei, then we see that for m=8 and g=0.2, the graph crosses the y-axis at 0.84. In the picture in your book, this is not the case and the crossing is at {0, 0.65} (the plot is log-scaled!). Additionally, Alexei's graph ends in {4, 0.67} while in your book this is the point isn't even on the graph. Instead, it contains the point {3, 0.1}.

To cut is short: Although you book claims that it depicts g=0.2, I believe it rather used g=1.

Additionally, note that you can integrate from -Infinity to Infinity in your code. NIntegrate can handle this. To make this a complete answer:

f[z_] := 1/2 (1 + Erf[z/Sqrt]);
Plot[f[z], {z, -10, 10}, Axes -> False, Frame -> True,
PlotRange -> {Automatic, {0, 1}}] ClearAll[q];
q[B_?NumericQ, g_?NumericQ, m_?NumericQ] :=
1 - (1/Sqrt[2*Pi])*
NIntegrate[
Exp[-1/2 (z - g*Sqrt[B])^2]*f[z]^(-1 + m), {z, -Infinity,
Infinity}]

LogPlot[Evaluate[q[2^x, 1, #] & /@ {8, 128, 512}], {x, -4, 4},
Frame -> True, Axes -> False, PlotRange -> {Automatic, {0.1, 1}},
GridLines -> {None, {.2, .3, .4, .5, .6, .7, .8, .9}},
PlotLegends -> {"m=8", "m=128", "m=512"}] • Addtionally to your "Additionally", integrating from -Infinity to Infinity is usually handled better than from -1000 to 1000 in such an integral. (+1) May 12, 2015 at 13:06

You might do as follows:

    ClearAll[F, z];
F[z_] := 0.5*(1 + Erf[z/Sqrt]);
p[lgB_, g_, m_] :=
1 - (1/Sqrt[2*Pi])*
NIntegrate[
F[z]^(-1 + m)/E^(0.5*((-2^(lgB/2))*g + z)^2), {z, -1000, 1000},
MaxRecursion -> 12];
Plot[{p[lgB, 0.2, 8]}, {lgB, -4, 4}]


yielding this The key points are tha (i) I substituded B=^lgB, thus, introduced a new variable, lgBthat you probably have head in mind, and (ii) I used NIntegrateinstead of Integrate.

Have fun!

• This looks odd because the desired graph seems to have a log-scale at the y-axis and the m=8 curve seems to contain the point {0.1, 3} which doesn't go along with your graph. May 12, 2015 at 12:29