CCL Home Page
Up Directory CCL f.18
C    *******************************************************************
C    ** THIS FORTRAN CODE IS INTENDED TO ILLUSTRATE POINTS MADE IN    **
C    ** THE TEXT. TO OUR KNOWLEDGE IT WORKS CORRECTLY. HOWEVER IT IS  **
C    ** THE RESPONSIBILITY OF THE USER TO TEST IT, IF IT IS USED IN A **
C    ** RESEARCH APPLICATION.                                         **
C    *******************************************************************

C    *******************************************************************
C    ** FICHE F.18                                                    **
C    ** FUNCTION TO COMPUTE SQUARE ROOT FASTER THAN FORTRAN SQRT.     **
C    *******************************************************************

        REAL FUNCTION SSQRT ( XSQ )

C    *******************************************************************
C    ** FUNCTION TO COMPUTE SQUARE ROOT FASTER THAN FORTRAN SQRT.     **
C    **                                                               **
C    ** THIS FUNCTION RETURNS THE SQUARE ROOT OF A REAL NUMBER XSQ    **
C    ** WITH 0.1 < XSQ < 1.0. THE METHOD USES A POLYNOMIAL            **
C    ** APPROXIMATION FOLLOWED BY NEWTON-RAPHSON ITERATION.           **
C    **                                                               **
C    ** REFERENCES:                                                   **
C    **                                                               **
C    ** SINGER, CCP5 QUARTERLY, 8, 47, 1983.                          **
C    ** POWLES, CCP5 QUARTERLY, 11, 39, 1984.                         **
C    **                                                               **
C    ** PRINCIPAL VARIABLES:                                          **
C    **                                                               **
C    ** REAL    XSQ          THE NUMBER WHOSE SQUARE ROOT IS REQUIRED **
C    ** REAL    X            THE SQUARE ROOT                          **
C    ** REAL    C0,C1,C2,C3  COEFFICIENTS IN THE POLYNOMIAL APPROX.   **
C    *******************************************************************

        REAL        XSQ

        REAL        X
        REAL        C0, C1, C2, C3

        PARAMETER ( C0 =  0.188030699,  C1 = 1.48359853  )
        PARAMETER ( C2 = -1.0979059  ,  C3 = 0.430357353 )

C    *******************************************************************

C    ** POLYNOMIAL APPROXIMATION TO X **

        X = C0 + XSQ * ( C1 + XSQ * ( C2 + XSQ * C3 ) )

C    ** ITERATION OF APPROXIMATION **

        X =     X + 0.5 * ( XSQ / X - X )
        X =     X + 0.5 * ( XSQ / X - X )
        SSQRT = X + 0.5 * ( XSQ / X - X )

        RETURN
        END


Modified: Fri Oct 15 16:00:00 1993 GMT
Page accessed 6162 times since Sat Aug 26 23:06:04 2000 GMT