No Inverse Error function?

No Inverse Error function?

The Fortran Math library has ERF for the error function, but I have not been able to find the Inverse.

Its a statistical function based upon the Gaussian Normal distribution.


Strangely enough, it does exist for VECTOR ELEMENTS, but I don't see why they would not

include it for regular usage. Every other math library on other processors has this function.

If it is in the library, searching for it produces no results.

How do we use vector elements - what are they referring to?


(in case I get desperate)


12 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The IMSL package add-on has ERFI, but I don't think it is a part of standard Intel Fortran.  Can you expand on 'it does exist for VECTOR ELEMENTS'?


What you've found is entries for erfinv in Intel MKL. Fortran does not define the erfinv intrinsic. You can use this from MKL but it is defined on arrays only. You could pass a single-element array if you wanted.

Ask over in the MKL forum if you need more help.

Steve - Intel Developer Support

As explained by John Reid in his 2014 report, "The New Features of Fortran 2008", the following 3 new intrinsic functions have been added to the Fortran 2008 standard and I think these are available in the latest Intel Fortran compiler version:

What exactly is the inverse error function?  Is it the same as the complementary error function (erfc(x)) explained above?


Downloadimage/png ErrorFunctions.png31.58 KB

FortranFan: if y = erf(x), x = inverf(y); if y = erfc(x), x = inverfc(y), as is usual in mathematics

William S.: there is nothing that keeps you from calling the VML/VSL functions with a vector argument containing a single component. For example:

program xinverf
implicit none
include 'mkl_vml.f90'
integer,parameter :: n=1
integer*8 mode
real a(1),v(1)

a(1) = 0.4
call vserfcinv(n, a, v)
end program xinverf

With this program we get

S:\MKL> ifort /Qmkl xerfinv.f90

S:\MKL> xerfinv



mecej4 wrote:

.. if y = erf(x), x = inverf(y); if y = erfc(x), x = inverfc(y), as is usual in mathematics


Thanks mecej4.

Then another question - perhaps for Steve or other folks more familiar with the Fortran standards development and/or those who are more mathematically inclined:

If the Fortran standard now includes the error function (erf(x)), any idea why the inverse isn't?

Is it mathematically too complicated (it's been a while, too lazy to run now to our library to consult the math handbooks), or the methods approximate or involve more intricate details, or constrained by some technical artifact (e.g., valid only in certain domains), or some proprietary issues with the solvers that the standard body would decide to punt on this?


erfinv isn't really all that popular in language libraries. It's not in typical C libraries. For Fortran 2008, the standard added a bunch of mathematical intrinsics popular for C, but erfinv wasn't among them. I searched the J3 archives and don't see even a suggestion that it be included. I see that C++ has added erfinv, but Fortran doesn't tend to follow C++.

Steve - Intel Developer Support

Its pretty awkward to have to make the Inputs vectors.

I don't see any useful purpose in that, unless it has to do with

optimization of the results. After all, one can get the same answers by using a DO LOOP.


And why they did that for the Error function and its complement, and not for their inverses,

which are used just as often, is a mystery. As any statistician will tell you - just ask ! ! !


for example you would use the inverse when you know the probability of an outcome,

and you want to know its Z value (no of standard deviations away from the mean) corresponding

to that. It's used all the time.

That would be like having a SINE function but no ARCSINE, or a TAN function, but no ARC Tangent.

That thing that mecej4 sent me doesn't work either.

says its can't find the function. None of them in fact.

I did put in the INCLUDE statement they recommended.


so those statitistical functions, if they are in the MKL libary,

are unusable.

I suppose those who say calling MKL is too difficult aren't likely to use it, but C source code (with poor documentation) for erfinv (apparently just a bit more than single precision) is presented at

which could be trivially translated to Fortran or called via bind(c).

I'm struggling to understand whether the VS2012/2013 implementation is for Nvidia accelerator only.

An article on how it was implemented for Nvidia:

I did "kluge" up an inverse error function, for those that are interested.

Any statistical application would have to have it...........


It uses the existing ERF in the Fortran library and a set of linear approximations

to iterate on the answer. Just like you could use the Newton_Raphson technique to

get an ARC Tangent if you didn't already have one.


The C++ library routine it appears uses a set of polynomials, so that might be faster.

But you may not get the full REAL*8 accuracy. It does have D.P variables though.

You need to select the "Use Intel Math Kernel Library" option under Fortran > Libraries.

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today