# Plotting of an expression in Mathematica

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:

Expected outcome (solid blue curves):

• Use LogLogPlot[Pr[...], ...] Jul 18, 2023 at 14:21
• @MarcoB: I tried, but not getting the appropriate result. Thanks. Jul 18, 2023 at 14:25
• 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. Jul 18, 2023 at 14:36
• @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. Jul 18, 2023 at 16:37

\$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]}]


• Bob Hanlon: Yes, this is precisely the outcome I was aiming for. Thank you very much for your help. Jul 18, 2023 at 16:42

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]
]
`

That looks very similar to your desired output to me.