# Aproximation to function of error function

The function: $p = \dfrac{\mathrm{erf}(z)-\mathrm{erf}(f(x))}{\mathrm{erf}(z)-\mathrm{erf}(y)}$

All the parameters of the error function ($z, y, f(x)$) are very large. This leads to catastrophic cancellation when I tried to solve it. I fix it by using either Mathematics two parameters Erf implementation or using the complementary error function. However, I would like to have a nice and fast approximation for $p$ using only elementary functions.

As $p$ is a probability, it is important that $0 \le p \le 1$. I do not need a great precision on $p$ only on the order of $10^{-3}$.

Now, the real problematic question is next. $x$ is a random variable with an Uniform Distribution between $a$ and $b$. I want to know the expected $p$, and for that I'm using

$\int_{a}^{b} \dfrac{p(x)}{b-a} dx$

Now, because the function $f(x)$ is inside an error function, I was never able to get a solution for this integral. My first question exist exactly to go is that direction. Is there any other strategy?

• Perhaps you can get along with the extended mean value theorem, using the halfway-point instead of the unknown midpoint as approximation, $\frac{h(a)-h(b)}{h(c)-h(d)}\simeq\frac{(a-b)h'(\frac{a+b}2)}{(c-d)h'(\frac{c+d}2)}$. – LutzL Jan 31 '17 at 9:06
• Are x, y, z, f real? – Raziman T V Jan 31 '17 at 9:39
• Yes, I completly forget that. All the variables are real. @LutzL how can I use that? – Diogo Santos Jan 31 '17 at 9:41

For the first part of the problem, considering $$p = \dfrac{\mathrm{erf}(z)-\mathrm{erf}(t)}{\mathrm{erf}(y)-\mathrm{erf}(z)}$$ where $z,t,y$ are large, may be, you could use as a first approximation $$\mathrm{erf}(x)\approx 1-\frac{e^{-x^2}}{\sqrt{\pi } x}$$ This would make $$p\approx\frac{ y\, z\, e^{z^2-t^2}\,-\,t\, y}{t\, y\,-\,t \,z\, e^{z^2-y^2}}$$
• Thanks! That formulat get $t$ in 4 different places, which will make integration hard :( Is there other options? – Diogo Santos Jan 31 '17 at 14:36