{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Suppose we wish to evaluate the Jacobian of a function "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "f: \\mathbf{R}^m \\rightarrow \\mathbf{R}^n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". Assign to variables "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "m"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " the positive integer values of "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "m"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", respectively, and let "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "..."
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " represent an arbitrary tuple of integers. If we wish to evaluate the Jacobian at a single point, then:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "argument "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "x"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " must be an array of shape "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "(m,)"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "argument "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "f"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " must be vectorized to accept an array of shape "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "(m, ...)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ".   The first axis represents the "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "m"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " inputs of "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "f"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "; the remainder   are for evaluating the function at multiple points in a single call."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "argument "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "f"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " must return an array of shape "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "(n, ...)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". The first   axis represents the "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "n"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " outputs of "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "f"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "; the remainder   are for the result of evaluating the function at multiple points."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "attribute "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "df"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " of the result object will be an array of shape "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "(n, m)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ",   the Jacobian."
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This function is also vectorized in the sense that the Jacobian can be evaluated at "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "k"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " points in a single call. In this case, "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "x"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " would be an array of shape "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "(m, k)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "f"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " would accept an array of shape "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "(m, k, ...)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and return an array of shape "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "(n, k, ...)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "df"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " attribute of the result would have shape "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "(n, m, k)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Suppose the desired callable "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "f_not_vectorized"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is not vectorized; it can only accept an array of shape "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "(m,)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". A simple solution to satisfy the required interface is to wrap "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "f_not_vectorized"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " as follows      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "def f(x):\n    return np.apply_along_axis(f_not_vectorized, axis=0, arr=x)",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Alternatively, suppose the desired callable "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "f_vec_q"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is vectorized, but only for 2-D arrays of shape "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "(m, q)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". To satisfy the required interface, consider      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "def f(x):\n    m, batch = x.shape[0], x.shape[1:]  # x.shape is (m, ...)\n    x = np.reshape(x, (m, -1))  # `-1` is short for q = prod(batch)\n    res = f_vec_q(x)  # pass shape (m, q) to function\n    n = res.shape[0]\n    return np.reshape(res, (n,) + batch)  # return shape (n, ...)",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Then pass the wrapped callable "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "f"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " as the first argument of "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "jacobian",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.differentiate._differentiate:jacobian"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Strong",
              "__tag": 4048,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Array API Standard Support"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "jacobian",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.differentiate._differentiate:jacobian"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "SCIPY_ARRAY_API=1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "====================  ====================  ====================\nLibrary               CPU                   GPU\n====================  ====================  ====================\nNumPy                 ✅                     n/a                 \nCuPy                  n/a                   ✅                   \nPyTorch               ✅                     ✅                   \nJAX                   ⚠️ no JIT             ⚠️ no JIT           \nDask                  ⛔                     n/a                 \n====================  ====================  ====================",
          "execution_status": null
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "See "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "dev-arrayapi",
                  "domain": null,
                  "role": "ref",
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " for more information."
                }
              ]
            }
          ]
        }
      ],
      "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": "res",
              "annotation": "_RichResult",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "An object similar to an instance of "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "scipy.optimize.OptimizeResult",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "scipy",
                        "version": "*",
                        "kind": "api",
                        "path": "scipy.optimize._optimize:OptimizeResult"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " with the following attributes. The descriptions are written as though the values will be scalars; however, if "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "f"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " returns an array, the outputs will be arrays of the same shape."
                    }
                  ]
                },
                {
                  "__type": "DefList",
                  "__tag": 4033,
                  "children": [
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "success"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "success"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "status"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "status"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "df"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "df"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "error"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "error"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "nit"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "nit"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "nfev"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "nfev"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Each element of an attribute is associated with the corresponding element of "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "df",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". For instance, element "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "i"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " of "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "nfev",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is the number of points at which "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "f"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " was evaluated for the sake of computing element "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "i"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " of "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "df",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Evaluate the Jacobian of a function numerically."
            }
          ]
        }
      ],
      "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": "f",
              "annotation": "callable",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The function whose Jacobian is desired. The signature must be      "
                    }
                  ]
                },
                {
                  "__type": "Code",
                  "__tag": 4050,
                  "value": "f(xi: ndarray) -> ndarray",
                  "execution_status": null
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "where each element of "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "xi"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is a finite real. If the function to be differentiated accepts additional arguments, wrap it (e.g. using "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "functools.partial",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "functools",
                        "version": "*",
                        "kind": "api",
                        "path": "functools:partial"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " or "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "lambda"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ") and pass the wrapped callable into "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "jacobian",
                      "reference": {
                        "__type": "LocalRef",
                        "__tag": 4022,
                        "kind": "module",
                        "path": "scipy.differentiate._differentiate:jacobian"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "f"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " must not mutate the array "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "xi"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". See Notes regarding vectorization and the dimensionality of the input and output."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "x",
              "annotation": "float array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Points at which to evaluate the Jacobian. Must have at least one dimension. See Notes regarding the dimensionality and vectorization."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "tolerances",
              "annotation": "dictionary of floats, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Absolute and relative tolerances. Valid keys of the dictionary are:"
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "atol"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " - absolute tolerance on the derivative"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "rtol"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " - relative tolerance on the derivative"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Iteration will stop when "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "res.error < atol + rtol * abs(res.df)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". The default "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "atol",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is the smallest normal number of the appropriate dtype, and the default "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "rtol",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is the square root of the precision of the appropriate dtype."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "maxiter",
              "annotation": "int, default: 10",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The maximum number of iterations of the algorithm to perform. See Notes."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "order",
              "annotation": "int, default: 8",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The (positive integer) order of the finite difference formula to be used. Odd integers will be rounded up to the next even integer."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "initial_step",
              "annotation": "float array_like, default: 0.5",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The (absolute) initial step size for the finite difference derivative approximation. Must be broadcastable with "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "x"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "step_direction"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "step_factor",
              "annotation": "float, default: 2.0",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The factor by which the step size is "
                    },
                    {
                      "__type": "Emphasis",
                      "__tag": 4047,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "reduced"
                        }
                      ]
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " in each iteration; i.e. the step size in iteration 1 is "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "initial_step/step_factor"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". If "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "step_factor < 1"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", subsequent steps will be greater than the initial step; this may be useful if steps smaller than some threshold are undesirable (e.g. due to subtractive cancellation error)."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "step_direction",
              "annotation": "integer array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "An array representing the direction of the finite difference steps (e.g. for use when "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "x"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " lies near to the boundary of the domain of the function.) Must be broadcastable with "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "x"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "initial_step"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". Where 0 (default), central differences are used; where negative (e.g. -1), steps are non-positive; and where positive (e.g. 1), all steps are non-negative."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "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/differentiate/_differentiate.py",
  "item_line": 719,
  "item_type": "function",
  "aliases": [
    "scipy.differentiate.jacobian"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "The Rosenbrock function maps from :math:`\\mathbf{R}^m \\rightarrow \\mathbf{R}`;\nthe SciPy implementation `scipy.optimize.rosen` is vectorized to accept an\narray of shape ``(m, p)`` and return an array of shape ``p``. Suppose we wish\nto evaluate the Jacobian (AKA the gradient because the function returns a scalar)\nat ``[0.5, 0.5, 0.5]``.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy.differentiate import jacobian\nfrom scipy.optimize import rosen, rosen_der\nm = 3\nx = np.full(m, 0.5)\nres = jacobian(rosen, x)\nref = rosen_der(x)  # reference value of the gradient\nres.df, ref\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nAs an example of a function with multiple outputs, consider Example 4\nfrom [1]_.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "def f(x):\n    x1, x2, x3 = x\n    return [x1, 5*x3, 4*x2**2 - 2*x3, x3*np.sin(x1)]\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe true Jacobian is given by:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "def df(x):\n        x1, x2, x3 = x\n        one = np.ones_like(x1)\n        return [[one, 0*one, 0*one],\n                [0*one, 0*one, 5*one],\n                [0*one, 8*x2, -2*one],\n                [x3*np.cos(x1), 0*one, np.sin(x1)]]\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nEvaluate the Jacobian at an arbitrary point.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "rng = np.random.default_rng(389252938452)\nx = rng.random(size=3)\nres = jacobian(f, x)\nref = df(x)\nres.df.shape == (4, 3)\nnp.allclose(res.df, ref)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nEvaluate the Jacobian at 10 arbitrary points in a single call.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "x = rng.random(size=(3, 10))\nres = jacobian(f, x)\nref = df(x)\nres.df.shape == (4, 3, 10)\nnp.allclose(res.df, ref)\n",
        "execution_status": "success"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "derivative",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "derivative"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "hessian",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.differentiate._differentiate:hessian"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": "func"
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "f",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "x",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "tolerances",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "maxiter",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "10"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "order",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "8"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "initial_step",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "0.5"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "step_factor",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "2.0"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "step_direction",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "0"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "jacobian"
  },
  "references": [
    ".. [1] Jacobian matrix and determinant, *Wikipedia*,",
    "       https://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant"
  ],
  "qa": "scipy.differentiate._differentiate:jacobian",
  "arbitrary": [],
  "local_refs": [
    "f",
    "initial_step",
    "maxiter",
    "order",
    "res",
    "step_direction",
    "step_factor",
    "tolerances",
    "x"
  ]
}