{
  "__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-Jacobi (shifted) 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": "p1",
              "annotation": "float",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "(p1 - q1) must be > -1."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "q1",
              "annotation": "float",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "q1 must be > 0."
                    }
                  ]
                }
              ]
            },
            {
              "__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-Jacobi (shifted) quadrature. The sample points are the roots of the n-th degree shifted Jacobi polynomial"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "G_n^{(p, q)}(x)\n  = \\frac{n!\\Gamma(n+p)}{\\Gamma(2n+p)} P_n^{(p - q, q - 1)}(2x - 1)."
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__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, 1]"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " with weight function "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "w(x) = (1 - x)^{p-q} x^{q-1}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". See 22.2.2 in "
            },
            {
              "__type": "CitationReference",
              "__tag": 4063,
              "label": "AS"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for details. Note that here, in contrast to "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "roots_sh_legendre",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.special._orthogonal:roots_sh_legendre"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "roots_sh_chebyt",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.special._orthogonal:roots_sh_chebyt"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "roots_sh_chebyu",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.special._orthogonal:roots_sh_chebyu"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", more than just the argument is shifted."
            }
          ]
        }
      ],
      "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": 444,
  "item_type": "function",
  "aliases": [
    "scipy.special.js_roots"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "The roots and weights obtained from the shifted Chebyshev polynomials of\nthe first and second kind are special cases of those obtained from the\nshifted Jacobi polynomials for :math:`p=0, q=1/2` and :math:`p=2, q=3/2`,\nrespectively.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.special import roots_sh_chebyt, roots_sh_chebyu, roots_sh_jacobi\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "roots_sh_jacobi(5, 0, 0.5)  # doctest: +NORMALIZE_WHITESPACE\nroots_sh_chebyt(5)  # doctest: +NORMALIZE_WHITESPACE\nroots_sh_jacobi(5, 2, 1.5)  # doctest: +NORMALIZE_WHITESPACE\nroots_sh_chebyu(5)  # doctest: +NORMALIZE_WHITESPACE\n",
        "execution_status": "failure",
        "out": "(array([0.067, 0.25 , 0.5  , 0.75 , 0.933]), array([0.033, 0.098, 0.131, 0.098, 0.033]))\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nConsider the specific case :math:`p=2, q=0.5`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "p, q = 2, 0.5\nroots, weights, sum_of_weights = roots_sh_jacobi(5, p, q, mu=True)\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nVerify that the values in `roots` are roots of the shifted Jacobi\npolynomial :math:`G^{1.5, -0.5}_5(x)`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.special import eval_sh_jacobi\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "eval_sh_jacobi(5, p, q, roots)\n",
        "execution_status": "failure",
        "out": "array([-0., -0., -0., -0., -0.])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nAll values are indeed very close to zero.\n\nThe sum of the weights is given by the integral from 0 to 1 of\n:math:`(1-x)^{p-q}x^{q-1}` which evalutes to\n:math:`\\Gamma(q)\\Gamma(p-q+1)/\\Gamma(p+1)`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "sum_of_weights\nfrom math import gamma, pi\ngamma(q) * gamma(p-q+1) / gamma(p+1)\n",
        "execution_status": "success",
        "out": "1.1780972450961726\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nRoots and weights obtained from the shifted Jacobi polynomial\n:math:`G^{p, q}_n(x)` are used in Gauss-Jacobi quadrature where\nthe integral from 0 to 1 of :math:`f(x)(1-x)^{p-q}x^{q-1}` is evaluated.\nRoots and weights for order :math:`n` are expected to yield the exact\nresult for polynomials :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(0.02147573103039911)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe exact result is :math:`7\\pi/1024`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "7*pi/1024\n",
        "execution_status": "success",
        "out": "0.021475731030398976\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nIn general, Gauss-Chebyshev quadrature will only yield an approximate value of the\nintegral. Consider the integral from 0 to 1 of :math:`\\cos(x)(1-x)^{p-q}x^{q-1}`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nweights @ np.cos(roots)\nfrom scipy.integrate import quad\nquad(lambda x: np.cos(x) * (1-x)**(p-q) * x**(q-1), 0, 1)\n",
        "execution_status": "success",
        "out": "(1.1421634722898315, 6.314033740295599e-10)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe two result agree better than indicated by the estimated absolute error given\nby the second value in the last output."
      }
    ],
    "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": "p1",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "q1",
        "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_sh_jacobi"
  },
  "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_sh_jacobi",
  "arbitrary": [],
  "local_refs": [
    "mu",
    "n",
    "p1",
    "q1",
    "w",
    "x"
  ]
}