{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "x",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Sample points"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "w",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Weights"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "mu",
              "annotation": "float",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Sum of the weights"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Gauss-generalized Laguerre quadrature."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "n",
              "annotation": "int",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "quadrature order"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "alpha",
              "annotation": "float",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "alpha must be > -1"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "mu",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If True, return the sum of the weights, optional."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Compute the sample points and weights for Gauss-generalized Laguerre quadrature. The sample points are the roots of the nth degree generalized Laguerre polynomial, "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "L^{\\alpha}_n(x)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". These sample points and weights correctly integrate polynomials of degree "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "2n - 1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " or less over the interval "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "[0, \\infty]"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " with weight function "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "w(x) = x^{\\alpha} e^{-x}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". See 22.3.9 in "
            },
            {
              "__type": "CitationReference",
              "__tag": 4063,
              "label": "AS"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for details."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "build-install/usr/lib/python3.14/site-packages/scipy/special/_orthogonal.py",
  "item_line": 680,
  "item_type": "function",
  "aliases": [
    "scipy.special.la_roots"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.special import roots_genlaguerre\nroots, weights = roots_genlaguerre(5, 1.5)\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "roots\nweights\n",
        "execution_status": "failure",
        "out": "array([0.396, 0.695, 0.223, 0.015, 0.   ])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nVerify that the values in `roots` are roots of the generalized Laguerre\npolynomial :math:`L^{1.5}_5(x)`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.special import eval_genlaguerre\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "eval_genlaguerre(5, 1.5, roots)\n",
        "execution_status": "failure",
        "out": "array([-0., -0.,  0., -0.,  0.])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe values of :math:`L^{1.5}_5(x)` evaluated at the roots are indeed rather\nclose to zero. The increasing values for larger roots can be explained by the\nincreasing derivative of the generalized Laguerre polynomial at the roots.\n\nVerify that the sum of the weights equals the integral from 0 to :math:`\\infty`\nof :math:`x^\\alpha\\exp(-x)` which for :math:`\\alpha=1.5` evaluates to\n:math:`3\\sqrt{\\pi}/4`.  There are two ways to obtain the sum of weights, both\nyielding the expected result within numerical precision.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "sum(weights)\nroots, weights, sum_of_weights = roots_genlaguerre(5, 1.5, mu=True)\nsum_of_weights\nfrom math import pi, sqrt\n0.75*sqrt(pi)\n",
        "execution_status": "success",
        "out": "1.329340388179137\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nRoots and weights obtained from the generalized Laguerre polynomial\n:math:`L^\\alpha_n(x)` are used in Gauss-Laguerre quadrature where the integral\nfrom 0 to :math:`\\infty` of :math:`f(x)x^\\alpha\\exp(-x)` is evaluated. Roots\nand weights for order :math:`n` are expected to yield the exact result for\npolynomials :math:`f(x)` of a maximal order of :math:`2n-1`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "f = lambda x: x**4\nweights @ f(roots)\n",
        "execution_status": "success",
        "out": "np.float64(287.88527781504445)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThis result agrees with the exact value of :math:`10395\\sqrt{\\pi}/64` within\nnumerical precision.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "(10395/64)*sqrt(pi)\n",
        "execution_status": "success",
        "out": "287.88527781504433\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nIn general, Gauss-Laguerre quadrature will only yield an approximate\nvalue of the integral. Consider the integral from 0 to :math:`\\infty`\nof :math:`\\cos(x)x^{1.5}\\exp(-x)`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "weights @ np.cos(roots)\n",
        "execution_status": "failure",
        "out": "np.float64(-0.2005673177859365)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nBecause of the small number of nodes, this result is rather imprecise.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.integrate import quad\nimport numpy as np\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "quad(lambda x: np.cos(x) * x**1.5 * np.exp(-x), 0, np.inf)\n",
        "execution_status": "failure",
        "out": "(-0.2138889584997946, 1.4800383740780929e-08)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nHere, the first number refers to the result while the second one gives an estimate\nof the absolute error. A better result can be obtained by means of Gauss-Laguerre\nquadrature by choosing a larger number of nodes.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "roots, weights = roots_genlaguerre(50, 1.5)\nweights @ np.cos(roots)\n",
        "execution_status": "success",
        "out": "np.float64(-0.21388895849684425)\n"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "scipy.integrate.fixed_quad",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.integrate._quadrature:fixed_quad"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": null
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "n",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "alpha",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "mu",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "roots_genlaguerre"
  },
  "references": [
    ".. [AS] Milton Abramowitz and Irene A. Stegun, eds.",
    "    Handbook of Mathematical Functions with Formulas,",
    "    Graphs, and Mathematical Tables. New York: Dover, 1972."
  ],
  "qa": "scipy.special._orthogonal:roots_genlaguerre",
  "arbitrary": [],
  "local_refs": [
    "alpha",
    "mu",
    "n",
    "w",
    "x"
  ]
}