Solving 1D Boundary Value Problem BVP Using Shooting Method

by admin in , , on April 4, 2019

This code implements the shooting method for solving 1D boundary value problem (abbrev. BVP ODE). It uses the Runge-Kutta method of 4th order for solving ODE and the interval bisection method for finding the alpha parameter.

Shooting method function form:

[x,y] = shooting_method(fun,h,zero,a,b,con,type,init)

The meaning of input and output parameters:

  • x – grid of points where the solution have been found
  • y – 2D array, values of function (solution) are in first row, values of 1st derivative are in second row
  • fun – the function handle, fun contains system of solved differential equations, e.g. let y” + y = sqrt(x+1) be the solved differential equation, then fun has the shape:
    function out = fce(x,y)
    out(1) = y(2);
    out(2) = sqrt(x+1)-y(1);
  • h – the step of the Runge-Kutta method (the step of the grid).
  • zero – the interval bisection method accuracy, it is recommended to set 1e-6.
  • a,b – outer points of the interval.
  • BC – values of boundary conditions (2D vector).
  • type – to specify type of the boundary condition in the particular point,  it is the string consists of 2 char (‘f’ for function, ‘d’ for derivative), e.g ‘fd’ is meant that in a point the condition is related to function and in the b point to derivative.
  • init – 2D vector of initial alpha parameters, it is not required, the implicit value is [-10 10]

The ploting of the solution: The solution (both function and 1st derivative) of BVP ODE is shown graphicaly after enumeration.

Example on using the function:

[x y] = shooting_method(fun,0.001,1e-6,0,1,[1 3],’fd’) – It is meant that will be solved the BVP ODE described in the function fun, on the interval (0,1) with boundary conditions y(0) = 1 and y'(1) = 3. With 0.001 Runge-Kutta step size, and 1e-6 of the interval bisection method accuracy.

0 Sale

Share Now!

Release Information

  • Price
    :

    $4.99

  • Released
    :

    April 4, 2019

  • Last Updated
    :

    May 29, 2019

Share Your Valuable Opinions