bvp5c
Solves boundary value problems with a fourth-order method that controls the true error.
Category: Mathematics > Numerical Integration and Differential Equations
Syntax
sol = bvp5c(odefun, bcfun, solinit)
Solves the system y' = odefun(x, y) with boundary conditions bcfun(y(a), y(b)) = 0.
sol = bvp5c(odefun, bcfun, solinit, options)
Also applies options from bvpset.
Description
bvp5c has the same calling pattern as bvp4c, so one can often be swapped for the other. The difference is in the error control: bvp4c limits the residual of the collocation polynomial, while bvp5c limits the error in the solution itself, which can matter when a tight tolerance is required.
If one solver stalls on a hard problem, try the other, and improve the initial guess.
Input arguments
odefun, bcfun- Function handles for the equations and for the boundary residuals, as for
bvp4c. solinit- Initial mesh and guess from
bvpinit. options- Structure from
bvpset.
Output arguments
sol- Structure with the fields
x,y,ypandstats, usable withdeval.
Example
Same problem as bvp4c
odefun = @(x, y) [y(2); -y(1)];
bcfun = @(ya, yb) [ya(1); yb(1) - 1];
solinit = bvpinit(linspace(0, 1, 5), [0; 1]);
sol = bvp5c(odefun, bcfun, solinit);
y = deval(sol, 0.5);
fprintf('%.4f\n', y(1))
Output
0.5697