#! /usr/bin/env python # def laguerre_1_set ( n ): #*****************************************************************************80 # ## LAGUERRE_1_SET sets abscissas and weights for Laguerre quadrature. # # Discussion: # # This routine is specialized for the case where the density function is 1. # # The integral is: # I(f) = integral ( 0 <= x < +oo ) f(x) dx # The quadrature rule is # Q(f) = sum ( 1 <= i <= n ) w(i) * f ( x(i) ) # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 17 June 2015 # # Author: # # John Burkardt # # Parameters: # # Input, integer N, the order. # N must be between 1 and 10. # # Output, real X(N), the abscissas. # # Output, real W(N), the weights. # import numpy as np from sys import exit if ( n == 1 ): x = np.array ( [ \ 1.00000000000000000000000000000 ] ) w = np.array ( [ \ 2.7182818284590451 ] ) elif ( n == 2 ): x = np.array ( [ \ 0.585786437626904951198311275790, \ 3.41421356237309504880168872421 ] ) w = np.array ( [ \ 1.5333260331194167, \ 4.4509573350545928 ] ) elif ( n == 3 ): x = np.array ( [ \ 0.415774556783479083311533873128, \ 2.29428036027904171982205036136, \ 6.28994508293747919686641576551 ] ) w = np.array ( [ \ 1.0776928592709207, \ 2.7621429619015876, \ 5.6010946254344267 ] ) elif ( n == 4 ): x = np.array ( [ \ 0.322547689619392311800361459104, \ 1.74576110115834657568681671252, \ 4.53662029692112798327928538496, \ 9.39507091230113312923353644342 ] ) w = np.array ( [ \ 0.83273912383788917, \ 2.0481024384542965, \ 3.6311463058215168, \ 6.4871450844076604 ] ) elif ( n == 5 ): x = np.array ( [ \ 0.263560319718140910203061943361, \ 1.41340305910651679221840798019, \ 3.59642577104072208122318658878, \ 7.08581000585883755692212418111, \ 12.6408008442757826594332193066 ] ) w = np.array ( [ \ 0.67909404220775038, \ 1.6384878736027471, \ 2.7694432423708375, \ 4.3156569009208940, \ 7.2191863543544450 ] ) elif ( n == 6 ): x = np.array ( [ \ 0.222846604179260689464354826787, \ 1.18893210167262303074315092194, \ 2.99273632605931407769132528451, \ 5.77514356910451050183983036943, \ 9.83746741838258991771554702994, \ 15.9828739806017017825457915674 ] ) w = np.array ( [ \ 0.57353550742273818, \ 1.3692525907123045, \ 2.2606845933826722, \ 3.3505245823554555, \ 4.8868268002108213, \ 7.8490159455958279 ] ) elif ( n == 7 ): x = np.array ( [ \ 0.193043676560362413838247885004, \ 1.02666489533919195034519944317, \ 2.56787674495074620690778622666, \ 4.90035308452648456810171437810, \ 8.18215344456286079108182755123, \ 12.7341802917978137580126424582, \ 19.3957278622625403117125820576 ] ) w = np.array ( [ \ 0.49647759753997234, \ 1.1776430608611976, \ 1.9182497816598063, \ 2.7718486362321113, \ 3.8412491224885148, \ 5.3806782079215330, \ 8.4054324868283103 ] ) elif ( n == 8 ): x = np.array ( [ \ 0.170279632305100999788861856608, \ 0.903701776799379912186020223555, \ 2.25108662986613068930711836697, \ 4.26670017028765879364942182690, \ 7.04590540239346569727932548212, \ 10.7585160101809952240599567880, \ 15.7406786412780045780287611584, \ 22.8631317368892641057005342974 ] ) w = np.array ( [ \ 0.43772341049291136, \ 1.0338693476655976, \ 1.6697097656587756, \ 2.3769247017585995, \ 3.2085409133479259, \ 4.2685755108251344, \ 5.8180833686719184, \ 8.9062262152922216 ] ) elif ( n == 9 ): x = np.array ( [ \ 0.152322227731808247428107073127, \ 0.807220022742255847741419210952, \ 2.00513515561934712298303324701, \ 3.78347397333123299167540609364, \ 6.20495677787661260697353521006, \ 9.37298525168757620180971073215, \ 13.4662369110920935710978818397, \ 18.8335977889916966141498992996, \ 26.3740718909273767961410072937 ] ) w = np.array ( [ \ 0.39143112431563987, \ 0.92180502852896307, \ 1.4801279099429154, \ 2.0867708075492613, \ 2.7729213897119713, \ 3.5916260680922663, \ 4.6487660021402037, \ 6.2122754197471348, \ 9.3632182377057980 ] ) elif ( n == 10 ): x = np.array ( [ \ 0.137793470540492430830772505653, \ 0.729454549503170498160373121676, \ 1.80834290174031604823292007575, \ 3.40143369785489951448253222141, \ 5.55249614006380363241755848687, \ 8.33015274676449670023876719727, \ 11.8437858379000655649185389191, \ 16.2792578313781020995326539358, \ 21.9965858119807619512770901956, \ 29.9206970122738915599087933408 ] ) w = np.array ( [ \ 0.35400973860699630, \ 0.83190230104358065, \ 1.3302885617493283, \ 1.8630639031111309, \ 2.4502555580830108, \ 3.1227641551351848, \ 3.9341526955615240, \ 4.9924148721930299, \ 6.5722024851307994, \ 9.7846958403746243 ] ) else: print ( '' ) print ( 'LAGUERRE_1_SET - Fatal error!' ) print ( ' Illegal value of N = %d' % ( n ) ) print ( ' Legal values are 1 to 10.' ) exit ( 'LAGUERRE_1_SET - Fatal error!' ) return x, w def laguerre_1_set_test ( ): #*****************************************************************************80 # ## LAGUERRE_1_SET_TEST tests LAGUERRE_1_SET. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 17 June 2015 # # Author: # # John Burkardt # import platform print ( '' ) print ( 'LAGUERRE_1_SET_TEST' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' LAGUERRE_1_SET sets a Laguerre rule.' ) print ( ' The density function is rho(x)=1.' ) print ( '' ) print ( ' I X W' ) for n in range ( 1, 11 ): x, w = laguerre_1_set ( n ) print ( '' ) for i in range ( 0, n ): print ( ' %8d %24.16g %24.16g' % ( i, x[i], w[i] ) ) # # Terminate. # print ( '' ) print ( 'LAGUERRE_1_SET_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) laguerre_1_set_test ( ) timestamp ( )