#! /usr/bin/env python # def u_polynomial_zeros ( n ): #*****************************************************************************80 # ## U_POLYNOMIAL_ZEROS returns zeroes of the Chebyshev polynomial T(n,x). # # Discussion: # # The I-th zero of U(n,x) is cos((I-1)*PI/(N-1)), 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 ( i + 1 ) * np.pi / float ( n + 1 ) z[i] = np.cos ( angle ) return z def u_polynomial_zeros_test ( ): #*****************************************************************************80 # ## U_POLYNOMIAL_ZEROS_TEST tests U_POLYNOMIAL_ZEROS. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 12 July 2015 # # Author: # # John Burkardt # import platform from u_polynomial import u_polynomial print ( '' ) print ( 'U_POLYNOMIAL_ZEROS_TEST:' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' U_POLYNOMIAL_ZEROS computes the zeros of U(n,x)' ) print ( '' ) print ( ' N X U(n,x)' ) for n in range ( 0, 6 ): x = u_polynomial_zeros ( n ) fx = u_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 ( 'U_POLYNOMIAL_ZEROS_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) u_polynomial_zeros_test ( ) timestamp ( )