C
C.......................................................................
C
C	 SUBROUTINE NDTRI
C
C	 PURPOSE
C	   COMPUTES X = P**(-1)(Y), THE ARGUMENT X SUCH THAT Y= P(X) =
C	   THE PROBABILITY THAT THE RANDOM VARIABLE U, DISTRIBUTED
C	   NORMALLY(0,1), IS LESS THAN OR EQUAL TO X.  F(X), THE
C	   ORDINATE OF THE NORMAL DENSITY, AT X, IS ALSO COMPUTED.
C
C	 USAGE
C	   CALL NDTRI(P,X,D,IER)
C
C	 DESCRIPTION OF PARAMETERS
C	   P   - INPUT PROBABILITY.
C	   X   - OUTPUT ARGUMENT SUCH THAT P = Y = THE PROBABILITY THAT
C		    U, THE RANDOM VARIABLE, IS LESS THAN OR EQUAL TO X.
C	   D   - OUTPUT DENSITY, F(X).
C	   IER - OUTPUT ERROR CODE
C		 = -1 IF P IS NOT IN THE INTERVAL (0,1), INCLUSIVE.
C		   X=D=.99999E+74 IN THIS CASE
C		 = 0 IF THERE IS NO ERROR.  SEE REMARKS, BELOW.
C
C	 REMARKS
C	   MAXIMUM ERROR IS 0.00045.
C	   IF P = 0, X IS SET TO -(10)**74.  D IS SET TO 0.
C	   IF P = 1, X IS SET TO  (10)**74.  D IS SET TO 0.
C
C	 SUBROUTINES AND SUBPROGRAMS REQUIRED
C	   NONE
C
C	 METHOD
C	   BASED ON APPROXIMATIONS IN C. HASTINGS, APPROXIMATIONS FOR
C	   DIGITAL COMPUTERS, PRINCETON UNIV. PRESS, PRINCETON, N.J.,
C	   1955.  SEE EQUATION 26.2.23, HANDBOOK OF MATHEMATICAL
C	   FUNCTIONS, ABRAMOWITZ AND STEGUN, DOVER PUBLICATIONS, INC.,
C	   NEW YORK.
C
C.......................................................................
C
      SUBROUTINE NDTRI(P,X,D,IE)
C
      IE=0
      X=.99999E+38
      D=X
      IF(P)1,4,2
    1 IE=-1
      GO TO 12
    2 IF (P-1.0)7,5,1
    4 X=-.999999E+38
    5 D=0.0
      GO TO 12
C
C
    7 D=P
      IF(D-0.5)9,9,8
    8 D=1.0-D
    9 T2=ALOG(1.0/(D*D))
      T=SQRT(T2)
      X=T-(2.515517+0.802853*T+0.010328*T2)/(1.0+1.432788*T+0.189269*T2
     1	+0.001308*T*T2)
      IF(P-0.5)10,10,11
   10 X=-X
   11 D=0.3989423*EXP(-X*X/2.0)
   12 RETURN
      END











.515517+0.802853*T+0.010