{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This function implements a 4th order collocation algorithm with the control of residuals similar to "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". A collocation system is solved by a damped Newton method with an affine-invariant criterion function as described in "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "3"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Note that in "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "  integral residuals are defined without normalization by interval lengths. So, their definition is different by a multiplier of h**0.5 (h is an interval length) from the definition used here."
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "versionadded",
          "base_type": "neutral",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "versionadded 0.18.0"
                }
              ]
            }
          ]
        },
        {
          "__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": "solve_bvp",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.integrate._bvp:solve_bvp"
              },
              "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                   ⛔                     ⛔                   \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": "",
              "annotation": "Bunch object with the following fields defined:",
              "desc": []
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "sol",
              "annotation": "PPoly",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Found solution for y as "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "scipy.interpolate.PPoly",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "scipy",
                        "version": "*",
                        "kind": "api",
                        "path": "scipy.interpolate._interpolate:PPoly"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " instance, a C1 continuous cubic spline."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "p",
              "annotation": "ndarray or None, shape (k,)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Found parameters. None, if the parameters were not present in the problem."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "x",
              "annotation": "ndarray, shape (m,)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Nodes of the final mesh."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "y",
              "annotation": "ndarray, shape (n, m)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Solution values at the mesh nodes."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "yp",
              "annotation": "ndarray, shape (n, m)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Solution derivatives at the mesh nodes."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "rms_residuals",
              "annotation": "ndarray, shape (m - 1,)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "RMS values of the relative residuals over each mesh interval (see the description of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "tol"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " parameter)."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "niter",
              "annotation": "int",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Number of completed iterations."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "status",
              "annotation": "int",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Reason for algorithm termination:"
                    }
                  ]
                },
                {
                  "__type": "Blockquote",
                  "__tag": 4059,
                  "children": [
                    {
                      "__type": "BulletList",
                      "__tag": 4053,
                      "ordered": false,
                      "start": 1,
                      "children": [
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "0: The algorithm converged to the desired accuracy."
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "1: The maximum number of mesh nodes is exceeded."
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "2: A singular Jacobian encountered when solving the collocation       system."
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "message",
              "annotation": "string",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Verbal description of the termination reason."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "success",
              "annotation": "bool",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "True if the algorithm converged to the desired accuracy ("
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "status=0"
                    },
                    {
                      "__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": "Solve a boundary value problem for a system of ODEs."
            }
          ]
        }
      ],
      "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": "fun",
              "annotation": "callable",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Right-hand side of the system. The calling signature is "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "fun(x, y)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", or "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "fun(x, y, p)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " if parameters are present. All arguments are ndarray: "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "x"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " with shape (m,), "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "y"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " with shape (n, m), meaning that "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "y[:, i]"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " corresponds to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "x[i]"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", and "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "p"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " with shape (k,). The return value must be an array with shape (n, m) and with the same layout as "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "y"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "bc",
              "annotation": "callable",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Function evaluating residuals of the boundary conditions. The calling signature is "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "bc(ya, yb)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", or "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "bc(ya, yb, p)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " if parameters are present. All arguments are ndarray: "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "ya"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "yb"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " with shape (n,), and "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "p"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " with shape (k,). The return value must be an array with shape (n + k,)."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "x",
              "annotation": "array_like, shape (m,)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Initial mesh. Must be a strictly increasing sequence of real numbers with "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "x[0]=a"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "x[-1]=b"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "y",
              "annotation": "array_like, shape (n, m)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Initial guess for the function values at the mesh nodes, ith column corresponds to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "x[i]"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". For problems in a complex domain pass "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "y"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " with a complex data type (even if the initial guess is purely real)."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "p",
              "annotation": "array_like with shape (k,) or None, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Initial guess for the unknown parameters. If None (default), it is assumed that the problem doesn't depend on any parameters."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "S",
              "annotation": "array_like with shape (n, n) or None",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Matrix defining the singular term. If None (default), the problem is solved without the singular term."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "fun_jac",
              "annotation": "callable or None, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Function computing derivatives of f with respect to y and p. The calling signature is "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "fun_jac(x, y)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", or "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "fun_jac(x, y, p)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " if parameters are present. The return must contain 1 or 2 elements in the following order:"
                    }
                  ]
                },
                {
                  "__type": "Blockquote",
                  "__tag": 4059,
                  "children": [
                    {
                      "__type": "BulletList",
                      "__tag": 4053,
                      "ordered": false,
                      "start": 1,
                      "children": [
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "df_dyarray_like with shape (n, n, m), where an element       (i, j, q) equals to d f_i(x_q, y_q, p) / d (y_q)_j."
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "df_dparray_like with shape (n, k, m), where an element       (i, j, q) equals to d f_i(x_q, y_q, p) / d p_j."
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Here q numbers nodes at which x and y are defined, whereas i and j number vector components. If the problem is solved without unknown parameters, df_dp should not be returned."
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "fun_jac"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is None (default), the derivatives will be estimated by the forward finite differences."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "bc_jac",
              "annotation": "callable or None, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Function computing derivatives of bc with respect to ya, yb, and p. The calling signature is "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "bc_jac(ya, yb)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", or "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "bc_jac(ya, yb, p)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " if parameters are present. The return must contain 2 or 3 elements in the following order:"
                    }
                  ]
                },
                {
                  "__type": "Blockquote",
                  "__tag": 4059,
                  "children": [
                    {
                      "__type": "BulletList",
                      "__tag": 4053,
                      "ordered": false,
                      "start": 1,
                      "children": [
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "dbc_dyaarray_like with shape (n, n), where an element (i, j)       equals to d bc_i(ya, yb, p) / d ya_j."
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "dbc_dybarray_like with shape (n, n), where an element (i, j)       equals to d bc_i(ya, yb, p) / d yb_j."
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "dbc_dparray_like with shape (n, k), where an element (i, j)       equals to d bc_i(ya, yb, p) / d p_j."
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If the problem is solved without unknown parameters, dbc_dp should not be returned."
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "bc_jac"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is None (default), the derivatives will be estimated by the forward finite differences."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "tol",
              "annotation": "float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Desired tolerance of the solution. If we define "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "r = y' - f(x, y)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", where y is the found solution, then the solver tries to achieve on each mesh interval "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "norm(r / (1 + abs(f)) < tol"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", where "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "norm"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is estimated in a root mean squared sense (using a numerical quadrature formula). Default is 1e-3."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "max_nodes",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Maximum allowed number of the mesh nodes. If exceeded, the algorithm terminates. Default is 1000."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "verbose",
              "annotation": "{0, 1, 2}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Level of algorithm's verbosity:"
                    }
                  ]
                },
                {
                  "__type": "Blockquote",
                  "__tag": 4059,
                  "children": [
                    {
                      "__type": "BulletList",
                      "__tag": 4053,
                      "ordered": false,
                      "start": 1,
                      "children": [
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "0 (default)work silently."
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "1display a termination report."
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "2display progress during iterations."
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "bc_tol",
              "annotation": "float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Desired absolute tolerance for the boundary condition residuals: "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "bc"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " value should satisfy "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "abs(bc) < bc_tol"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " component-wise. Equals to "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "tol"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " by default. Up to 10 iterations are allowed to achieve this tolerance."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This function numerically solves a first order system of ODEs subject to two-point boundary conditions      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "dy / dx = f(x, y, p) + S * y / (x - a), a <= x <= b\nbc(y(a), y(b), p) = 0",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Here x is a 1-D independent variable, y(x) is an n-D vector-valued function and p is a k-D vector of unknown parameters which is to be found along with y(x). For the problem to be determined, there must be n + k boundary conditions, i.e., bc must be an (n + k)-D function."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The last singular term on the right-hand side of the system is optional. It is defined by an n-by-n matrix S, such that the solution must satisfy S y(a) = 0. This condition will be forced during iterations, so it must not contradict boundary conditions. See "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for the explanation how this term is handled when solving BVPs numerically."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Problems in a complex domain can be solved as well. In this case, y and p are considered to be complex, and f and bc are assumed to be complex-valued functions, but x stays real. Note that f and bc must be complex differentiable (satisfy Cauchy-Riemann equations "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "4"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "), otherwise you should rewrite your problem for real and imaginary parts separately. To solve a problem in a complex domain, pass an initial guess for y with a complex data type (see below)."
            }
          ]
        }
      ],
      "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/_bvp.py",
  "item_line": 712,
  "item_type": "function",
  "aliases": [
    "scipy.integrate.solve_bvp"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "In the first example, we solve Bratu's problem::\n\n    y'' + k * exp(y) = 0\n    y(0) = y(1) = 0\n\nfor k = 1.\n\nWe rewrite the equation as a first-order system and implement its\nright-hand side evaluation::\n\n    y1' = y2\n    y2' = -exp(y1)\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\ndef fun(x, y):\n    return np.vstack((y[1], -np.exp(y[0])))\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nImplement evaluation of the boundary condition residuals:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "def bc(ya, yb):\n    return np.array([ya[0], yb[0]])\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nDefine the initial mesh with 5 nodes:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "x = np.linspace(0, 1, 5)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThis problem is known to have two solutions. To obtain both of them, we\nuse two different initial guesses for y. We denote them by subscripts\na and b.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "y_a = np.zeros((2, x.size))\ny_b = np.zeros((2, x.size))\ny_b[0] = 3\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nNow we are ready to run the solver.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.integrate import solve_bvp\nres_a = solve_bvp(fun, bc, x, y_a)\nres_b = solve_bvp(fun, bc, x, y_b)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nLet's plot the two found solutions. We take an advantage of having the\nsolution in a spline form to produce a smooth plot.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "x_plot = np.linspace(0, 1, 100)\ny_plot_a = res_a.sol(x_plot)[0]\ny_plot_b = res_b.sol(x_plot)[0]\nimport matplotlib.pyplot as plt\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.plot(x_plot, y_plot_a, label='y_a')\nplt.plot(x_plot, y_plot_b, label='y_b')\nplt.legend()\nplt.xlabel(\"x\")\nplt.ylabel(\"y\")\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.show()\n",
        "execution_status": "success"
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "1.17.1",
          "kind": "assets",
          "path": "fig-cb82bcbcb2427eed.png"
        }
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nWe see that the two solutions have similar shape, but differ in scale\nsignificantly.\n\nIn the second example, we solve a simple Sturm-Liouville problem::\n\n    y'' + k**2 * y = 0\n    y(0) = y(1) = 0\n\nIt is known that a non-trivial solution y = A * sin(k * x) is possible for\nk = pi * n, where n is an integer. To establish the normalization constant\nA = 1 we add a boundary condition::\n\n    y'(0) = k\n\nAgain, we rewrite our equation as a first-order system and implement its\nright-hand side evaluation::\n\n    y1' = y2\n    y2' = -k**2 * y1\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "def fun(x, y, p):\n    k = p[0]\n    return np.vstack((y[1], -k**2 * y[0]))\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nNote that parameters p are passed as a vector (with one element in our\ncase).\n\nImplement the boundary conditions:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "def bc(ya, yb, p):\n    k = p[0]\n    return np.array([ya[0], yb[0], ya[1] - k])\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nSet up the initial mesh and guess for y. We aim to find the solution for\nk = 2 * pi, to achieve that we set values of y to approximately follow\nsin(2 * pi * x):\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "x = np.linspace(0, 1, 5)\ny = np.zeros((2, x.size))\ny[0, 1] = 1\ny[0, 3] = -1\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nRun the solver with 6 as an initial guess for k.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "sol = solve_bvp(fun, bc, x, y, p=[6])\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nWe see that the found k is approximately correct:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "sol.p[0]\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nAnd, finally, plot the solution to see the anticipated sinusoid:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "x_plot = np.linspace(0, 1, 100)\ny_plot = sol.sol(x_plot)[0]\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.plot(x_plot, y_plot)\nplt.xlabel(\"x\")\nplt.ylabel(\"y\")\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.show()\n",
        "execution_status": "success"
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "1.17.1",
          "kind": "assets",
          "path": "fig-5d22f9d64e4f69ec.png"
        }
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "fun",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "bc",
        "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": "y",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "p",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "S",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "fun_jac",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "bc_jac",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "tol",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "0.001"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "max_nodes",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "1000"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "verbose",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "0"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "bc_tol",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "solve_bvp"
  },
  "references": [
    ".. [1] J. Kierzenka, L. F. Shampine, \"A BVP Solver Based on Residual",
    "       Control and the Maltab PSE\", ACM Trans. Math. Softw., Vol. 27,",
    "       Number 3, pp. 299-316, 2001.",
    ".. [2] L.F. Shampine, P. H. Muir and H. Xu, \"A User-Friendly Fortran BVP",
    "       Solver\", J. Numer. Anal., Ind. Appl. Math. (JNAIAM), Vol. 1, ",
    "       Number 2, pp. 201-217, 2006.",
    ".. [3] U. Ascher, R. Mattheij and R. Russell \"Numerical Solution of",
    "       Boundary Value Problems for Ordinary Differential Equations\",",
    "       Philidelphia, PA: Society for Industrial and Applied Mathematics,",
    "       1995.",
    "       :doi:`10.1137/1.9781611971231`",
    ".. [4] `Cauchy-Riemann equations",
    "        <https://en.wikipedia.org/wiki/Cauchy-Riemann_equations>`_ on",
    "        Wikipedia."
  ],
  "qa": "scipy.integrate._bvp:solve_bvp",
  "arbitrary": [],
  "local_refs": [
    "S",
    "bc",
    "bc_jac",
    "bc_tol",
    "fun",
    "fun_jac",
    "max_nodes",
    "message",
    "niter",
    "p",
    "rms_residuals",
    "sol",
    "status",
    "success",
    "tol",
    "verbose",
    "x",
    "y",
    "yp"
  ]
}