#! /usr/bin/env python # def u_polynomial_ab_value ( a, b, n, xab ): #*****************************************************************************80 # ## U_POLYNOMIAL_AB: Chebyshev polynomial UAB(N,X) in [A,B]. # # Discussion: # # UAB(n,x) = U(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 u_polynomial_value import u_polynomial_value x = ( 2.0 * xab - a - b ) / ( b - a ) v = u_polynomial_value ( n, x ); return v def u_polynomial_ab_value_test ( ): #*****************************************************************************80 # ## U_POLYNOMIAL_AB_VALUE_TEST tests U_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 u_polynomial_01_values import u_polynomial_01_values print ( '' ) print ( 'U_POLYNOMIAL_AB_VALUE_TEST:' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' U_POLYNOMIAL_AB_VALUE evaluates a Chebyshev polynomial UAB(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 U01(n,x) U01(n,x)' ) print ( '' ) a = 0.0 b = 1.0 n_data = 0 while ( True ): n_data, n, x01, fx = u_polynomial_01_values ( n_data ) if ( n_data == 0 ): break fx2 = u_polynomial_ab_value ( a, b, n, x01 ) print ( ' %8d %8.4f %14.6g %14.6g' % ( n, x01, fx, fx2 ) ) # # Terminate. # print ( '' ) print ( 'U_POLYNOMIAL_AB_VALUE_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) u_polynomial_ab_value_test ( ) timestamp ( )