#! /usr/bin/env python # def laguerre_general_values ( n_data ): #*****************************************************************************80 # ## LAGUERRE_GENERAL_VALUES: values of the generalized Laguerre polynomials. # # Discussion: # # In Mathematica, the function can be evaluated by: # # LaguerreL[n,a,x] # # The functions satisfy the following differential equation: # # X * Y'' + (ALPHA+1-X) * Y' + N * Y = 0 # # Function values can be generated by the recursion: # # L(0,ALPHA)(X) = 1 # L(1,ALPHA)(X) = 1+ALPHA-X # # L(N,ALPHA)(X) = ( (2*N-1+ALPHA-X) * L(N-1,ALPHA)(X) # - (N-1+ALPHA) * L(N-2,ALPHA)(X) ) / N # # The parameter ALPHA is required to be greater than -1. # # For ALPHA = 0, the generalized Laguerre function L(N,ALPHA)(X) # is equal to the Laguerre polynomial L(N)(X). # # For ALPHA integral, the generalized Laguerre function # L(N,ALPHA)(X) equals the associated Laguerre polynomial L(N,ALPHA)(X). # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 17 February 2015 # # Author: # # John Burkardt # # Reference: # # Stephen Wolfram, # The Mathematica Book, # Fourth Edition, # Wolfram Media / Cambridge University Press, 1999. # # Parameters: # # Input/output, integer N_DATA. The user sets N_DATA to 0 before the # first call. On each call, the routine increments N_DATA by 1, and # returns the corresponding data; when there is no more data, the # output value of N_DATA will be 0 again. # # Output, integer N, the order of the function. # # Output, real A, the parameter. # # Output, real X, the point where the function is evaluated. # # Output, real F, the value of the function. # import numpy as np n_max = 20 a_vec = np.array ( ( \ 0.00E+00, \ 0.25E+00, \ 0.50E+00, \ 0.75E+00, \ 1.50E+00, \ 2.50E+00, \ 5.00E+00, \ 1.20E+00, \ 1.20E+00, \ 1.20E+00, \ 1.20E+00, \ 1.20E+00, \ 1.20E+00, \ 5.20E+00, \ 5.20E+00, \ 5.20E+00, \ 5.20E+00, \ 5.20E+00, \ 5.20E+00, \ 5.20E+00 )) f_vec = np.array ( ( \ 0.3726399739583333E-01, \ 0.3494791666666667E+00, \ 0.8710042317708333E+00, \ 0.1672395833333333E+01, \ 0.6657625325520833E+01, \ 0.2395726725260417E+02, \ 0.2031344319661458E+03, \ 0.1284193996800000E+02, \ 0.5359924801587302E+01, \ 0.9204589064126984E+00, \ -0.1341585114857143E+01, \ -0.2119726307555556E+01, \ -0.1959193658349206E+01, \ 0.1000000000000000E+01, \ 0.5450000000000000E+01, \ 0.1720125000000000E+02, \ 0.4110393750000000E+02, \ 0.8239745859375000E+02, \ 0.1460179186171875E+03, \ 0.2359204608298828E+03 )) n_vec = np.array ( ( \ 5, \ 5, \ 5, \ 5, \ 5, \ 5, \ 5, \ 8, \ 8, \ 8, \ 8, \ 8, \ 8, \ 0, \ 1, \ 2, \ 3, \ 4, \ 5, \ 6 )) x_vec = np.array ( ( \ 0.25E+00, \ 0.25E+00, \ 0.25E+00, \ 0.25E+00, \ 0.25E+00, \ 0.25E+00, \ 0.25E+00, \ 0.00E+00, \ 0.20E+00, \ 0.40E+00, \ 0.60E+00, \ 0.80E+00, \ 1.00E+00, \ 0.75E+00, \ 0.75E+00, \ 0.75E+00, \ 0.75E+00, \ 0.75E+00, \ 0.75E+00, \ 0.75E+00 )) if ( n_data < 0 ): n_data = 0 if ( n_max <= n_data ): n_data = 0 n = 0 a = 0.0 x = 0.0 f = 0.0 else: n = n_vec[n_data] a = a_vec[n_data] x = x_vec[n_data] f = f_vec[n_data] n_data = n_data + 1 return n_data, n, a, x, f def laguerre_general_values_test ( ): #*****************************************************************************80 # ## LAGUERRE_GENERAL_VALUES_TEST demonstrates the use of LAGUERRE_GENERAL_VALUES. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 17 February 2015 # # Author: # # John Burkardt # import platform print ( '' ) print ( 'LAGUERRE_GENERAL_VALUES_TEST:' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' LAGUERRE_GENERAL_VALUES stores values of the general Laguerre function.' ) print ( '' ) print ( ' N A X F' ) print ( '' ) n_data = 0 while ( True ): n_data, n, a, x, f = laguerre_general_values ( n_data ) if ( n_data == 0 ): break print ( ' %6d %12f %12f %24.16g' % ( n, a, x, f ) ) # # Terminate. # print ( '' ) print ( 'LAGUERRE_GENERAL_VALUES_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) laguerre_general_values_test ( ) timestamp ( )