#! /usr/bin/env python # def ttt_product_integral ( i, j, k ): #*****************************************************************************80 # ## TTT_PRODUCT_INTEGRAL: integral (-1<=x<=1) T(i,x)*T(j,x)*T(k,x)/sqrt(1-x^2) dx # # Discussion: # # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 14 July 2015 # # Author: # # John Burkardt # # Reference: # # John Mason, David Handscomb, # Chebyshev Polynomials, # CRC Press, 2002, # ISBN: 0-8493-035509, # LC: QA404.5.M37. # # Parameters: # # Input, integer I, J, K, the polynomial indices. # 0 <= I, J. # # Output, real VALUE, the integral. # from tt_product_integral import tt_product_integral if ( i < 0 ): value = 0.0 return value if ( j < 0 ): value = 0.0 return value if ( k < 0 ): value = 0.0 return value value = 0.5 * ( \ tt_product_integral ( i + j, k ) + \ + tt_product_integral ( abs ( i - j ), k ) ) return value def ttt_product_integral_test ( ): #*****************************************************************************80 # ## TTT_PRODUCT_INTEGRAL_TEST tests TTT_PRODUCT_INTEGRAL. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 14 July 2015 # # Author: # # John Burkardt # import platform from i4_uniform_ab import i4_uniform_ab from t_polynomial_value import t_polynomial_value from t_quadrature_rule import t_quadrature_rule test_num = 20 print ( '' ) print ( 'TTT_PRODUCT_INTEGRAL_TEST:' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' TTT_PRODUCT_INTEGRAL computes the triple integral' ) print ( ' Tijk = integral ( -1 <= x <= 1 ) T(i,x) T(j,x) T(k,x) / sqrt ( 1-x^2) dx' ) print ( '' ) print ( ' I J K Tijk Tijk' ) print ( ' computed exact' ) print ( '' ) n = 15 x, w = t_quadrature_rule ( n ) seed = 123456789 for test in range ( 0, test_num ): i, seed = i4_uniform_ab ( 2, 6, seed ) j, seed = i4_uniform_ab ( 1, 3, seed ) k, seed = i4_uniform_ab ( 0, 4, seed ) fx1 = ttt_product_integral ( i, j, k ) fx2 = 0.0 for l in range ( 0, n ): ti = t_polynomial_value ( i, x[l] ) tj = t_polynomial_value ( j, x[l] ) tk = t_polynomial_value ( k, x[l] ) fx2 = fx2 + w[l] * ti * tj * tk print ( ' %2d %2d %2d %14.6g %14.6g' % ( i, j, k, fx1, fx2 ) ) # # Terminate. # print ( '' ) print ( 'TTT_PRODUCT_INTEGRAL_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) ttt_product_integral_test ( ) timestamp ( )