Two Point Boundary Value

Overview


Two point boundary value problems are second order ordinary differential equations of the form:
{% \frac{d^2y}{dx^2} + p(x)\frac{dy}{dx} + q(x)y = f(x) %}
{% y(0) = \alpha %}
{% y(L) = \beta %}
The function is specified on two points (the boundary points)

Solution


  • Divide the domain x into a set of equally spaced points.
    {% x_i = ih %}
  • Approximate the Derivatives

    Make the following approximations
    {% \frac{dy}{dx} = \frac{y(x_{i+1}) - y(x_{i-1})}{2h} %}
    {% \frac{d^2y}{dx^2} = \frac{ y(x_{i+1}) -2y(x_i) + y(x_{i-1}) }{ h^2 } %}

Example


The following example demonstrates uses a finite difference approximation to calculating the boundary value problem.


let fd = await import('/lib/numeric/finite-difference/v1.0.0/finite-difference.mjs');

let p = val => 0;
let q = val => -1;
let f = val => -1*Math.sin(2*3.14159*val);
let alpha = 0;
let beta = 0;

let answer = fd.linearbvp([0,1], 10, p, q, f, alpha, beta);

					
Try it!