\documentstyle [11pt] {article}
\pagestyle{empty}
%
\topmargin=-0.75in
\hoffset=-0.75in
\textheight=10.0in \vsize\textheight
\textwidth=6.5in \hsize\textwidth
%
\begin {document}
{\Large
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Insert source immediately following \begin{verbatim}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{verbatim}
c-----------------------------------------------------------
c     Program illustrating "catastrophic" loss of precision
c     resulting from the subtraction of two nearly equal 
c     floating point values.
c-----------------------------------------------------------
      program         catprec

      implicit        none

      real*8          x  
      parameter     ( x = 0.2d0 )

      integer         i
      real*8          h,     dsinx

      write(*,*) '      h      d(sin) approx   '//
     &           'd(sin) exact    d(sin) err'
      write(*,*)

      h = 0.5d0
      do i = 1 , 16
c-----------------------------------------------------------
c        Algebraically, in the limit h -> 0, dsinx should
c        approach cos(x), but sin(x+h) -> sin(x) so 
c        catastrophic loss of precision occurs.
c-----------------------------------------------------------
         dsinx = (sin(x+h) - sin(x)) / h
         write(*,1000) h,  dsinx,  cos(x),   dsinx - cos(x)
1000     format(1P,E12.3,2E16.8,E12.3)
         h = 0.125d0 * h
      end do

      stop

      end 
\end{verbatim}
\clearpage
\begin{verbatim}
       h      d(sin) approx   d(sin) exact    d(sin) err

   5.000E-01  8.91096713E-01  9.80066578E-01  -8.897E-02
   6.250E-02  9.73222242E-01  9.80066578E-01  -6.844E-03
   7.812E-03  9.79280560E-01  9.80066578E-01  -7.860E-04
   9.766E-04  9.79969416E-01  9.80066578E-01  -9.716E-05
   1.221E-04  9.80054450E-01  9.80066578E-01  -1.213E-05
   1.526E-05  9.80065062E-01  9.80066578E-01  -1.516E-06
   1.907E-06  9.80066388E-01  9.80066578E-01  -1.895E-07
   2.384E-07  9.80066554E-01  9.80066578E-01  -2.369E-08
   2.980E-08  9.80066574E-01  9.80066578E-01  -3.663E-09
   3.725E-09  9.80066575E-01  9.80066578E-01  -2.731E-09
   4.657E-10  9.80066538E-01  9.80066578E-01  -3.998E-08
   5.821E-11  9.80066299E-01  9.80066578E-01  -2.784E-07
   7.276E-12  9.80064392E-01  9.80066578E-01  -2.186E-06
   9.095E-13  9.80041504E-01  9.80066578E-01  -2.507E-05
   1.137E-13  9.79980469E-01  9.80066578E-01  -8.611E-05
   1.421E-14  9.78515625E-01  9.80066578E-01  -1.551E-03
\end{verbatim}
}
%
\end {document}
