K iBddlmZmZmZddlmZddlmZmZddl m Z ddl m Z ddl mZmZmZmZddlmZdZd Zd Zd Zd Zd ZdZdZy))SDummypi) factorial)sincos)sqrt)gamma) legendre_poly laguerre_poly hermite_poly jacobi_poly)RootOfc td}t||d}|j|}g}g}|jD]}t |t r(|j tjd|dzzz }|j|j||jdd|dzz |j||dzzz j|||fS)a Computes the Gauss-Legendre quadrature [1]_ points and weights. Explanation =========== The Gauss-Legendre quadrature approximates the integral: .. math:: \int_{-1}^1 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 `P_n` and the weights `w_i` are given by: .. math:: w_i = \frac{2}{\left(1-x_i^2\right) \left(P'_n(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_legendre >>> x, w = gauss_legendre(3, 5) >>> x [-0.7746, 0, 0.7746] >>> w [0.55556, 0.88889, 0.55556] >>> x, w = gauss_legendre(4, 5) >>> x [-0.86114, -0.33998, 0.33998, 0.86114] >>> w [0.34785, 0.65215, 0.65215, 0.34785] See Also ======== gauss_laguerre, gauss_gen_laguerre, gauss_hermite, gauss_chebyshev_t, gauss_chebyshev_u, gauss_jacobi, gauss_lobatto References ========== .. [1] https://en.wikipedia.org/wiki/Gaussian_quadrature .. [2] https://people.sc.fsu.edu/~jburkardt/cpp_src/legendre_rule/legendre_rule.html xTpolys ) rr diff real_roots isinstancer eval_rationalrOneappendnsubsrn_digitsrppdxiwrs `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/integrals/quadrature.pygauss_legendrer' sv c Aa$'A B B A \\^@ a b8A:&6 67A !##h-  !a1f1 q 00144X>? @ q5Lc td}t||d}t|dz|d}g}g}|jD]}t|tr(|j t jd|dzzz }|j|j||j||dzdz|j||dzzz j|||fS)a Computes the Gauss-Laguerre quadrature [1]_ points and weights. Explanation =========== 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] https://people.sc.fsu.edu/~jburkardt/cpp_src/laguerre_rule/laguerre_rule.html rTrrrr) rr rrrrrrrrrrr rr!p1r#r$r%s r&gauss_laguerrer,Ssx c Aa$'A qsAT *B B A \\^@ a b8A:&6 67A !##h-  !acAX1 q 00144X>? @ q5Lr(c td}t||d}t|dz |d}g}g}|jD]}t|tr(|j t jd|dzzz }|j|j||jd|dz zt|zttz|dz|j||dzzz j|||fS)au Computes the Gauss-Hermite quadrature [1]_ points and weights. Explanation =========== The Gauss-Hermite quadrature approximates the integral: .. math:: \int_{-\infty}^{\infty} e^{-x^2} 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 `H_n` and the weights `w_i` are given by: .. math:: w_i = \frac{2^{n-1} n! \sqrt{\pi}}{n^2 \left(H_{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_hermite >>> x, w = gauss_hermite(3, 5) >>> x [-1.2247, 0, 1.2247] >>> w [0.29541, 1.1816, 0.29541] >>> x, w = gauss_hermite(6, 5) >>> x [-2.3506, -1.3358, -0.43608, 0.43608, 1.3358, 2.3506] >>> w [0.00453, 0.15707, 0.72463, 0.72463, 0.15707, 0.00453] See Also ======== gauss_legendre, gauss_laguerre, gauss_gen_laguerre, gauss_chebyshev_t, gauss_chebyshev_u, gauss_jacobi, gauss_lobatto References ========== .. [1] https://en.wikipedia.org/wiki/Gauss-Hermite_Quadrature .. [2] https://people.sc.fsu.edu/~jburkardt/cpp_src/hermite_rule/hermite_rule.html .. [3] https://people.sc.fsu.edu/~jburkardt/cpp_src/gen_hermite_rule/gen_hermite_rule.html rTrrrr)rr rrrrrrrrrr rrr*s r& gauss_hermiter.s| c AQ&A ac1D )B B A \\^9 a b8A:&6 67A !##h-  1qs8il*T"X5Q$A))+,-AhK 9 9 q5Lr(c 0td}t|||d}t|dz ||d}t|dz ||dzd}g}g}|jD]} t| tr(| j t jd|dzzz } |j| j||jt||z|t|z|j|| z|j|| zz j|||fS)a Computes the generalized Gauss-Laguerre quadrature [1]_ points and weights. Explanation =========== 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] https://people.sc.fsu.edu/~jburkardt/cpp_src/gen_laguerre_rule/gen_laguerre_rule.html rT)alpharrrr) rr rrrrrrrrr r) rr0r rr!r+p2r#r$r%s r&gauss_gen_laguerrer2sF c Aa%t4A qsAU$ 7B qsAU1WD 9B B A \\^H a b8A:&6 67A !##h-  %a.E!H*RWWQ]*2771a=8:;<1X; H H q5Lr(cDg}g}td|dzD]}|jtd|ztjz d|zz tj zj ||jtj |z j |||fS)a- Computes the Gauss-Chebyshev quadrature [1]_ points and weights of the first kind. Explanation =========== The Gauss-Chebyshev quadrature of the first kind approximates the integral: .. math:: \int_{-1}^{1} \frac{1}{\sqrt{1-x^2}} 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 `T_n` and the weights `w_i` are given by: .. math:: w_i = \frac{\pi}{n} 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_chebyshev_t >>> x, w = gauss_chebyshev_t(3, 5) >>> x [0.86602, 0, -0.86602] >>> w [1.0472, 1.0472, 1.0472] >>> x, w = gauss_chebyshev_t(6, 5) >>> x [0.96593, 0.70711, 0.25882, -0.25882, -0.70711, -0.96593] >>> w [0.5236, 0.5236, 0.5236, 0.5236, 0.5236, 0.5236] See Also ======== gauss_legendre, gauss_laguerre, gauss_hermite, gauss_gen_laguerre, gauss_chebyshev_u, gauss_jacobi, gauss_lobatto References ========== .. [1] https://en.wikipedia.org/wiki/Chebyshev%E2%80%93Gauss_quadrature .. [2] https://people.sc.fsu.edu/~jburkardt/cpp_src/chebyshev1_rule/chebyshev1_rule.html rr)rangerrrrPirrr r#r$is r&gauss_chebyshev_tr8:s~ B A 1ac]' 3!AEE AaC(-.11(;< !$$q&H%&' q5Lr(c g}g}td|dzD]}|jt||tjzz tj zj ||jtj |tjzz t|tj z|tjzz dzzj |||fS)a: Computes the Gauss-Chebyshev quadrature [1]_ points and weights of the second kind. Explanation =========== The Gauss-Chebyshev quadrature of the second kind approximates the integral: .. math:: \int_{-1}^{1} \sqrt{1-x^2} 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 `U_n` and the weights `w_i` are given by: .. math:: w_i = \frac{\pi}{n+1} \sin^2 \left(\frac{i}{n+1}\pi\right) 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_chebyshev_u >>> x, w = gauss_chebyshev_u(3, 5) >>> x [0.70711, 0, -0.70711] >>> w [0.3927, 0.7854, 0.3927] >>> x, w = gauss_chebyshev_u(6, 5) >>> x [0.90097, 0.62349, 0.22252, -0.22252, -0.62349, -0.90097] >>> w [0.084489, 0.27433, 0.42658, 0.42658, 0.27433, 0.084489] See Also ======== gauss_legendre, gauss_laguerre, gauss_hermite, gauss_gen_laguerre, gauss_chebyshev_t, gauss_jacobi, gauss_lobatto References ========== .. [1] https://en.wikipedia.org/wiki/Chebyshev%E2%80%93Gauss_quadrature .. [2] https://people.sc.fsu.edu/~jburkardt/cpp_src/chebyshev2_rule/chebyshev2_rule.html rr)r4rrrrr5rrr6s r&gauss_chebyshev_ur:sz B A 1ac]H 3q!AEE'{144'(++H56 !$$!%%.QqttVQquuW%5!6!99< -1` beta : the second parameter of the Jacobi Polynomial, `\beta > -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_jacobi >>> x, w = gauss_jacobi(3, S.Half, -S.Half, 5) >>> x [-0.90097, -0.22252, 0.62349] >>> w [1.7063, 1.0973, 0.33795] >>> x, w = gauss_jacobi(6, 1, 1, 5) >>> x [-0.87174, -0.5917, -0.2093, 0.2093, 0.5917, 0.87174] >>> w [0.050584, 0.22169, 0.39439, 0.39439, 0.22169, 0.050584] See Also ======== gauss_legendre, gauss_laguerre, gauss_hermite, gauss_gen_laguerre, gauss_chebyshev_t, gauss_chebyshev_u, gauss_lobatto References ========== .. [1] https://en.wikipedia.org/wiki/Gauss%E2%80%93Jacobi_quadrature .. [2] https://people.sc.fsu.edu/~jburkardt/cpp_src/jacobi_rule/jacobi_rule.html .. [3] https://people.sc.fsu.edu/~jburkardt/cpp_src/gegenbauer_rule/gegenbauer_rule.html rTrrrr) rrrrrrrrrrrr r) rr0betar rr!r"pnr#r$r%s r& gauss_jacobir>szN c AAudAT2A B QqS%q 5B B A \\^L a b8A:&6 67A !##h-  s5y~a AeGDL$6 7 1U719 eAdF1Ho - / 1U74<% &uQqSz 1 3 d O  "wwq!}rwwq!}< >@Aq{  L L q5Lr(c td}t|dz |d}|j|}g}g}|jD]}t |t r(|j tjd|dzzz }|j|j||jd||dz z|j||dzzz j||jdd|jd|jdtd||dz zz j||jtd||dz zz j|||fS) a  Computes the Gauss-Lobatto quadrature [1]_ points and weights. Explanation =========== The Gauss-Lobatto quadrature approximates the integral: .. math:: \int_{-1}^1 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 `P'_(n-1)` and the weights `w_i` are given by: .. math:: &w_i = \frac{2}{n(n-1) \left[P_{n-1}(x_i)\right]^2},\quad x\neq\pm 1\\ &w_i = \frac{2}{n(n-1)},\quad x=\pm 1 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_lobatto >>> x, w = gauss_lobatto(3, 5) >>> x [-1, 0, 1] >>> w [0.33333, 1.3333, 0.33333] >>> x, w = gauss_lobatto(4, 5) >>> x [-1, -0.44721, 0.44721, 1] >>> w [0.16667, 0.83333, 0.83333, 0.16667] See Also ======== gauss_legendre,gauss_laguerre, gauss_gen_laguerre, gauss_hermite, gauss_chebyshev_t, gauss_chebyshev_u, gauss_jacobi References ========== .. [1] https://en.wikipedia.org/wiki/Gaussian_quadrature#Gauss.E2.80.93Lobatto_rules .. [2] https://web.archive.org/web/20200118141346/http://people.math.sfu.ca/~cbm/aands/page_888.htm rrTrrrr) rr rrrrrrrrrrinsertrs r& gauss_lobattorBs5v c Aac1D)A B B A ]]_> a b8A:&6 67A !##h-  !Q!Wqvva|Q./228<= > IIaIIaLHHQ1q!A#w""8,-HHadAqsGn   )* q5Lr(N) sympy.corerrr(sympy.functions.combinatorial.factorialsr(sympy.functions.elementary.trigonometricrr(sympy.functions.elementary.miscellaneousr 'sympy.functions.special.gamma_functionsr sympy.polys.orthopolysr r r rsympy.polys.rootoftoolsrr'r,r.r2r8r:r>rBr(r&rKs[##>=99??*EPFRIXOdDNBJVrJr(