def gauss_laguerre(n, n_digits): r""" Computes the Gauss-Laguerre quadrature [1] points and weights. Parameters ========== n : the order of quadrature n_digits : number of significant digits of the points and weights to return Returns ======= (x, w) : the ``x`` and ``w`` are lists of points and weights as Floats The Gauss-Laguerre quadrature approximates the integral: .. math:: \int_0^{\infty} e^{-x} f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i) The points `x_i` and weights `w_i` are returned as ``(x, w)`` tuple of lists. Examples ======== >>> from sympy.integrals.quadrature import gauss_laguerre >>> x, w = gauss_laguerre(3, 5) >>> x [0.41577, 2.2943, 6.2899] >>> w [0.71109, 0.27852, 0.010389] >>> x, w = gauss_laguerre(6, 5) >>> x [0.22285, 1.1889, 2.9927, 5.7751, 9.8375, 15.983] >>> w [0.45896, 0.417, 0.11337, 0.010399, 0.00026102, 8.9855e-7] [1] http://en.wikipedia.org/wiki/Gauss%E2%80%93Laguerre_quadrature """ x = Dummy("x") p = laguerre_poly(n, x, polys=True) p1 = laguerre_poly(n+1, x, polys=True) xi = [] w = [] for r in p.real_roots(): if isinstance(r, RootOf): r = r.eval_rational(S(1)/10**(n_digits+2)) xi.append(r.n(n_digits)) w.append((r/((n+1)**2 * p1.subs(x, r)**2)).n(n_digits)) return xi, w
def test_laguerre_poly(): raises(ValueError, "laguerre_poly(-1, x)") assert laguerre_poly(1, x, polys=True) == Poly(-x + 1) assert laguerre_poly(0, x) == 1 assert laguerre_poly(1, x) == -x + 1 assert laguerre_poly(2, x) == Q(1,2)*x**2 - Q(4,2)*x + 1 assert laguerre_poly(3, x) == -Q(1,6)*x**3 + Q(9,6)*x**2 - Q(18,6)*x + 1 assert laguerre_poly(4, x) == Q(1,24)*x**4 - Q(16,24)*x**3 + Q(72,24)*x**2 - Q(96,24)*x + 1 assert laguerre_poly(5, x) == -Q(1,120)*x**5 + Q(25,120)*x**4 - Q(200,120)*x**3 + Q(600,120)*x**2 - Q(600,120)*x + 1 assert laguerre_poly(6, x) == Q(1,720)*x**6 - Q(36,720)*x**5 + Q(450,720)*x**4 - Q(2400,720)*x**3 + Q(5400,720)*x**2 - Q(4320,720)*x + 1
def test_laguerre_poly(): raises(ValueError, "laguerre_poly(-1, x)") assert laguerre_poly(1, x, polys=True) == Poly(-x + 1) assert laguerre_poly(0, x) == 1 assert laguerre_poly(1, x) == -x + 1 assert laguerre_poly(2, x) == Q(1, 2) * x**2 - Q(4, 2) * x + 1 assert laguerre_poly( 3, x) == -Q(1, 6) * x**3 + Q(9, 6) * x**2 - Q(18, 6) * x + 1 assert laguerre_poly(4, x) == Q(1, 24) * x**4 - Q(16, 24) * x**3 + Q( 72, 24) * x**2 - Q(96, 24) * x + 1 assert laguerre_poly(5, x) == -Q(1, 120) * x**5 + Q(25, 120) * x**4 - Q( 200, 120) * x**3 + Q(600, 120) * x**2 - Q(600, 120) * x + 1 assert laguerre_poly( 6, x) == Q(1, 720) * x**6 - Q(36, 720) * x**5 + Q(450, 720) * x**4 - Q( 2400, 720) * x**3 + Q(5400, 720) * x**2 - Q(4320, 720) * x + 1
def laguerre_l(n, alpha, x): """ Returns the generalized Laguerre polynomial. Parameters ========== n : int Degree of Laguerre polynomial. Must be ``n >= 0``. alpha : Expr Arbitrary expression. For ``alpha=0`` regular Laguerre polynomials will be generated. Examples ======== To construct generalized Laguerre polynomials issue:: >>> from sympy import laguerre_l, var >>> var("alpha, x") (alpha, x) >>> laguerre_l(0, alpha, x) 1 >>> laguerre_l(1, alpha, x) alpha - x + 1 >>> laguerre_l(2, alpha, x) alpha**2/2 + 3*alpha/2 + x**2/2 + x*(-alpha - 2) + 1 If you set ``alpha=0``, you get regular Laguerre polynomials:: >>> laguerre_l(1, 0, x) -x + 1 >>> laguerre_l(2, 0, x) x**2/2 - 2*x + 1 >>> laguerre_l(3, 0, x) -x**3/6 + 3*x**2/2 - 3*x + 1 >>> laguerre_l(4, 0, x) x**4/24 - 2*x**3/3 + 3*x**2 - 4*x + 1 See Also ======== sympy.polys.orthopolys.laguerre_poly """ return laguerre_poly(n, x, alpha)
def test_assoc_laguerre(): n = Symbol("n") m = Symbol("m") alpha = Symbol("alpha") # generalized Laguerre polynomials: assert assoc_laguerre(0, alpha, x) == 1 assert assoc_laguerre(1, alpha, x) == -x + alpha + 1 assert assoc_laguerre(2, alpha, x).expand() == \ (x**2/2 - (alpha + 2)*x + (alpha + 2)*(alpha + 1)/2).expand() assert assoc_laguerre(3, alpha, x).expand() == \ (-x**3/6 + (alpha + 3)*x**2/2 - (alpha + 2)*(alpha + 3)*x/2 + (alpha + 1)*(alpha + 2)*(alpha + 3)/6).expand() # Test the lowest 10 polynomials with laguerre_poly, to make sure it works: for i in range(10): assert assoc_laguerre(i, 0, x).expand() == laguerre_poly(i, x) X = assoc_laguerre(n, m, x) assert isinstance(X, assoc_laguerre) assert assoc_laguerre(n, 0, x) == laguerre(n, x) assert assoc_laguerre(n, alpha, 0) == binomial(alpha + n, alpha) p = Symbol("p", positive=True) assert assoc_laguerre(p, alpha, oo) == (-1)**p * oo assert assoc_laguerre(p, alpha, -oo) is oo assert diff(assoc_laguerre(n, alpha, x), x) == \ -assoc_laguerre(n - 1, alpha + 1, x) _k = Dummy('k') assert diff(assoc_laguerre(n, alpha, x), alpha).dummy_eq( Sum(assoc_laguerre(_k, alpha, x) / (-alpha + n), (_k, 0, n - 1))) assert conjugate(assoc_laguerre(n, alpha, x)) == \ assoc_laguerre(n, conjugate(alpha), conjugate(x)) assert assoc_laguerre(n, alpha, x).rewrite('polynomial').dummy_eq( gamma(alpha + n + 1) * Sum( x**_k * RisingFactorial(-n, _k) / (factorial(_k) * gamma(_k + alpha + 1)), (_k, 0, n)) / factorial(n)) raises(ValueError, lambda: assoc_laguerre(-2.1, alpha, x)) raises(ArgumentIndexError, lambda: assoc_laguerre(n, alpha, x).fdiff(1)) raises(ArgumentIndexError, lambda: assoc_laguerre(n, alpha, x).fdiff(4))
def eval(cls, n, alpha, x): # L_{n}^{0}(x) ---> L_{n}(x) if alpha.is_zero: return laguerre(n, x) if not n.is_Number: # We can evaluate for some special values of x if x.is_zero: return binomial(n + alpha, alpha) elif x is S.Infinity and n > 0: return S.NegativeOne ** n * S.Infinity elif x is S.NegativeInfinity and n > 0: return S.Infinity else: # n is a given fixed integer, evaluate into polynomial if n.is_negative: raise ValueError("The index n must be nonnegative integer (got %r)" % n) else: return laguerre_poly(n, x, alpha)
def eval(cls, n, alpha, x): # L_{n}^{0}(x) ---> L_{n}(x) if alpha == S.Zero: return laguerre(n, x) if not n.is_Number: # We can evaluate for some special values of x if x == S.Zero: return C.binomial(n+alpha, alpha) elif x == S.Infinity and n > S.Zero: return S.NegativeOne**n * S.Infinity elif x == S.NegativeInfinity and n > S.Zero: return S.Infinity else: # n is a given fixed integer, evaluate into polynomial if n.is_negative: raise ValueError("The index n must be nonnegative integer (got %r)" % n) else: return laguerre_poly(n, x, alpha)
def eval(cls, n, x): if not n.is_Number: # Symbolic result L_n(x) # L_{n}(-x) ---> exp(-x) * L_{-n-1}(x) # L_{-n}(x) ---> exp(x) * L_{n-1}(-x) if n.could_extract_minus_sign(): return C.exp(x) * laguerre(n-1, -x) # We can evaluate for some special values of x if x == S.Zero: return S.One elif x == S.NegativeInfinity: return S.Infinity elif x == S.Infinity: return S.NegativeOne**n * S.Infinity else: # n is a given fixed integer, evaluate into polynomial if n.is_negative: raise ValueError("The index n must be nonnegative integer (got %r)" % n) else: return laguerre_poly(n, x, 0)
def eval(cls, n, x): if not n.is_Number: # Symbolic result L_n(x) # L_{n}(-x) ---> exp(-x) * L_{-n-1}(x) # L_{-n}(x) ---> exp(x) * L_{n-1}(-x) if n.could_extract_minus_sign(): return C.exp(x) * laguerre(n - 1, -x) # We can evaluate for some special values of x if x == S.Zero: return S.One elif x == S.NegativeInfinity: return S.Infinity elif x == S.Infinity: return S.NegativeOne**n * S.Infinity else: # n is a given fixed integer, evaluate into polynomial if n.is_negative: raise ValueError( "The index n must be nonnegative integer (got %r)" % n) else: return laguerre_poly(n, x, 0)
def laguerre_l(n, alpha, x): """ Returns the generalized Laguerre polynomial. ``n`` : ``int`` Degree of Laguerre polynomial. Must be ``n >= 0``. ``alpha`` : ``Expr`` Arbitrary expression. For ``alpha=0`` regular Laguerre polynomials will be generated. **Examples** To construct generalized Laguerre polynomials issue:: >>> from sympy import laguerre_l, var >>> var("alpha, x") (alpha, x) >>> laguerre_l(0, alpha, x) 1 >>> laguerre_l(1, alpha, x) alpha - x + 1 >>> laguerre_l(2, alpha, x) alpha**2/2 + 3*alpha/2 + x**2/2 + x*(-alpha - 2) + 1 If you set ``alpha=0``, you get regular Laguerre polynomials:: >>> laguerre_l(1, 0, x) -x + 1 >>> laguerre_l(2, 0, x) x**2/2 - 2*x + 1 >>> laguerre_l(3, 0, x) -x**3/6 + 3*x**2/2 - 3*x + 1 >>> laguerre_l(4, 0, x) x**4/24 - 2*x**3/3 + 3*x**2 - 4*x + 1 """ return laguerre_poly(n, x, alpha)
def gauss_laguerre(n, n_digits): r""" Computes the Gauss-Laguerre quadrature [1]_ points and weights. The Gauss-Laguerre quadrature approximates the integral: .. math:: \int_0^{\infty} e^{-x} f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i) The nodes `x_i` of an order `n` quadrature rule are the roots of `L_n` and the weights `w_i` are given by: .. math:: w_i = \frac{x_i}{(n+1)^2 \left(L_{n+1}(x_i)\right)^2} Parameters ========== n : the order of quadrature n_digits : number of significant digits of the points and weights to return Returns ======= (x, w) : the ``x`` and ``w`` are lists of points and weights as Floats. The points `x_i` and weights `w_i` are returned as ``(x, w)`` tuple of lists. Examples ======== >>> from sympy.integrals.quadrature import gauss_laguerre >>> x, w = gauss_laguerre(3, 5) >>> x [0.41577, 2.2943, 6.2899] >>> w [0.71109, 0.27852, 0.010389] >>> x, w = gauss_laguerre(6, 5) >>> x [0.22285, 1.1889, 2.9927, 5.7751, 9.8375, 15.983] >>> w [0.45896, 0.417, 0.11337, 0.010399, 0.00026102, 8.9855e-7] See Also ======== gauss_legendre, gauss_gen_laguerre, gauss_hermite, gauss_chebyshev_t, gauss_chebyshev_u, gauss_jacobi, gauss_lobatto References ========== .. [1] https://en.wikipedia.org/wiki/Gauss%E2%80%93Laguerre_quadrature .. [2] http://people.sc.fsu.edu/~jburkardt/cpp_src/laguerre_rule/laguerre_rule.html """ x = Dummy("x") p = laguerre_poly(n, x, polys=True) p1 = laguerre_poly(n + 1, x, polys=True) xi = [] w = [] for r in p.real_roots(): if isinstance(r, RootOf): r = r.eval_rational(S(1) / 10**(n_digits + 2)) xi.append(r.n(n_digits)) w.append((r / ((n + 1)**2 * p1.subs(x, r)**2)).n(n_digits)) return xi, w
def gauss_gen_laguerre(n, alpha, n_digits): r""" Computes the generalized Gauss-Laguerre quadrature [1]_ points and weights. The generalized Gauss-Laguerre quadrature approximates the integral: .. math:: \int_{0}^\infty x^{\alpha} e^{-x} f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i) The nodes `x_i` of an order `n` quadrature rule are the roots of `L^{\alpha}_n` and the weights `w_i` are given by: .. math:: w_i = \frac{\Gamma(\alpha+n)} {n \Gamma(n) L^{\alpha}_{n-1}(x_i) L^{\alpha+1}_{n-1}(x_i)} Parameters ========== n : the order of quadrature alpha : the exponent of the singularity, `\alpha > -1` n_digits : number of significant digits of the points and weights to return Returns ======= (x, w) : the ``x`` and ``w`` are lists of points and weights as Floats. The points `x_i` and weights `w_i` are returned as ``(x, w)`` tuple of lists. Examples ======== >>> from sympy import S >>> from sympy.integrals.quadrature import gauss_gen_laguerre >>> x, w = gauss_gen_laguerre(3, -S.Half, 5) >>> x [0.19016, 1.7845, 5.5253] >>> w [1.4493, 0.31413, 0.00906] >>> x, w = gauss_gen_laguerre(4, 3*S.Half, 5) >>> x [0.97851, 2.9904, 6.3193, 11.712] >>> w [0.53087, 0.67721, 0.11895, 0.0023152] See Also ======== gauss_legendre, gauss_laguerre, gauss_hermite, gauss_chebyshev_t, gauss_chebyshev_u, gauss_jacobi, gauss_lobatto References ========== .. [1] https://en.wikipedia.org/wiki/Gauss%E2%80%93Laguerre_quadrature .. [2] http://people.sc.fsu.edu/~jburkardt/cpp_src/gen_laguerre_rule/gen_laguerre_rule.html """ x = Dummy("x") p = laguerre_poly(n, x, alpha=alpha, polys=True) p1 = laguerre_poly(n - 1, x, alpha=alpha, polys=True) p2 = laguerre_poly(n - 1, x, alpha=alpha + 1, polys=True) xi = [] w = [] for r in p.real_roots(): if isinstance(r, RootOf): r = r.eval_rational(S(1) / 10**(n_digits + 2)) xi.append(r.n(n_digits)) w.append((gamma(alpha + n) / (n * gamma(n) * p1.subs(x, r) * p2.subs(x, r))).n(n_digits)) return xi, w
def test_laguerre_poly(): raises(ValueError, lambda: laguerre_poly(-1, x)) assert laguerre_poly(1, x, polys=True) == Poly(-x + 1) assert laguerre_poly(0, x) == 1 assert laguerre_poly(1, x) == -x + 1 assert laguerre_poly(2, x) == Q(1, 2) * x**2 - Q(4, 2) * x + 1 assert laguerre_poly( 3, x) == -Q(1, 6) * x**3 + Q(9, 6) * x**2 - Q(18, 6) * x + 1 assert laguerre_poly(4, x) == Q(1, 24) * x**4 - Q(16, 24) * x**3 + Q( 72, 24) * x**2 - Q(96, 24) * x + 1 assert laguerre_poly(5, x) == -Q(1, 120) * x**5 + Q(25, 120) * x**4 - Q( 200, 120) * x**3 + Q(600, 120) * x**2 - Q(600, 120) * x + 1 assert laguerre_poly( 6, x) == Q(1, 720) * x**6 - Q(36, 720) * x**5 + Q(450, 720) * x**4 - Q( 2400, 720) * x**3 + Q(5400, 720) * x**2 - Q(4320, 720) * x + 1 assert laguerre_poly(0, x, a) == 1 assert laguerre_poly(1, x, a) == -x + a + 1 assert laguerre_poly( 2, x, a) == x**2 / 2 + (-a - 2) * x + a**2 / 2 + a * Q(3, 2) + 1 assert laguerre_poly(3, x, a) == -x**3 / 6 + (a / 2 + Q(3) / 2) * x**2 + ( -a**2 / 2 - a * Q(5, 2) - 3) * x + a**3 / 6 + a**2 + a * Q(11, 6) + 1 assert laguerre_poly(1).dummy_eq(-x + 1) assert laguerre_poly(1, polys=True) == Poly(-x + 1)
hermite_poly(2, x) == HermiteP.subs(n, 2).doit() # True hermite_poly(3, x) == HermiteP.subs(n, 3).doit() # True hermite_poly(4, x) == HermiteP.subs(n, 4).doit() # True (HermiteF.subs(n, n + 1) / HermiteF).simplify() # 2*x*(n + 1)/(-2*k + n + 1) (HermiteF.subs(k, k + 1) / HermiteF).simplify() # -(2*k - n)*(2*k - n + 1)/(4*x**2*(k + 1)) LaguerreF = binomial(n + alpha, n - k) * (-x) ** k / factorial(k) LaguerreP = Sum(LaguerreF, (k, 0, n)) for alphavar in range(4): for nvar in range(4): print alphavar, nvar, LaguerreP.subs(n, nvar).subs(alpha, alphavar).doit(), LaguerreP.subs(n, nvar).subs( alpha, alphavar ).doit() == laguerre_poly( nvar, x, alpha=alphavar ) # True (LaguerreF.subs(n, n + 1) / LaguerreF).simplify() # (alpha + n + 1)/(-k + n + 1) (LaguerreF.subs(k, k + 1) / LaguerreF).simplify() # x*(k - n)/((k + 1)*(alpha + k + 1)) LegendreF = Rat(1) / (Rat(2) ** n) * (binomial(n, k)) ** 2 * (x - Rat(1)) ** k * (x + Rat(1)) ** (n - k) LegendreP = Sum(LegendreF, (k, 0, n)) for nvar in range(4): legendre_poly(nvar, x) == LegendreP.subs(n, nvar).doit().expand() # True (LegendreF.subs(n, n + 1) / LegendreF).simplify() # (n + 1)**2*(x + 1)/(2*(k - n - 1)**2) (LegendreF.subs(k, k + 1) / LegendreF).simplify() # (k - n)**2*(x - 1)/((k + 1)**2*(x + 1)) JacobiF = (
def test_laguerre_poly(): raises(ValueError, lambda: laguerre_poly(-1, x)) assert laguerre_poly(1, x, polys=True) == Poly(-x + 1) assert laguerre_poly(0, x) == 1 assert laguerre_poly(1, x) == -x + 1 assert laguerre_poly(2, x) == Q(1,2)*x**2 - Q(4,2)*x + 1 assert laguerre_poly(3, x) == -Q(1,6)*x**3 + Q(9,6)*x**2 - Q(18,6)*x + 1 assert laguerre_poly(4, x) == Q(1,24)*x**4 - Q(16,24)*x**3 + Q(72,24)*x**2 - Q(96,24)*x + 1 assert laguerre_poly(5, x) == -Q(1,120)*x**5 + Q(25,120)*x**4 - Q(200,120)*x**3 + Q(600,120)*x**2 - Q(600,120)*x + 1 assert laguerre_poly(6, x) == Q(1,720)*x**6 - Q(36,720)*x**5 + Q(450,720)*x**4 - Q(2400,720)*x**3 + Q(5400,720)*x**2 - Q(4320,720)*x + 1 assert laguerre_poly(0, x, a) == 1 assert laguerre_poly(1, x, a) == -x + a + 1 assert laguerre_poly(2, x, a) == x**2/2 + (-a - 2)*x + a**2/2 + 3*a/2 + 1 assert laguerre_poly(3, x, a) == -x**3/6 + (a/2 + Q(3)/2)*x**2 + (-a**2/2 - 5*a/2 - 3)*x + a**3/6 + a**2 + 11*a/6 + 1 assert laguerre_poly(1).dummy_eq(-x + 1) assert laguerre_poly(1, polys=True) == Poly(-x + 1)
def gauss_gen_laguerre(n, alpha, n_digits): r""" Computes the generalized Gauss-Laguerre quadrature [1]_ points and weights. The generalized Gauss-Laguerre quadrature approximates the integral: .. math:: \int_{0}^\infty x^{\alpha} e^{-x} f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i) The nodes `x_i` of an order `n` quadrature rule are the roots of `L^{\alpha}_n` and the weights `w_i` are given by: .. math:: w_i = \frac{\Gamma(\alpha+n)}{n \Gamma(n) L^{\alpha}_{n-1}(x_i) L^{\alpha+1}_{n-1}(x_i)} Parameters ========== n : the order of quadrature alpha : the exponent of the singularity, `\alpha > -1` n_digits : number of significant digits of the points and weights to return Returns ======= (x, w) : the ``x`` and ``w`` are lists of points and weights as Floats. The points `x_i` and weights `w_i` are returned as ``(x, w)`` tuple of lists. Examples ======== >>> from sympy import S >>> from sympy.integrals.quadrature import gauss_gen_laguerre >>> x, w = gauss_gen_laguerre(3, -S.Half, 5) >>> x [0.19016, 1.7845, 5.5253] >>> w [1.4493, 0.31413, 0.00906] >>> x, w = gauss_gen_laguerre(4, 3*S.Half, 5) >>> x [0.97851, 2.9904, 6.3193, 11.712] >>> w [0.53087, 0.67721, 0.11895, 0.0023152] See Also ======== gauss_legendre, gauss_laguerre, gauss_hermite, gauss_chebyshev_t, gauss_chebyshev_u, gauss_jacobi References ========== .. [1] http://en.wikipedia.org/wiki/Gauss%E2%80%93Laguerre_quadrature .. [2] http://people.sc.fsu.edu/~jburkardt/cpp_src/gen_laguerre_rule/gen_laguerre_rule.html """ x = Dummy("x") p = laguerre_poly(n, x, alpha=alpha, polys=True) p1 = laguerre_poly(n-1, x, alpha=alpha, polys=True) p2 = laguerre_poly(n-1, x, alpha=alpha+1, polys=True) xi = [] w = [] for r in p.real_roots(): if isinstance(r, RootOf): r = r.eval_rational(S(1)/10**(n_digits+2)) xi.append(r.n(n_digits)) w.append((gamma(alpha+n)/(n*gamma(n)*p1.subs(x, r)*p2.subs(x, r))).n(n_digits)) return xi, w
def gauss_laguerre(n, n_digits): r""" Computes the Gauss-Laguerre quadrature [1]_ points and weights. The Gauss-Laguerre quadrature approximates the integral: .. math:: \int_0^{\infty} e^{-x} f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i) The nodes `x_i` of an order `n` quadrature rule are the roots of `L_n` and the weights `w_i` are given by: .. math:: w_i = \frac{x_i}{(n+1)^2 \left(L_{n+1}(x_i)\right)^2} Parameters ========== n : the order of quadrature n_digits : number of significant digits of the points and weights to return Returns ======= (x, w) : the ``x`` and ``w`` are lists of points and weights as Floats. The points `x_i` and weights `w_i` are returned as ``(x, w)`` tuple of lists. Examples ======== >>> from sympy.integrals.quadrature import gauss_laguerre >>> x, w = gauss_laguerre(3, 5) >>> x [0.41577, 2.2943, 6.2899] >>> w [0.71109, 0.27852, 0.010389] >>> x, w = gauss_laguerre(6, 5) >>> x [0.22285, 1.1889, 2.9927, 5.7751, 9.8375, 15.983] >>> w [0.45896, 0.417, 0.11337, 0.010399, 0.00026102, 8.9855e-7] See Also ======== gauss_legendre, gauss_gen_laguerre, gauss_hermite, gauss_chebyshev_t, gauss_chebyshev_u, gauss_jacobi References ========== .. [1] http://en.wikipedia.org/wiki/Gauss%E2%80%93Laguerre_quadrature .. [2] http://people.sc.fsu.edu/~jburkardt/cpp_src/laguerre_rule/laguerre_rule.html """ x = Dummy("x") p = laguerre_poly(n, x, polys=True) p1 = laguerre_poly(n+1, x, polys=True) xi = [] w = [] for r in p.real_roots(): if isinstance(r, RootOf): r = r.eval_rational(S(1)/10**(n_digits+2)) xi.append(r.n(n_digits)) w.append((r/((n+1)**2 * p1.subs(x, r)**2)).n(n_digits)) return xi, w