{
  "__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-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": "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-Laguerre quadrature. The sample points are the roots of the nth degree Laguerre polynomial, "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "L_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) = e^{-x}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". See 22.2.13 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": 925,
  "item_type": "function",
  "aliases": [
    "scipy.special.l_roots"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.special import roots_laguerre\nroots, weights = roots_laguerre(5)\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "roots\nweights\n",
        "execution_status": "failure",
        "out": "array([0.522, 0.399, 0.076, 0.004, 0.   ])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nVerify that the values in `roots` are roots of the Laguerre polynomial\n:math:`L_5(x)`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.special import eval_laguerre\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "eval_laguerre(5, roots)\n",
        "execution_status": "failure",
        "out": "array([-0., -0.,  0., -0., -0.])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe values of :math:`L_5(x)` evaluated at the roots are indeed rather close\nto zero. The increasing values for larger roots can be explained by the\nincreasing derivative of the Laguerre polynomial at the roots.\n\nVerify that the sum of the weights equals the integral from 0 to :math:`\\infty`\nof :math:`\\exp(-x)` which evaluates to 1. There are two ways to obtain the\nsum of weights, both resulting in 1 within numerical precision.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "sum(weights)\nroots, weights, sum_of_weights = roots_laguerre(5, mu=True)\nsum_of_weights\n",
        "execution_status": "success",
        "out": "np.float64(1.0)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nRoots and weights obtained from the Laguerre polynomial :math:`L_n(x)`\nare used in Gauss-Laguerre quadrature where the integral from 0 to\n:math:`\\infty` of :math:`f(x)\\exp(-x)` is evaluated. Roots and weights\nfor order :math:`n` are expected to yield the exact result for polynomials\n: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(24.000000000000014)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThis result is indeed very close to the exact value of 24.\n\nIn general, Gauss-Laguerre quadrature will only yield an approximate value of the\nintegral. Consider the integral from 0 to :math:`\\infty` of :math:`\\cos(x)\\exp(-x)`\nwhich evaluates to 1/2.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nweights @ np.cos(roots)\n",
        "execution_status": "success",
        "out": "np.float64(0.5005384852176379)\n"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "numpy.polynomial.laguerre.laggauss",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "numpy.polynomial.laguerre.laggauss"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": null
    },
    {
      "__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": "mu",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "roots_laguerre"
  },
  "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_laguerre",
  "arbitrary": [],
  "local_refs": [
    "mu",
    "n",
    "w",
    "x"
  ]
}