function x = r8_erfinv ( y )

%*****************************************************************************80
%
%% r8_erfinv() inverts the error function ERF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    13 January 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real Y, the value of the error function.
%
%  Output:
%
%    real X, the value such that ERF(X) = Y.
%
   x = 0.5 * sqrt ( pi ) * ( ...
                                         y ...
     +              pi   /        12.0 * y^3 ...
     +        7.0 * pi^2 /       480.0 * y^5 ...
     +      127.0 * pi^3 /     40320.0 * y^7 ...
     +     4369.0 * pi^4 /   5806080.0 * y^9 ...
     +    34807.0 * pi^5 / 182476800.0 * y^11 ...
     + 20036983.0 * pi^6);

  return
end

