## Documentation Center |

Solve boundary value problems for ordinary differential equations

`sol = bvp5c(odefun,bcfun,solinit)sol = bvp5c(odefun,bcfun,solinit,options)`

A function handle that evaluates
the differential equations dydx = odefun(x,y) dydx = odefun(x,y,parameters) For a scalar | ||

A function handle that computes
the residual in the boundary conditions. For two-point boundary value
conditions of the form res = bcfun(ya,yb) res = bcfun(ya,yb,parameters) where | ||

A structure containing the
initial guess for a solution. You create | ||

Ordered nodes of the initial mesh. Boundary conditions
are imposed at | ||

Initial guess for the solution such that | ||

Optional. | ||

The structure can have any
name, but the fields must be named | ||

Optional integration argument.
A structure you create using the |

`sol = bvp5c(odefun,bcfun,solinit)` integrates
a system of ordinary differential equations of the form

*y*′ = *f*(*x*,*y*)

on the interval [a,b] subject to two-point boundary value conditions

*bc*(*y*(*a*),*y*(*b*))
= 0

`odefun` and `bcfun` are function
handles. See the `function_handle` reference
page for more information.

Parameterizing Functions explains how to provide additional
parameters to the function `odefun`, as well as the
boundary condition function `bcfun`, if necessary.
You can use the function `bvpinit` to
specify the boundary points, which are stored in the input argument `solinit`.

The `bvp5c` solver can also find unknown
parameters *p* for problems of the form

*y*′ = *f*(*x*,*y*,*p*)

0 = *bc*(*y*(*a*),*y*(*b*),*p*)

where *p* corresponds to `parameters`.
You provide `bvp5c` an initial guess for any unknown
parameters in `solinit.parameters`. The `bvp5c` solver
returns the final values of these unknown parameters in `sol.parameters`.

`bvp5c` produces a solution that is continuous
on `[a,b]` and has a continuous first derivative
there. Use the function `deval` and
the output `sol` of `bvp5c` to
evaluate the solution at specific points `xint` in
the interval `[a,b]`.

sxint = deval(sol,xint)

The structure `sol` returned by `bvp5c` has
the following fields:

Mesh selected by | |

Approximation to | |

Values returned by | |

Computational cost statistics (also displayed when the stats option
is set with bvpset). |

The structure `sol` can have any name, and `bvp5c` creates
the fields `x`, `y`, `parameters`,
and `solver`.

`sol = bvp5c(odefun,bcfun,solinit,options)` solves
as above with default integration properties replaced by the values
in `options`, a structure created with the `bvpset` function.
See `bvpset` for details.

` solinit = bvpinit(x, yinit,
params)` forms the initial guess

`bvp5c` solves a class of singular boundary
value problems, including problems with unknown parameters `p`,
of the form

*y*′ = *S*· *y*/*x* + *f*(*x*,*y*,*p*)

0 = *bc*(*y*(0),*y*(*b*),*p*)

The interval is required to be [0, *b*] with
b > 0. Often such problems arise when computing a smooth solution
of ODEs that result from partial differential equations (PDEs) due
to cylindrical or spherical symmetry. For singular problems, you specify
the (constant) matrix `S` as the value of the `'SingularTerm'` option
of `bvpset`, and `odefun` evaluates
only *f*(*x*,*y*,*p*).
The boundary conditions must be consistent with the necessary condition *S*· *y*(0)
= 0 and the initial guess should satisfy this condition.

`bvp5c` can solve multipoint boundary value
problems where *a* = *a*_{0} < *a*_{1} < *a*_{2} <
... < *a*_{n} = *b* are
boundary points in the interval [*a*,*b*].
The points *a*_{1},*a*_{2},
... ,*a*_{n–1} represent
interfaces that divide [*a*,*b*]
into regions. `bvp5c` enumerates the regions from
left to right (from *a* to *b*),
with indices starting from 1. In region *k*, [*a*_{k–1},*a** _{k}*],

yp = odefun(x,y,k)

In the boundary conditions function

bcfun(yleft,yright)

yleft(:, k) is the solution at the left boundary of [*a*_{k–1},*a** _{k}*].
Similarly,

yleft(:,1) = y(a)

and

yright(:,end) = y(b)

When you create an initial guess with

solinit = bvpinit(xinit,yinit),

use double entries in `xinit` for each interface
point. See the reference page for `bvpinit` for
more information.

If `yinit` is a function, `bvpinit` calls `y
= yinit(x, k)` to get an initial guess for the solution at `x` in
region `k`. In the solution structure `sol` returned
by `bvp5c`, `sol.x` has double entries
for each interface point. The corresponding columns of `sol.y` contain
the left and right solution at the interface, respectively.

To see an example of that solves a three-point boundary value
problem, type `threebvp` at the MATLAB^{®} command
prompt.

[1] Shampine, L.F., M.W. Reichelt, and J.
Kierzenka "Solving Boundary Value Problems for Ordinary Differential
Equations in MATLAB with bvp4c" `http://www.mathworks.com/bvp_tutorial`.
Note that this tutorial uses the bvp4c function, however in most cases
the solvers can be used interchangeably.

Was this topic helpful?