1
$\begingroup$

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

enter image description here enter image description here this is supposed to be - desired graph

My calculation:

enter image description here

ClearAll[F, z];
F[z_] := 0.5*(1 + Erf[z/Sqrt[2]]);
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?

$\endgroup$
13
  • $\begingroup$ added to question $\endgroup$
    – instantia
    May 12, 2015 at 4:37
  • 1
    $\begingroup$ 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 $\endgroup$ May 12, 2015 at 5:03
  • $\begingroup$ I think you might want to use Plot[{p[B, 0.2, 8]}, {B, 1/16, 16}] $\endgroup$
    – m_goldberg
    May 12, 2015 at 5:17
  • $\begingroup$ 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 :) $\endgroup$ May 12, 2015 at 5:29
  • $\begingroup$ @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. $\endgroup$
    – m_goldberg
    May 12, 2015 at 5:37

2 Answers 2

1
$\begingroup$

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[2]]);
Plot[f[z], {z, -10, 10}, Axes -> False, Frame -> True, 
 PlotRange -> {Automatic, {0, 1}}]

Mathematica graphics

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"}]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Addtionally to your "Additionally", integrating from -Infinity to Infinity is usually handled better than from -1000 to 1000 in such an integral. (+1) $\endgroup$
    – Michael E2
    May 12, 2015 at 13:06
0
$\begingroup$

You might do as follows:

    ClearAll[F, z];
F[z_] := 0.5*(1 + Erf[z/Sqrt[2]]);
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

enter image description here

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!

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – halirutan
    May 12, 2015 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.