# Writing integrals in terms of the error function

WWCY

## Homework Statement

I have the following integral,

$$\frac{1}{\sigma \sqrt{2\pi} t} \int_{-\infty}^{0} \exp[\frac{-1}{2\sigma ^2} (\frac{x-x_0}{t} - p_0)^2]dx$$
that I wish to write in terms of the error function,
$$erf(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-g^2}dg$$
However, I can't seem to make my limits fit that of ##erf(x)## despite trying a change of variables like letting ## g = \frac{-1}{\sqrt{2\sigma ^2}} (\frac{x-x_0}{t} - p_0)##

This is my first time dealing with such a function, and pointers are greatly appreciated.

Homework Helper
Dearly Missed

## Homework Statement

I have the following integral,

$$\frac{1}{\sigma \sqrt{2\pi} t} \int_{-\infty}^{0} \exp[\frac{-1}{2\sigma ^2} (\frac{x-x_0}{t} - p_0)^2]dx$$
that I wish to write in terms of the error function,
$$erf(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-g^2}dg$$
However, I can't seem to make my limits fit that of ##erf(x)## despite trying a change of variables like letting ## g = \frac{-1}{\sqrt{2\sigma ^2}} (\frac{x-x_0}{t} - p_0)##

This is my first time dealing with such a function, and pointers are greatly appreciated.

## The Attempt at a Solution

PF rules really do require you to tell us more. Show your actual work; where does it fail?

For constants ##a,b,c,k,w## (with ##c > 0##), can you express
$$\int_a^b k e^{-c(x-w)^2} \, dx$$
in terms of ##\text{erf}( \cdot)##?

WWCY
Thanks for the response

PF rules really do require you to tell us more. Show your actual work; where does it fail?
For constants ##a,b,c,k,w## (with ##c > 0##), can you express
$$\int_a^b k e^{-c(x-w)^2} \, dx$$
in terms of ##\text{erf}( \cdot)##?

Using the integral given as an example, I tried a change of variables ##f = \sqrt{c}(x - w)^2##,
which led to
$$\frac{k}{\sqrt{c}} \int_{f_1}^{f_2}e^{-f^2}df$$
I can't tell if this was the right "first-step" to take.

May I know what are the concepts in play? For example, is this just an issue of changing variables, or is there more to it?

Staff Emeritus
Homework Helper
Gold Member
2021 Award
Rewrite the integral as two integrals from ##_-\infty## to some upper limit.

WWCY
Thanks for the response

Rewrite the integral as two integrals from ##_-\infty## to some upper limit.

Do you mean something like this?
$$\frac{k}{\sqrt{c}} (\int_{-\infty}^{f_2}e^{-f^2}df - \int_{-\infty}^{f_1}e^{-f^2}df)$$

If so, how do I continue? Thank you for assisting.

Staff Emeritus
Homework Helper
Gold Member
2021 Award
Sorry, I meant from ##0## to some upper limit ... Edit: Also, your rewriting is not correct. There is a minor error in it. Try to find it.

WWCY
Sorry, I meant from ##0## to some upper limit ... Edit: Also, your rewriting is not correct. There is a minor error in it. Try to find it.

Oops, I believe I have spotted it.

$$\frac{k}{\sqrt{c}} (\int_{0}^{f_2}e^{-f^2}df - \int_{0}^{f_1}e^{-f^2}df)$$
where ##f_1 = \sqrt{c} (a - w), f_2 = \sqrt{c} (b - w)##

Is this correct? And how do I proceed?

Thanks!

Staff Emeritus
Homework Helper
Gold Member
2021 Award
Uhhhmm... Apply the definition of the error function?

WWCY
I got,
$$\frac{k}{2} \sqrt{\frac{\pi}{c}}[erf(f_2) - erf(f_1)]$$

Uhhhmm... Apply the definition of the error function?

Apologies, I meant to ask how I would fit in the limits of ##-\infty## and ##0## as per my original question.

For ##b = 0, a = -\infty##,
$$\frac{k}{2} \sqrt{\frac{\pi}{c}}[erf(- \sqrt{c} w) - \frac{2}{\sqrt{\pi}} \int_{0}^{-\infty}e^{-f^2}df]$$
$$\frac{k}{2} \sqrt{\frac{\pi}{c}}[erf(- \sqrt{c} w) + 1]$$

Am I doing it right? Thank you!

Homework Helper
Dearly Missed
I got,
$$\frac{k}{2} \sqrt{\frac{\pi}{c}}[erf(f_2) - erf(f_1)]$$

Apologies, I meant to ask how I would fit in the limits of ##-\infty## and ##0## as per my original question.

For ##b = 0, a = -\infty##,
$$\frac{k}{2} \sqrt{\frac{\pi}{c}}[erf(- \sqrt{c} w) - \frac{2}{\sqrt{\pi}} \int_{0}^{-\infty}e^{-f^2}df]$$
$$\frac{k}{2} \sqrt{\frac{\pi}{c}}[erf(- \sqrt{c} w) + 1]$$

