<filename>gaussianQuadratureLookup.py<gh_stars>0
#ref https://pomax.github.io/bezierinfo/legendre-gauss.html
class GaussianQuadratureLookup:
    def __init__(self, N):
        self.N = N
        self.lookupDic = {}


    #Multiples of 3 and 9 below
        #N = 3
        weights = [0.8888888888888888,
                0.5555555555555556,
                0.5555555555555556]
        xs = [0.0000000000000000,
            -0.7745966692414834,
            0.7745966692414834]
        self.lookupDic[3] = (weights, xs)

        #N = 9
        weights = [0.3302393550012598,
                    0.1806481606948574,
                    0.1806481606948574,
                    0.0812743883615744,
                    0.0812743883615744,
                    0.3123470770400029,
                    0.3123470770400029,
                    0.2606106964029354,
                    0.2606106964029354]
        xs = [0.0000000000000000,
            -0.8360311073266358,
            0.8360311073266358,
            -0.9681602395076261,
            0.9681602395076261,
            -0.3242534234038089,
            0.3242534234038089,
            -0.6133714327005904,
            0.6133714327005904]
        self.lookupDic[9] = (weights, xs)

        #N = 18
        weights = [0.1691423829631436,
                    0.1691423829631436,
                    0.1642764837458327,
                    0.1642764837458327,
                    0.1546846751262652,
                    0.1546846751262652,
                    0.1406429146706507,
                    0.1406429146706507,
                    0.1225552067114785,
                    0.1225552067114785,
                    0.1009420441062872,
                    0.1009420441062872,
                    0.0764257302548891,
                    0.0764257302548891,
                    0.0497145488949698,
                    0.0497145488949698,
                    0.0216160135264833,
                    0.0216160135264833]
        xs = [-0.0847750130417353,
                0.0847750130417353,
                -0.2518862256915055,
                0.2518862256915055,
                -0.4117511614628426,
                0.4117511614628426,
                -0.5597708310739475,
                0.5597708310739475,
                -0.6916870430603532,
                0.6916870430603532,
                -0.8037049589725231,
                0.8037049589725231,
                -0.8926024664975557,
                0.8926024664975557,
                -0.9558239495713977,
                0.9558239495713977,
                -0.9915651684209309,
                0.9915651684209309]
        self.lookupDic[18] = (weights, xs)

    #Multiples of 4 & 8 below
        #N = 4
        weights = [0.6521451548625461,
                0.6521451548625461,
                0.3478548451374538,
                0.3478548451374538]
        xs = [-0.3399810435848563,
                0.3399810435848563,
                -0.8611363115940526,
                0.8611363115940526]
        self.lookupDic[4] = (weights, xs)

        #N = 8
        weights = [0.3626837833783620,
                0.3626837833783620,
                0.3137066458778873,
                0.3137066458778873,
                0.2223810344533745,
                0.2223810344533745,
                0.1012285362903763,
                0.1012285362903763]
        xs = [-0.1834346424956498,
            0.1834346424956498,
            -0.5255324099163290,
            0.5255324099163290,
            -0.7966664774136267,
            0.7966664774136267,
            -0.9602898564975363,
            0.9602898564975363]
        self.lookupDic[8] = (weights, xs)

        #N = 12
        weights = [0.2491470458134028,
            0.2491470458134028,
            0.2334925365383548,
            0.2334925365383548,
            0.2031674267230659,
            0.2031674267230659,
            0.1600783285433462,
            0.1600783285433462,
            0.1069393259953184,
            0.1069393259953184,
            0.0471753363865118,
            0.0471753363865118]
        xs = [-0.1252334085114689,
            0.1252334085114689,
            -0.3678314989981802,
            0.3678314989981802,
            -0.5873179542866175,
            0.5873179542866175,
            -0.7699026741943047,
            0.7699026741943047,
            -0.9041172563704749,
            0.9041172563704749,
            -0.9815606342467192,
            0.9815606342467192]
        self.lookupDic[12] = (weights, xs)

        #N = 16
        weights = [0.1894506104550685,
                    0.1894506104550685,
                    0.1826034150449236,
                    0.1826034150449236,
                    0.1691565193950025,
                    0.1691565193950025,
                    0.1495959888165767,
                    0.1495959888165767,
                    0.1246289712555339,
                    0.1246289712555339,
                    0.0951585116824928,
                    0.0951585116824928,
                    0.0622535239386479,
                    0.0622535239386479,
                    0.0271524594117541,
                    0.0271524594117541]
        xs = [-0.0950125098376374,
                0.0950125098376374,
                -0.2816035507792589,
                0.2816035507792589,
                -0.4580167776572274,
                0.4580167776572274,
                -0.6178762444026438,
                0.6178762444026438,
                -0.7554044083550030,
                0.7554044083550030,
                -0.8656312023878318,
                0.8656312023878318,
                -0.9445750230732326,
                0.9445750230732326,
                -0.9894009349916499,
                0.9894009349916499]
        self.lookupDic[16] = (weights, xs)

        #N = 24
        weights = [0.1279381953467522,
                    0.1279381953467522,
                    0.1258374563468283,
                    0.1258374563468283,
                    0.1216704729278034,
                    0.1216704729278034,
                    0.1155056680537256,
                    0.1155056680537256,
                    0.1074442701159656,
                    0.1074442701159656,
                    0.0976186521041139,
                    0.0976186521041139,
                    0.0861901615319533,
                    0.0861901615319533,
                    0.0733464814110803,
                    0.0733464814110803,
                    0.0592985849154368,
                    0.0592985849154368,
                    0.0442774388174198,
                    0.0442774388174198,
                    0.0285313886289337,
                    0.0285313886289337,
                    0.0123412297999872,
                    0.0123412297999872]
        xs = [-0.0640568928626056,
                0.0640568928626056,
                -0.1911188674736163,
                0.1911188674736163,
                -0.3150426796961634,
                0.3150426796961634,
                -0.4337935076260451,
                0.4337935076260451,
                -0.5454214713888396,
                0.5454214713888396,
                -0.6480936519369755,
                0.6480936519369755,
                -0.7401241915785544,
                0.7401241915785544,
                -0.8200019859739029,
                0.8200019859739029,
                -0.8864155270044011,
                0.8864155270044011,
                -0.9382745520027328,
                0.9382745520027328,
                -0.9747285559713095,
                0.9747285559713095,
                -0.9951872199970213,
                0.9951872199970213]
        self.lookupDic[24] = (weights, xs)

        #N = 32
        weights = [0.0965400885147278,
                    0.0965400885147278,
                    0.0956387200792749,
                    0.0956387200792749,
                    0.0938443990808046,
                    0.0938443990808046,
                    0.0911738786957639,
                    0.0911738786957639,
                    0.0876520930044038,
                    0.0876520930044038,
                    0.0833119242269467,
                    0.0833119242269467,
                    0.0781938957870703,
                    0.0781938957870703,
                    0.0723457941088485,
                    0.0723457941088485,
                    0.0658222227763618,
                    0.0658222227763618,
                    0.0586840934785355,
                    0.0586840934785355,
                    0.0509980592623762,
                    0.0509980592623762,
                    0.0428358980222267,
                    0.0428358980222267,
                    0.0342738629130214,
                    0.0342738629130214,
                    0.0253920653092621,
                    0.0253920653092621,
                    0.0162743947309057,
                    0.0162743947309057,
                    0.0070186100094701,
                    0.0070186100094701]
        xs = [-0.0483076656877383,
                0.0483076656877383,
                -0.1444719615827965,
                0.1444719615827965,
                -0.2392873622521371,
                0.2392873622521371,
                -0.3318686022821277,
                0.3318686022821277,
                -0.4213512761306353,
                0.4213512761306353,
                -0.5068999089322294,
                0.5068999089322294,
                -0.5877157572407623,
                0.5877157572407623,
                -0.6630442669302152,
                0.6630442669302152,
                -0.7321821187402897,
                0.7321821187402897,
                -0.7944837959679424,
                0.7944837959679424,
                -0.8493676137325700,
                0.8493676137325700,
                -0.8963211557660521,
                0.8963211557660521,
                -0.9349060759377397,
                0.9349060759377397,
                -0.9647622555875064,
                0.9647622555875064,
                -0.9856115115452684,
                0.9856115115452684,
                -0.9972638618494816,
                0.9972638618494816]
        self.lookupDic[32] = (weights, xs)        


    #returns weights, then x's
    def getWeightsAndVariables(self):
        var = self.lookupDic[self.N]
        return var[0], var[1]
