#! /usr/bin/env python # def w_polynomial_ab ( a, b, m, n, xab ): #*****************************************************************************80 # ## W_POLYNOMIAL_AB: Chebyshev polynomials WAB(N,X) in [A,B]. # # Discussion: # # WAB(n,x) = W(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 M, the number of evaluation points. # # Input, integer N, the highest polynomial to compute. # # Input, real XAB(M,1), the evaluation points. # A <= XAB(*) <= B. # # Output, real V(M,N+1), the values of the Chebyshev polynomials. # from w_polynomial import w_polynomial x = ( 2.0 * xab - a - b ) / ( b - a ) v = w_polynomial ( m, n, x ); return v def w_polynomial_ab_test ( ): #*****************************************************************************80 # ## W_POLYNOMIAL_AB_TEST tests W_POLYNOMIAL_AB. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 20 July 2015 # # Author: # # John Burkardt # import numpy as np import platform from r8mat_print import r8mat_print print ( '' ) print ( 'W_POLYNOMIAL_AB_TEST:' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' W_POLYNOMIAL_AB evaluates Chebyshev polynomials WAB(n,x)' ) print ( ' shifted from [-1,+1] to the domain [A,B].' ) print ( '' ) print ( ' Here, we will use the new domain [0,1]' ) print ( ' and the desired maximum polynomial degree will be N = 5.' ) a = 0.0 b = 1.0 m = 11 n = 5 x = np.linspace ( a, b, m ) v = w_polynomial_ab ( a, b, m, n, x ) r8mat_print ( m, n + 1, v, ' Tables of W values:' ) # # Terminate. # print ( '' ) print ( 'W_POLYNOMIAL_AB_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) w_polynomial_ab_test ( ) timestamp ( )