! Exemplul Mueller-Kahan
! Kahan (2006): "How Futile are Mindless Assessments of Roundoff in Floating-Point Computation ?"
!
! f(y,z) =108.-(815.-1500./z)/y
! x_0 =4; x_1 =4.25; x_(n+1) =f(x_n, x_(n-1))
! 
! Calculati x_n pt. n "mare": n ~ 80
! Limita corecta: x_n --> 5
! 
! Pentru compilare cu CVF:
! -----------------------
! Faceti comentarii instructiunile referitoare la tipul real(16)
!

implicit real(8) (d)
implicit real(16) (q)

df(dy,dz) =108.-(815.-1500./dz)/dy
qf(qy,qz) =108.-(815.-1500./qz)/qy

open(1, file ='K-M-q.rez',status ='unknown', form ='formatted')

write(1, '(/,t11,a, t40,a)') ' Double Precision (53)', 'Quadruple Precision (113)'

! Initialize:
dx0 = 4d0
dx1 = 4.25d0 

qx0 = 4Q0
qx1 = 4.25Q0

! Compute:
do i=1,81,5

dxi =df(dx1,dx0)
qxi =qf(qx1,qx0)

write(1,*) i, dxi, qxi

dx0 =dx1
dx1 =dxi

qx0 =qx1
qx1 =qxi

enddo


close(1)

write(*, '(a, /)') 'Result File: "K-M-q.rez"'

END