Am I doing it right? Thank you!

Yes, except that you are not writing "erf" correctly in LaTeX. You should say "##\text{erf}(f_2)##" instead of "##erf(f_2)##". Right-click on the expressions to see the difference.

WWCY
Yes, except that you are not writing "erf" correctly in LaTeX. You should say "##\text{erf}(f_2)##" instead of "##erf(f_2)##". Right-click on the expressions to see the difference.

Thank you, I'll keep that in mind!

Homework Helper
Dearly Missed
Thank you, I'll keep that in mind!

Also: for most of the common functions (sin, cos, tan, arcsin,arccos, arcsin,cot,ln,log,max,min,lim,exp) and several others, it is enough to just put a "\" in front, so you get ##\sin \theta## (which looks good) instead of ##sin \theta## (which looks ugly and is hard to read).

• WWCY
Homework Helper
Dearly Missed
Also: for most of the common functions (sin, cos, tan, arcsin,arccos, arcsin,cot,ln,log,max,min,lim,exp) and several others, it is enough to just put a "\" in front, so you get ##\sin \theta## (which looks good) instead of ##sin \theta## (which looks ugly and is hard to read).
When the command does not have a "\" form, we need to manually force a non-math-italic font by putting the command inside a "\text{ }" construct, so we get ##P(2\; \text{heads}) = 1/4## instead of ##P(2\; heads) = 1/4##. That is why we needed to say \text{erf}(x): the function "erf" is not on the list of commands/functions having a short "\" form.

Last edited:
• WWCY
Staff Emeritus
Homework Helper
Gold Member
2021 Award
Actually, the \text command does not really do the same thing as the typical function commands. The spacing will be off. The appropriate way of putting new function commands into LaTeX is to use the \DeclareMathOperator command. If you just need it once, you should use \operatorname, i.e., ##\operatorname{erf}(x)##. Compare the \operatorname solution to "a erf(x)" with the \text solution:
$$a \operatorname{erf}(x) \quad \mbox{vs} \quad a \text{erf}(x)$$

• WWCY
WWCY
I have attempted working out my initial problem in the same manner as above, could someone give the working a look? Thanks in advance!
$$I = \frac{1}{\sigma \sqrt{2\pi} t} \int_{-\infty}^{0} \exp[\frac{-1}{2\sigma ^2} (\frac{x-x_0}{t} - p_0)^2]dx$$
Let ##g = \frac{1}{\sigma \sqrt{2}} ( \frac{x - x_0}{t} -p_0 ) ## and ##dg = \frac{1}{\sigma t \sqrt{2}} dx##
$$I = \frac{1}{\sqrt{\pi}} \int_{g_2}^{g_1} e^{-g^2}dg$$
$$I = \frac{1}{\sqrt{\pi}} [ \int_{0}^{g_2} e^{-g^2}dg - \int_{0}^{g_1} e^{-g^2}dg]$$
$$I = \frac{1}{\sqrt{\pi}} \frac{\sqrt{\pi}}{2}[\operatorname{erf(g_2)} - \frac{2}{\sqrt{\pi}} \int_{0}^{-\infty} e^{-g^2}dg ]$$
$$I = \frac{1}{2} [ \operatorname{erf}(\frac{1}{\sigma \sqrt{2}} [-\frac{x_0}{t} - p_0] ) + 1]$$
$$I = \frac{1}{2} [ \operatorname{erf}(-\frac{1}{\sigma \sqrt{2}} [\frac{x_0}{t} + p_0] ) + 1]$$

Homework Helper
Dearly Missed
Actually, the \text command does not really do the same thing as the typical function commands. The spacing will be off. The appropriate way of putting new function commands into LaTeX is to use the \DeclareMathOperator command. If you just need it once, you should use \operatorname, i.e., ##\operatorname{erf}(x)##. Compare the \operatorname solution to "a erf(x)" with the \text solution:
$$a \operatorname{erf}(x) \quad \mbox{vs} \quad a \text{erf}(x)$$

Thanks: I did not know that. However, I would rather type " a \: \text{erf}(x)" than "a \operatorname{erf}(x)". I have long been aware of that spacing problem and have used spacers to compensate.

Now that I know about "\operatorname" I can see defining a short form of it in the document preamble.

Last edited:
Staff Emeritus
Homework Helper
Gold Member
2021 Award
Thanks: I did not know that. However, I would rather type " a \: \text{erf}(x)" than "a \operatorname{erf}(x)". I have long been aware of that spacing problem and have used spacers to compensate.

Now that I know about "\operatorname" I can see defining a short form of it in the document preamble.
If you are going to use a single function often, I strongly reccomend \DeclareMathOperator instead.

WWCY
Could someone assist regarding post 15? Many thanks.