I observed that there is no Q-function representation in Mathematica. The definition of Q-Function is:

\begin{align} Q(x) &= \frac{1}{\sqrt{2\pi}} \int_x^\infty e^{-\frac{u^2}{2}}du \\ &=\frac{1}{2} \mathrm{erfc}(\frac{x}{\sqrt{2}}) \end{align}

a nother representation of Q-function is: \begin{align} Q(x) = \frac{1}{\pi} \int_0^{\frac{\pi}{2}} e^{\left(\frac{-x^2}{2\sin^2{\phi}} \right)}d\phi \end{align}

there is only Complementary Error Function representation Erfc.

$\mathrm{erfc}(x) = \frac{2}{\sqrt{\pi}} \int_{x}^{\infty} \exp(-t^2) dt$

Is there any possiblity that define a new function in Mathematica? so that it will be a permanent function.

Note: In statistics, the Q-function is the tail probability of the standard normal distribution. In other words, Q(x) is the probability that a normal (Gaussian) random variable will obtain a value larger than x standard deviations above the mean.

  • 3
    $\begingroup$ How about: q[x_] := Erfc[x/Sqrt[2]]/2; $\endgroup$
    – bill s
    Commented Oct 17, 2013 at 15:05
  • 7
    $\begingroup$ or even q[x_] := SurvivalFunction[NormalDistribution[], x] $\endgroup$
    – chuy
    Commented Oct 17, 2013 at 17:42

2 Answers 2


There are two parts to your question: how to define the function and how to make it persist between sessions. I suggested

q[x_] := Erfc[x/Sqrt[2]]/2;

though chuy's suggestion looks fine too.To make it persist, you can place this function definition in an initialization cell, and then this will run whenever the notebook is opened. You can find instructions for this here and other information here about running the cell on startup.

  • $\begingroup$ is it possible in the future versions in Mathematica contain this function? I mean can you tell them or suggest this to them? $\endgroup$
    – sky-light
    Commented Oct 17, 2013 at 23:40
  • 1
    $\begingroup$ I guess you might want to ask Wolfram about that. On the support page wolfram.com/support/contact/email you can email them about bugs or with suggestions. $\endgroup$
    – bill s
    Commented Oct 18, 2013 at 0:06

If this the function that you use daily, you can put it into you initialization file. Use the command in a notebook:


Usually there is a ./Kernel/init.m file. It is evaluated when Mathematica kernel starts. You can put these line in it:

q::usage="q[x] is my Q-function. You cannot modify it, aha!"
q[x_:0] := Erfc[x/Sqrt[2]]/2

Then you will have several good features:

better def


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.