#! /usr/bin/env python # def r8_epsilon ( ): #*****************************************************************************80 # ## R8_EPSILON returns the R8 roundoff unit. # # Discussion: # # The roundoff unit is a number R which is a power of 2 with the # property that, to the precision of the computer's arithmetic, # 1 < 1 + R # but # 1 = ( 1 + R / 2 ) # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 03 June 2013 # # Author: # # John Burkardt # # Parameters: # # Output, real VALUE, the roundoff unit. # value = 2.220446049250313E-016 return value def r8_epsilon_test ( ): #*****************************************************************************80 # ## R8_EPSILON_TEST tests R8_EPSILON. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 01 September 2012 # # Author: # # John Burkardt # import platform print ( '' ) print ( 'R8_EPSILON_TEST' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' R8_EPSILON produces the R8 roundoff unit.' ) print ( '' ) r = r8_epsilon ( ) print ( ' R = R8_EPSILON() = %e' % ( r ) ) s = ( 1.0 + r ) - 1.0 print ( ' ( 1 + R ) - 1 = %e' % ( s ) ) s = ( 1.0 + ( r / 2.0 ) ) - 1.0 print ( ' ( 1 + (R/2) ) - 1 = %e' % ( s ) ) # # Terminate. # print ( '' ) print ( 'R8_EPSILON_TEST' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) r8_epsilon_test ( ) timestamp ( )