{
  "__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": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Gauss-Kronrod 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": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "lower",
              "annotation": "Rule",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Lower-order rule."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "npoints",
              "annotation": "int",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Number of nodes for the higher-order rule."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "xp",
              "annotation": "array_namespace, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The namespace for the node and weight arrays. Default is None, where NumPy is used."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Gauss-Kronrod rules consist of two quadrature rules, one higher-order and one lower-order. The higher-order rule is used as the estimate of the integral and the difference between them is used as an estimate for the error."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Gauss-Kronrod is a 1D rule. To use it for multidimensional integrals, it will be necessary to use ProductNestedFixed and multiple Gauss-Kronrod rules. See Examples."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For n-node Gauss-Kronrod, the lower-order rule has "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "n//2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " nodes, which are the ordinary Gauss-Legendre nodes with corresponding weights. The higher-order rule has "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " nodes, "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "n//2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of which are the same as the lower-order rule and the remaining nodes are the Kronrod extension of those nodes."
            }
          ]
        }
      ],
      "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": "/scipy/integrate/_rules/_gauss_kronrod.py",
  "item_line": 9,
  "item_type": "class",
  "aliases": [
    "scipy.integrate._cubature.GaussKronrodQuadrature"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "Evaluate a 1D integral. Note in this example that ``f`` returns an array, so the\nestimates will also be arrays, despite the fact that this is a 1D problem.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy.integrate import cubature\nfrom scipy.integrate._rules import GaussKronrodQuadrature\ndef f(x):\n    return np.cos(x)\nrule = GaussKronrodQuadrature(21) # Use 21-point GaussKronrod\na, b = np.array([0]), np.array([1])\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "rule.estimate(f, a, b) # True value sin(1), approximately 0.84147\nrule.estimate_error(f, a, b)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nEvaluate a 2D integral. Note that in this example ``f`` returns a float, so the\nestimates will also be floats.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy.integrate import cubature\nfrom scipy.integrate._rules import (\n    ProductNestedFixed, GaussKronrodQuadrature\n)\ndef f(x):\n    # f(x) = cos(x_1) + cos(x_2)\n    return np.sum(np.cos(x), axis=-1)\nrule = ProductNestedFixed(\n    [GaussKronrodQuadrature(15), GaussKronrodQuadrature(15)]\n) # Use 15-point Gauss-Kronrod\na, b = np.array([0, 0]), np.array([1, 1])\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "rule.estimate(f, a, b) # True value 2*sin(1), approximately 1.6829\nrule.estimate_error(f, a, b)\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "npoints",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "xp",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "GaussKronrodQuadrature"
  },
  "references": [
    ".. [1] R. Piessens, E. de Doncker, Quadpack: A Subroutine Package for Automatic",
    "    Integration, files: dqk21.f, dqk15.f (1983)."
  ],
  "qa": "scipy.integrate._rules._gauss_kronrod:GaussKronrodQuadrature",
  "arbitrary": [],
  "local_refs": [
    "lower",
    "npoints",
    "xp"
  ]
}