{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The function gradient is determined by the forward finite difference formula               "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "         f(xk[i] + epsilon[i]) - f(xk[i])\nf'[i] = ---------------------------------\n                    epsilon[i]",
          "execution_status": null
        }
      ],
      "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": "jac",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The partial derivatives of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "f"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "xk"
                    },
                    {
                      "__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": "Finite difference approximation of the derivatives of a scalar or vector-valued function."
            }
          ]
        }
      ],
      "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": "xk",
              "annotation": "array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The coordinate vector at which to determine the gradient of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "f"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "f",
              "annotation": "callable",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Function of which to estimate the derivatives of. Has the signature "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "f(xk, *args)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " where "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "xk"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is the argument in the form of a 1-D array and "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "args"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is a tuple of any additional fixed parameters needed to completely specify the function. The argument "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "xk"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " passed to this function is an ndarray of shape (n,) (never a scalar even if n=1). It must return a 1-D array_like of shape (m,) or a scalar."
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Suppose the callable has signature "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "f0(x, *my_args, **my_kwargs)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", where "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "my_args"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "my_kwargs"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " are required positional and keyword arguments. Rather than passing "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "f0"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " as the callable, wrap it to accept only "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "x"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "; e.g., pass "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "fun=lambda x: f0(x, *my_args, **my_kwargs)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " as the callable, where "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "my_args"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " (tuple) and "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "my_kwargs"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " (dict) have been gathered before invoking this function."
                    }
                  ]
                },
                {
                  "__type": "Admonition",
                  "__tag": 4056,
                  "kind": "versionchanged",
                  "base_type": "neutral",
                  "children": [
                    {
                      "__type": "AdmonitionTitle",
                      "__tag": 4055,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "versionchanged 1.9.0"
                        }
                      ]
                    },
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "ParamRef",
                          "__tag": 4071,
                          "name": "f"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " is now able to return a 1-D array-like, with the "
                        },
                        {
                          "__type": "InlineMath",
                          "__tag": 4057,
                          "value": "(m, n)"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " Jacobian being estimated."
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "epsilon",
              "annotation": "{float, array_like}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Increment to "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "xk"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to use for determining the function gradient. If a scalar, uses the same finite difference delta for all partial derivatives. If an array, should contain one value per element of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "xk"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". Defaults to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "sqrt(np.finfo(float).eps)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", which is approximately 1.49e-08."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "\\*args",
              "annotation": "args, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Any other arguments that are to be passed to "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "f"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If a function maps from "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "R^n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "R^m"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", its derivatives form an m-by-n matrix called the Jacobian, where an element "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "(i, j)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is a partial derivative of f[i] with respect to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "xk[j]"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "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/optimize/_optimize.py",
  "item_line": 970,
  "item_type": "function",
  "aliases": [
    "scipy.optimize.approx_fprime"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy import optimize\ndef func(x, c0, c1):\n    \"Coordinate vector `x` should be an array of size two.\"\n    return c0 * x[0]**2 + c1*x[1]**2\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "x = np.ones(2)\nc0, c1 = (1, 200)\neps = np.sqrt(np.finfo(float).eps)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "optimize.approx_fprime(x, func, [eps, np.sqrt(200) * eps], c0, c1)\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "check_grad",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.optimize._optimize:check_grad"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Check correctness of gradient function against approx_fprime."
            }
          ]
        }
      ],
      "type": null
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "xk",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__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": "epsilon",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "1.4901161193847656e-08"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "args",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "VAR_POSITIONAL",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "approx_fprime"
  },
  "references": null,
  "qa": "scipy.optimize._optimize:approx_fprime",
  "arbitrary": [],
  "local_refs": [
    "\\*args",
    "epsilon",
    "f",
    "jac",
    "xk"
  ]
}