BVP Finite Difference Finite diference approximations First Derivative
BVP Finite Difference
Finite diference approximations First Derivative Forward difference O(h) Backward difference O(h) Central difference O(h) Second Derivative
Boundary Value Problems consider the second order ordinary dierential equation linear system of m equations for the m unknowns with some given boundary conditions Second Derivative
Boundary Value Problems
Boundary Value Problems linear system of m equations for the m unknowns consider the second order ordinary dierential equation with some given boundary conditions
Neumann boundary conditions consider the second order ordinary dierential equation with some given boundary conditions linear system of m equations for the m unknowns
A general linear second order equation We now consider the more general linear equation This equation can be discretized together with two boundary conditions,
A general linear second order equation m = 100; alpha = 1; beta = 1; h = 1/(m+1); x = h: h: 1 -h; a = inline('x'); b = inline('x. ^2'); c = inline('2*x'); f = inline('x'); dd = h^2 * c(x) - 2*a(x); db = a(x(2: end)) - h*b(x(2: end))/2; du = a(x(1: m-1)) + h*b(x(1: m-1))/2; A = diag(dd) + diag(du, 1) + diag(db, -1); A = A/h^2; F = f(x); F(1) = F(1) - (a(x(1))/h^2 - b(x(1))/(2*h))*alpha; F(m) = F(m) - (a(x(m))/h^2 + b(x(m))/(2*h))*beta; u = AF'; x=[0, x, 1]; u=[alpha; u; beta]; plot(x, u)
The Eigenvalue Problem
The Eigenvalue Problem 1) Boundary-Value Problem Remark: Eigenvalue Problem (Matrix) This BVP has infinite number of eigenvalues
The Eigenvalue Problem (Matrix)
The Eigenvalue Problem (Matrix) clear; clc; m = 1000; alpha = 1; beta = 1; h = 1/(m+1); x = h: h: 1 -h; A = diag(-2*ones(m, 1)) + diag(ones(m-1, 1), -1); A = -A/h^2; ans = k=1000; [V, D]=eig(A); plot([0, x, 1]', [0; V(: , k); 0]) w= diag(D)/pi^2; w(1: 20) Remark: This BVP has infinite number of eigenvalues 1. 0 e+02 * 0. 009999991792020 0. 039999868668506 0. 089999335134332 0. 159997898700420 0. 249994869888851 0. 359989362239658 0. 489980292319556 0. 639966379732615 0. 809946147132871 0. 999917920238877 1. 209879827850197 1. 439829801865834 1. 689765577304603 1. 959684692327440 2. 249584488261649 2. 559462109627093 2. 889314504164319 3. 239138422864620 3. 608930420002040 3. 998686853167313
BVP Shooting Method
shooting method BVP: We want The basic idea of the shooting method is to replace the above boundary value problem by some initial value problem. Solve: Algorithm: IVP 1: IVP 2: 1) Solve (IVP 1) with 2) Solve (IVP 2) with 3) Calculate 3) The solution to BVP is
shooting method f=@(x, u)[u(2); -x*u(2)-2*u(1)+1]; alpha = 1; beta =1 ; m=100; h =1/(m+1); x_final = 1; xs = [0: h: 1]; x 0=[alpha; 0]; % [x, uu]=ode 45(f, [0, x_final], x 0); [x, uu]=ode 45(f, xs, x 0); u 1 = uu(: , 1); plot(x, u 1), hold on x 0=[alpha; 1]; % [x, uu]=ode 45(f, [0, x_final], x 0); [x, uu]=ode 45(f, xs, x 0); u 2 = uu(: , 1); plot(x, u 2), lambda = (beta-u 2(m+2))/(u 1(m+2)-u 2(m+2)); u = lambda*u 1+(1 -lambda)*u 2; plot(x, u), grid on; hold off Algorithm: 1) Solve (IVP 1) with 2) Solve (IVP 2) with 3) Calculate 4) The solution to BVP is
- Slides: 15