<filename>gaussianQuadratureLookup.py<gh_stars>0
#ref https://pomax.github.io/bezierinfo/legendre-gauss.html
class GaussianQuadratureLookup:
    def __init__(self, N):
        self.N = N
        self.lookupDic = {}


    #Multiples of 3 and 9 below
        #N = 3
        weights = [0.8888888888888888,
                0.5555555555555556,
                0.5555555555555556]
        xs = [0.0000000000000000,
            -0.7745966692414834,
            0.7745966692414834]
        self.lookupDic[3] = (weights, xs)

        #N = 9
        weights = [0.3302393550012598,
                    0.1806481606948574,
                    0.1806481606948574,
                    0.0812743883615744,
                    0.0812743883615744,
                    0.3123470770400029,
                    0.3123470770400029,
                    0.2606106964029354,
                    0.2606106964029354]
        xs = [0.0000000000000000,
            -0.8360311073266358,
            0.8360311073266358,
            -0.9681602395076261,
            0.9681602395076261,
            -0.3242534234038089,
            0.3242534234038089,
            -0.6133714327005904,
            0.6133714327005904]
        self.lookupDic[9] = (weights, xs)

        #N = 18
        weights = [0.1691423829631436,
                    0.1691423829631436,
                    0.1642764837458327,
                    0.1642764837458327,
                    0.1546846751262652,
                    0.1546846751262652,
                    0.1406429146706507,
                    0.1406429146706507,
                    0.1225552067114785,
                    0.1225552067114785,
                    0.1009420441062872,
                    0.1009420441062872,
                    0.0764257302548891,
                    0.0764257302548891,
                    0.0497145488949698,
                    0.0497145488949698,
                    0.0216160135264833,
                    0.0216160135264833]
        xs = [-0.0847750130417353,
                0.0847750130417353,
                -0.2518862256915055,
                0.2518862256915055,
                -0.4117511614628426,
                0.4117511614628426,
                -0.5597708310739475,
                0.5597708310739475,
                -0.6916870430603532,
                0.6916870430603532,
                -0.8037049589725231,
                0.8037049589725231,
                -0.8926024664975557,
                0.8926024664975557,
                -0.9558239495713977,
                0.9558239495713977,
                -0.9915651684209309,
                0.9915651684209309]
        self.lookupDic[18] = (weights, xs)

    #Multiples of 4 & 8 below
        #N = 4
        weights = [0.6521451548625461,
                0.6521451548625461,
                0.3478548451374538,
                0.3478548451374538]
        xs = [-0.3399810435848563,
                0.3399810435848563,
                -0.8611363115940526,
                0.8611363115940526]
        self.lookupDic[4] = (weights, xs)

        #N = 8
        weights = [0.3626837833783620,
                0.3626837833783620,
                0.3137066458778873,
                0.3137066458778873,
                0.2223810344533745,
                0.2223810344533745,
                0.1012285362903763,
                0.1012285362903763]
        xs = [-0.1834346424956498,
            0.1834346424956498,
            -0.5255324099163290,
            0.5255324099163290,
            -0.7966664774136267,
            0.7966664774136267,
            -0.9602898564975363,
            0.9602898564975363]
        self.lookupDic[8] = (weights, xs)

        #N = 12
        weights = [0.2491470458134028,
            0.2491470458134028,
            0.2334925365383548,
            0.2334925365383548,
            0.2031674267230659,
            0.2031674267230659,
            0.1600783285433462,
            0.1600783285433462,
            0.1069393259953184,
            0.1069393259953184,
            0.0471753363865118,
            0.0471753363865118]
        xs = [-0.1252334085114689,
            0.1252334085114689,
            -0.3678314989981802,
            0.3678314989981802,
            -0.5873179542866175,
            0.5873179542866175,
            -0.7699026741943047,
            0.7699026741943047,
            -0.9041172563704749,
            0.9041172563704749,
            -0.9815606342467192,
            0.9815606342467192]
        self.lookupDic[12] = (weights, xs)

        #N = 16
        weights = [0.1894506104550685,
                    0.1894506104550685,
                    0.1826034150449236,
                    0.1826034150449236,
                    0.1691565193950025,
                    0.1691565193950025,
                    0.1495959888165767,
                    0.1495959888165767,
                    0.1246289712555339,
                    0.1246289712555339,
                    0.0951585116824928,
                    0.0951585116824928,
                    0.0622535239386479,
                    0.0622535239386479,
                    0.0271524594117541,
                    0.0271524594117541]
        xs = [-0.0950125098376374,
                0.0950125098376374,
                -0.2816035507792589,
                0.2816035507792589,
                -0.4580167776572274,
                0.4580167776572274,
                -0.6178762444026438,
                0.6178762444026438,
                -0.7554044083550030,
                0.7554044083550030,
                -0.8656312023878318,
                0.8656312023878318,
                -0.9445750230732326,
                0.9445750230732326,
                -0.9894009349916499,
                0.9894009349916499]
        self.lookupDic[16] = (weights, xs)

        #N = 24
        weights = [0.1279381953467522,
                    0.1279381953467522,
                    0.1258374563468283,
                    0.1258374563468283,
                    0.1216704729278034,
                    0.1216704729278034,
                    0.1155056680537256,
                    0.1155056680537256,
                    0.1074442701159656,
                    0.1074442701159656,
                    0.0976186521041139,
                    0.0976186521041139,
                    0.0861901615319533,
                    0.0861901615319533,
                    0.0733464814110803,
                    0.0733464814110803,
                    0.0592985849154368,
                    0.0592985849154368,
                    0.0442774388174198,
                    0.0442774388174198,
                    0.0285313886289337,
                    0.0285313886289337,
                    0.0123412297999872,
                    0.0123412297999872]
        xs = [-0.0640568928626056,
                0.0640568928626056,
                -0.1911188674736163,
                0.1911188674736163,
                -0.3150426796961634,
                0.3150426796961634,
                -0.4337935076260451,
                0.4337935076260451,
                -0.5454214713888396,
                0.5454214713888396,
                -0.6480936519369755,
                0.6480936519369755,
                -0.7401241915785544,
                0.7401241915785544,
                -0.8200019859739029,
                0.8200019859739029,
                -0.8864155270044011,
                0.8864155270044011,
                -0.9382745520027328,
                0.9382745520027328,
                -0.9747285559713095,
                0.9747285559713095,
                -0.9951872199970213,
                0.9951872199970213]
        self.lookupDic[24] = (weights, xs)

        #N = 32
        weights = [0.0965400885147278,
                    0.0965400885147278,
                    0.0956387200792749,
                    0.0956387200792749,
                    0.0938443990808046,
                    0.0938443990808046,
                    0.0911738786957639,
                    0.0911738786957639,
                    0.0876520930044038,
                    0.0876520930044038,
                    0.0833119242269467,
                    0.0833119242269467,
                    0.0781938957870703,
                    0.0781938957870703,
                    0.0723457941088485,
                    0.0723457941088485,
                    0.0658222227763618,
                    0.0658222227763618,
                    0.0586840934785355,
                    0.0586840934785355,
                    0.0509980592623762,
                    0.0509980592623762,
                    0.0428358980222267,
                    0.0428358980222267,
                    0.0342738629130214,
                    0.0342738629130214,
                    0.0253920653092621,
                    0.0253920653092621,
                    0.0162743947309057,
                    0.0162743947309057,
                    0.0070186100094701,
                    0.0070186100094701]
        xs = [-0.0483076656877383,
                0.0483076656877383,
                -0.1444719615827965,
                0.1444719615827965,
                -0.2392873622521371,
                0.2392873622521371,
                -0.3318686022821277,
                0.3318686022821277,
                -0.4213512761306353,
                0.4213512761306353,
                -0.5068999089322294,
                0.5068999089322294,
                -0.5877157572407623,
                0.5877157572407623,
                -0.6630442669302152,
                0.6630442669302152,
                -0.7321821187402897,
                0.7321821187402897,
                -0.7944837959679424,
                0.7944837959679424,
                -0.8493676137325700,
                0.8493676137325700,
                -0.8963211557660521,
                0.8963211557660521,
                -0.9349060759377397,
                0.9349060759377397,
                -0.9647622555875064,
                0.9647622555875064,
                -0.9856115115452684,
                0.9856115115452684,
                -0.9972638618494816,
                0.9972638618494816]
        self.lookupDic[32] = (weights, xs)        


    #returns weights, then x's
    def getWeightsAndVariables(self):
        var = self.lookupDic[self.N]
        return var[0], var[1]
#ref https://pomax.github.io/bezierinfo/legendre-gauss.html #Multiples of 3 and 9 below #N = 3 #N = 9 #N = 18 #Multiples of 4 & 8 below #N = 4 #N = 8 #N = 12 #N = 16 #N = 24 #N = 32 #returns weights, then x's