0
$\begingroup$

I want to plot the below expression using Mathematica:

$\begin{aligned} \operatorname{Pr}(e)_{C S} & \leq \frac{1}{2} e^{-M k N_S\left(\sqrt{N_B+1}-\sqrt{N_B}\right)^2} \hspace{45pt} (1)\\ \end{aligned}$

with the following parameters: $ M=10^5:10^7,\; N_S = 0.01, κ = 0.01, and\; N_B = 1$. I have attempted to plot the curves, but I am encountering some challenges. The resulting plot does not match the expected outcome.

Code:

Pr[k_, Nb_, Ns_, M_] = 1/2*Exp[-M*k*Ns*(Sqrt[Nb + 1] - Sqrt[Nb])^2]
Plot[Log10@{Pr[0.01, 20, 0.01, M]}, {M, 10^5, 10^7},PlotStyle -> Directive[Red, Thick], AxesStyle -> Directive[Black, Bold, FontSize -> 14], Axes -> True,GridLines -> Automatic, Frame -> True,TicksStyle -> Directive[Black, Bold], AxesLabel -> {"log_10(M)","log_10(Pr)"}]

Could you please assist me in creating the desired plot using Mathematica?

My outcome:

My outcome:

Expected outcome (solid blue curves):

Expected outcome (solid  blue curves):

$\endgroup$
4
  • $\begingroup$ Use LogLogPlot[Pr[...], ...] $\endgroup$
    – MarcoB
    Jul 18, 2023 at 14:21
  • $\begingroup$ @MarcoB: I tried, but not getting the appropriate result. Thanks. $\endgroup$
    – Sagar
    Jul 18, 2023 at 14:25
  • $\begingroup$ Could you explain what exactly doesn't work with LogLogPlot? I tried it in my answer below and the results seem in line with the figure you showed. Note that in your text you mentioned $N_b = 1$ but in your code you set $N_b$ to 20. $\endgroup$
    – MarcoB
    Jul 18, 2023 at 14:36
  • $\begingroup$ @MarcoB: LogLogPlot worked for me as well. I was getting an error because I mistakenly used "N" instead of "M," which is a protected symbol. Additionally, you are correct; it should indeed be Nb=20. Thank you for your assistance in resolving the issue. $\endgroup$
    – Sagar
    Jul 18, 2023 at 16:37

2 Answers 2

1
$\begingroup$
$Version

"13.3.0 for Mac OS X ARM (64-bit) (June 3, 2023)"

Clear["Global`*"]

Pr[k_, Nb_, Ns_, M_] =
  1/2*Exp[-M*k*Ns*(Sqrt[Nb + 1] - Sqrt[Nb])^2];

Plot[
 Log10@Pr[0.01, 20, 0.01, 10^M],
 {M, 5, 7},
 PlotStyle -> Directive[Red, Thick],
 AxesStyle -> Directive[Black, Bold, FontSize -> 14],
 Axes -> True,
 GridLines -> Automatic,
 Frame -> True,
 TicksStyle -> Directive[Black, Bold],
 FrameLabel ->
  (StringForm["``(``)", Subscript["log", 10], #] & /@
    {HoldForm[M], HoldForm[Pr]}),
 Epilog -> {Style[Text[
     StringForm[
      "    κ\[ThinSpace]=\[ThinSpace]0.01\n  ``\[ThinSpace]=\
\[ThinSpace]0.01\n``\[ThinSpace]=\[ThinSpace]20",
      Subscript[N, S], Subscript[N, B]],
     Scaled@{0.25, 0.2}, {1, 0}], 14]}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Bob Hanlon: Yes, this is precisely the outcome I was aiming for. Thank you very much for your help. $\endgroup$
    – Sagar
    Jul 18, 2023 at 16:42
0
$\begingroup$

Use LogLogPlot:

Clear[Pr]
Pr[k_, Nb_, Ns_, M_]:= 1/2*Exp[-M*k*Ns*(Sqrt[Nb + 1] - Sqrt[Nb])^2]

LogLogPlot[
  Pr[0.01, 20, 0.01, M], {M, 10^5, 10^7},
  PlotStyle -> Directive[Red, Thick], 
  AxesStyle -> Directive[Black, Bold, FontSize -> 14], 
  Axes -> True,GridLines -> Automatic,
  Frame -> True, TicksStyle -> Directive[Black, Bold]
]

enter image description here

That looks very similar to your desired output to me.

$\endgroup$

Your Answer

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

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