#! /usr/bin/env python # def integral_log ( ): #*****************************************************************************80 # ## INTEGRAL_LOG evaluates the test integral with logarithmic singularity. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 December 2015 # # Author: # # John Burkardt # # Parameters: # # Output, real VALUE, the integral of the test integrand from 0 to 1. # value = - 0.012771107587415899716 return value def integral_log_test ( ): #*****************************************************************************80 # ## INTEGRAL_LOG_TEST tests INTEGRAL_LOG. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 December 2015 # # Author: # # John Burkardt # print ( '' ) print ( 'INTEGRAL_LOG_TEST:' ) print ( ' INTEGRAL_LOG returns the value of the integral of the log-singular' ) print ( ' test function over [0,1].' ) print ( '' ) value = integral_log ( ) print ( ' INTEGRAL_LOG = %g' % ( value ) ) # # Terminate. # print ( '' ) print ( 'INTEGRAL_LOG_TEST:' ) print ( ' Normal end of execution.' ) return def integral_power ( ): #*****************************************************************************80 # ## INTEGRAL_POWER evaluates the test integral with power singularity. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 December 2015 # # Author: # # John Burkardt # # Parameters: # # Output, real VALUE, the integral of the test integrand from 0 to 1. # value = 0.079321002746971411182 return value def integral_power_test ( ): #*****************************************************************************80 # ## INTEGRAL_POWER_TEST tests INTEGRAL_POWER. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 December 2015 # # Author: # # John Burkardt # print ( '' ) print ( 'INTEGRAL_POWER_TEST:' ) print ( ' INTEGRAL_POWER returns the value of the integral of the power-singular' ) print ( ' test function over [0,1].' ) print ( '' ) value = integral_power ( ) print ( ' INTEGRAL_POWER = %g' % ( value ) ) # # Terminate. # print ( '' ) print ( 'INTEGRAL_POWER_TEST:' ) print ( ' Normal end of execution.' ) return def integral_regular ( ): #*****************************************************************************80 # ## INTEGRAL_REGULAR evaluates the regular test integral. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 December 2015 # # Author: # # John Burkardt # # Parameters: # # Output, real VALUE, the integral of the test integrand from 0 to 1. # import numpy as np value = ( - np.sin ( 0.3 ) + np.sin ( 200.0 ) + np.sin ( 200.3 ) ) / 200.0 return value def integral_regular_test ( ): #*****************************************************************************80 # ## INTEGRAL_REGULAR_TEST tests INTEGRAL_REGULAR. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 December 2015 # # Author: # # John Burkardt # print ( '' ) print ( 'INTEGRAL_REGULAR_TEST:' ) print ( ' INTEGRAL_REGULAR returns the value of the integral of the regular' ) print ( ' test function over [0,1].' ) print ( '' ) value = integral_regular ( ) print ( ' INTEGRAL_REGULAR = %g' % ( value ) ) # # Terminate. # print ( '' ) print ( 'INTEGRAL_REGULAR_TEST:' ) print ( ' Normal end of execution.' ) return def integrand_log ( n, x ): #*****************************************************************************80 # ## INTEGRAND_LOG evaluates the test integrand with logarithmic singularity. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 December 2015 # # Author: # # John Burkardt # # Parameters: # # Input, integer N, the number of evaluation points. # # Input, real X(N), the evaluation points. # # Output, real F(N), the integrand at the evaluation points. # import numpy as np f = np.zeros ( n ) f[0:n] = np.cos ( 200.0 * x[0:n] ) * np.log ( x[0:n] ) \ + np.cos ( 200.0 * x[0:n] + 0.3 ) return f def integrand_log_test ( ): #*****************************************************************************80 # ## INTEGRAND_LOG_TEST tests INTEGRAND_LOG. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 December 2015 # # Author: # # John Burkardt # from r8vec_linspace2 import r8vec_linspace2 print ( '' ) print ( 'INTEGRAND_LOG_TEST:' ) print ( ' INTEGRAND_LOG evaluates the log-singular test function.' ) n = 9 x = r8vec_linspace2 ( n, 0.0, 1.0 ) f = integrand_log ( n, x ) print ( '' ) print ( ' X F(X)' ) print ( '' ) for i in range ( 0, n ): print ( ' %2d %14.6g %14.6g' % ( i, x[i], f[i] ) ) # # Terminate. # print ( '' ) print ( 'INTEGRAND_LOG_TEST:' ) print ( ' Normal end of execution.' ) return def integrand_power ( n, x ): #*****************************************************************************80 # ## INTEGRAND_POWER evaluates the test integrand with power singularity. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 December 2015 # # Author: # # John Burkardt # # Parameters: # # Input, integer N, the number of evaluation points. # # Input, real X(N), the evaluation points. # # Output, real F(N), the integrand at the evaluation points. # import numpy as np f = np.zeros ( n ) f[0:n] = np.cos ( 200.0 * x[0:n] ) * x[0:n] ** ( - 0.5 ) \ + np.cos ( 200.0 * x[0:n] + 0.3 ) return f def integrand_power_test ( ): #*****************************************************************************80 # ## INTEGRAND_POWER_TEST tests INTEGRAND_POWER. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 December 2015 # # Author: # # John Burkardt # from r8vec_linspace2 import r8vec_linspace2 print ( '' ) print ( 'INTEGRAND_POWER_TEST:' ) print ( ' INTEGRAND_POWER evaluates the power-singular test function.' ) n = 9 x = r8vec_linspace2 ( n, 0.0, 1.0 ) f = integrand_power ( n, x ) print ( '' ) print ( ' X F(X)' ) print ( '' ) for i in range ( 0, n ): print ( ' %2d %14.6g %14.6g' % ( i, x[i], f[i] ) ) # # Terminate. # print ( '' ) print ( 'INTEGRAND_POWER_TEST:' ) print ( ' Normal end of execution.' ) return def integrand_regular ( n, x ): #*****************************************************************************80 # ## INTEGRAND_REGULAR evaluates the regular test integrand. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 December 2015 # # Author: # # John Burkardt # # Parameters: # # Input, integer N, the number of evaluation points. # # Input, real X(N), the evaluation points. # # Output, real F(N), the integrand at the evaluation points. # import numpy as np f = np.zeros ( n ) f[0:n] = np.cos ( 200.0 * x[0:n] ) + np.cos ( 200.0 * x[0:n] + 0.3 ) return f def integrand_regular_test ( ): #*****************************************************************************80 # ## INTEGRAND_REGULAR_TEST tests INTEGRAND_REGULAR. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 05 December 2015 # # Author: # # John Burkardt # from r8vec_linspace2 import r8vec_linspace2 print ( '' ) print ( 'INTEGRAND_REGULAR_TEST:' ) print ( ' INTEGRAND_REGULAR evaluates the regular test function.' ) n = 9 x = r8vec_linspace2 ( n, 0.0, 1.0 ) f = integrand_regular ( n, x ) print ( '' ) print ( ' X F(X)' ) print ( '' ) for i in range ( 0, n ): print ( ' %2d %14.6g %14.6g' % ( i, x[i], f[i] ) ) # # Terminate. # print ( '' ) print ( 'INTEGRAND_REGULAR_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) integral_log_test ( ) integral_power_test ( ) integral_regular_test ( ) integrand_log_test ( ) integrand_power_test ( ) integrand_regular_test ( ) timestamp ( )