#! /usr/bin/env python # def p_polynomial_zeros ( nt ): #*****************************************************************************80 # ## P_POLYNOMIAL_ZEROS: zeros of Legendre function P(n,x). # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 16 March 2016 # # Author: # # John Burkardt # # Parameters: # # Input, integer NT, the order of the rule. # # Output, real T(NT), the zeros. # import numpy as np from imtqlx import imtqlx a = np.zeros ( nt ) b = np.zeros ( nt ) for i in range ( 0, nt ): ip1 = i + 1 b[i] = ip1 / np.sqrt ( 4 * ip1 * ip1 - 1 ) c = np.zeros ( nt ) c[0] = np.sqrt ( 2.0 ) t, w = imtqlx ( nt, a, b, c ) return t def p_polynomial_zeros_test ( ): #*****************************************************************************80 # ## P_POLYNOMIAL_ZEROS_TEST tests P_POLYNOMIAL_ZEROS. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 16 March 2016 # # Author: # # John Burkardt # import numpy as np import platform from p_polynomial_value import p_polynomial_value from r8vec_print import r8vec_print print ( '' ) print ( 'P_POLYNOMIAL_ZEROS_TEST:' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' P_POLYNOMIAL_ZEROS computes the zeros of P(n,x)' ) print ( ' Check by calling P_POLYNOMIAL_VALUE there.' ) for degree in range ( 1, 6 ): z = p_polynomial_zeros ( degree ) title = ' Computed zeros for P(%d,x)' % ( degree ) r8vec_print ( degree, z, title ) lz = p_polynomial_value ( degree, degree, z ) title = ' Evaluate P(%d,z)' % ( degree ) lzvec = np.zeros ( degree ) for i in range ( 0, degree ): lzvec[i] = lz[i,degree] r8vec_print ( degree, lzvec, title ) # # Terminate. # print ( '' ) print ( 'P_POLYNOMIAL_ZEROS_TEST' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) p_polynomial_zeros_test ( ) timestamp ( )