#! /usr/bin/env python # def t_polynomial_zeros ( n ): #*****************************************************************************80 # ## T_POLYNOMIAL_ZEROS returns zeroes of the Chebyshev polynomial T(n,x). # # Discussion: # # The I-th zero is cos((2*I-1)*PI/(2*N)), I = 1 to N # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 12 July 2015 # # Author: # # John Burkardt # # Parameters: # # Input, integer N, the order of the polynomial. # # Output, real Z(N), the zeroes. # import numpy as np z = np.zeros ( n ) for i in range ( 0, n ): angle = float ( 2 * i + 1 ) * np.pi / float ( 2 * n ) z[i] = np.cos ( angle ) return z def t_polynomial_zeros_test ( ): #*****************************************************************************80 # ## T_POLYNOMIAL_ZEROS_TEST tests T_POLYNOMIAL_ZEROS. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 12 July 2015 # # Author: # # John Burkardt # import platform from t_polynomial import t_polynomial print ( '' ) print ( 'T_POLYNOMIAL_ZEROS_TEST:' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' T_POLYNOMIAL_ZEROS computes the zeros of T(n,x)' ) print ( '' ) print ( ' N X T(n,x)' ) for n in range ( 0, 6 ): x = t_polynomial_zeros ( n ) fx = t_polynomial ( n, n + 1, x ) print ( '' ) for i in range ( 0, n ): print ( ' %4d %8.4g %14.6g' % ( i, x[i], fx[i,n] ) ) # # Terminate. # print ( '' ) print ( 'T_POLYNOMIAL_ZEROS_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) t_polynomial_zeros_test ( ) timestamp ( )