#! /usr/bin/env python # def t_polynomial_ab_value ( a, b, n, xab ): #*****************************************************************************80 # ## T_POLYNOMIAL_AB: Chebyshev polynomial TAB(N,X) in [A,B]. # # Discussion: # # TAB(n,x) = T(n,(2*x-a-b)/(b-a)) # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 20 July 2015 # # Author: # # John Burkardt # # Parameters: # # Input, real A, B, the domain of definition. # # Input, integer N, the degree of the polynomial. # # Input, real XAB, the evaluation points. # A <= XAB <= B. # # Output, real V, the value. # from t_polynomial_value import t_polynomial_value x = ( 2.0 * xab - a - b ) / ( b - a ) v = t_polynomial_value ( n, x ); return v def t_polynomial_ab_value_test ( ): #*****************************************************************************80 # ## T_POLYNOMIAL_AB_VALUE_TEST tests T_POLYNOMIAL_AB_VALUE. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 20 July 2015 # # Author: # # John Burkardt # import numpy as np import platform from t_polynomial_01_values import t_polynomial_01_values print ( '' ) print ( 'T_POLYNOMIAL_AB_VALUE_TEST:' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' T_POLYNOMIAL_AB_VALUE evaluates a Chebyshev polynomial TAB(n,x)' ) print ( ' shifted from [-1,+1] to the domain [A,B].' ) print ( '' ) print ( ' Here, we will use the new domain [0,1].' ) print ( '' ) print ( ' Tabulated Computed' ) print ( ' N X T01(n,x) T01(n,x)' ) print ( '' ) a = 0.0 b = 1.0 n_data = 0 while ( True ): n_data, n, x01, fx = t_polynomial_01_values ( n_data ) if ( n_data == 0 ): break fx2 = t_polynomial_ab_value ( a, b, n, x01 ) print ( ' %8d %8.4f %14.6g %14.6g' % ( n, x01, fx, fx2 ) ) # # Terminate. # print ( '' ) print ( 'T_POLYNOMIAL_AB_VALUE_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) t_polynomial_ab_value_test ( ) timestamp ( )