Mathematics    

Representing BVP Problems

This section describes:

Example: Mathieu's Equation

This example determines the fourth eigenvalue of Mathieu's Equation. It illustrates how to write second-order differential equations as a system of two first-order ODEs and how to use bvp4c to determine an unknown parameter .

The task is to compute the fourth () eigenvalue of Mathieu's equation

Because the unknown parameter is present, this second-order differential equation is subject to three boundary conditions

1 Rewrite the Problem as a First-Order System.   To use bvp4c, you must rewrite the equations as an equivalent system of first-order differential equations. Using a substitution and , the differential equation is written as a system of two first-order equations

Note that the differential equations depend on the unknown parameter . The boundary conditions become

2 Code the System of First-Order ODEs in MATLAB.   Once you represent the equation as a first-order system, you can code it as a function that bvp4c can use. Because there is an unknown parameter, the function must be of the form

The code below represents the system in the MATLAB function, mat4ode.

See Finding Unknown Parameters for more information about using unknown parameters with bvp4c.

3 Code the Boundary Conditions Function.   You must also code the boundary conditions in a MATLAB function. Because there is an unknown parameter, the function must be of the form

The code below represents the boundary conditions in the MATLAB function, mat4bc.

4 Create an Initial Guess.   To form the guess structure solinit with bvpinit, you need to provide initial guesses for both the solution and the unknown parameter.

The function mat4init provides an initial guess for the solution. mat4init uses because this function satisfies the boundary conditions and has the correct qualitative behavior (the correct number of sign changes).

In the call to bvpinit, the third argument, lambda, provides an initial guess for the unknown parameter .

This example uses @ to pass mat4init as a function handle to bvpinit.

5 Apply the BVP Solver.   The mat4bvp example calls bvp4c with the functions mat4ode and mat4bc and the structure solinit created with bvpinit.

6 View the Results.   Complete the example by displaying the results:

See Evaluating the Solution at Specific Points for information about using bvpval.

The following plot shows the eigenfunction associated with the final eigenvalue = 17.097.

Finding Unknown Parameters

The bvp4c solver can find unknown parameters for problems of the form

You must provide bvp4c an initial guess for any unknown parameters in the vector solinit.parameters. When you call bvpinit to create the structure solinit, specify the initial guess as a vector in the additional argument parameters.

The bvp4c function arguments odefun and bcfun must each have a third argument.

The bvp4c solver calculates intermediate values of unknown parameters at each iteration, and passes the latest values to odefun and bcfun in the parameters arguments. The solver returns the final values of these unknown parameters in sol.parameters.

Evaluating the Solution at Specific Points

The collocation method implemented in bvp4c produces a C1-continuous solution over the whole interval of integration . You can evaluate the approximate solution, , at any point in using the structure sol returned by bvp4c and the helper function bvpval

The bvpval function is vectorized. For a vector xint, the ith column of Sxint approximates the solution .


 Boundary Value Problem Solver Making a Good Initial Guess