Linear boundary value problems: - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Linear boundary value problems:

Description:

use NAG (Numerical Algorithms group) routine to solve the matrix problem. ... write your C program, remembering to include the NAG routines, in the new folder ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 16
Provided by: ITS8230
Category:

less

Transcript and Presenter's Notes

Title: Linear boundary value problems:


1
Linear boundary value problems Matrix methods
Aims
  • write boundary value problem for ODE as a matrix
    equation.
  • use NAG (Numerical Algorithms group) routine to
    solve the matrix problem.

2
Setting up the problem
  • linear 2nd order ODE
  • boundary conditions
  • Discretize the independent variable, t.

3
Discretizing t the function
Continuum
Numerical
4
Discretizing t, the derivatives
  • Taylor expand the function x(t)
  • Solve for ,
  • Solve for ,
  • Substitute these into the continuum ODE to get a
    set of linear equations for the unknowns xn.

5
The equation
Eg.
The boundary conditions
The analytic solution
6
  • the discretized equation is

Try
  • n1
  • n2
  • n3

7
  • given that the boundary conditions are x00,
    x41, we arrive at
  • which we can write in matrix form
  • Now solve with linear algebra, e.g. row
    reduction, matrix inversion

8
  • in this example we have that for general
  • this tri-diagonal structure comes from the
    discrete version of the derivative operator.
  • We can think of the derivative operator as
    connecting neighbouring lattice points, as
    exemplified by the above equation.

9
Back to Schrodingers equation matrix method
  • we want to solve
  • subject to the boundary conditions

10
Back to Schrodingers equation matrix method
  • introduce the rescaled quantities
  • introduce the finite difference derivatives to
    get
  • it is our aim to find E (i.e. ?) and

11
  • We then get the series of linear equations
  • Or, in matrix form
  • This is now a matrix eigenvalue problem,

which we can solve to find the eigenvalues
And the eigenvectors, ?n. This
gives us the E we are after.
12
  • We could try to solve
    using the standard technique from matrix algebra
    the characteristic equation
  • This leads to a large order polynomial and is
    intractable analytically.
  • Fortunately there are people who have solved
    this before, the Numerical Algorithms Group, NAG.
  • We shall be using a particular routine which
    solves the eigenvalue, eigenvector problem for
    tri-diagonal matrices, F08JEF.

13
Using NAG routines in C
  • create a folder in which your program will live
  • write your C program, remembering to include the
    NAG routines, in the new folder
  • In Plato, click on New Project in the file
    menu
  • Click on C application, enter a name for your
    project, and choose the location to be the folder
    you just created.
  • A new Project Explorer window will appear on
    the right.
  • Right-click on references, then left-click on
    add reference
  • Choose Nag_mk21 on the P-drive, by clicking on
    the MyComputer icon
  • Go into the bin folder and double-click on
    FLDLL214Z_nag.dll
  • Right-click on Source Files in the Project
    Explorer window, choose Add Existing Items and
    select your C program.

include ltnagmk21.hgt //link to NAG
library include ltstdio.hgt include
ltmath.hgt include ltstdlib.hgt main(void)
14
F08JEF the tri-diagonal NAG routine
include ltnagmk21.hgt //link to NAG
library include ltstdio.hgt include
ltmath.hgt include ltstdlib.hgt int const N100
//Size of matrix main(void) char
COMPZ'I' //Calculate eigenvalues and
eigenvectors int CLEN1
//Character length int INFO0
//Gives error information double DN
//Input diagonal elements
//and returns eigenvalues double
EN-1 //Input off diagonal elements
double ZNN //Returns array of
eigenvectors //as
Zquantum statei double WORK2(N-1)
//Work space int i for(i0iltNi)
Di 1.0 //Diagonal elements go here
for(i0iltN-1i) Ei 2.0
//Off diagonal elements go here F08JEF(COMPZ,CLEN
,N,(double )D,(double )E,(double
)Z,N,(double )WORK,INFO) for(i0iltNi)
printf("f\n",Di) //Print eigenvalues
for(i0iltNi) printf("f\n",Z0i)
//Print first eigenvector
15
F08JEF and the harmonic oscillator
  • For the harmonic oscillator the diagonal
    elements are
  • the off-diagonal elements are
  • Ei-1
  • the results depend on N and ?x
  • N500, ?x0.1 gives En0.994.., 2.9969..,
    4.9919..
  • N100, ?x0.1 gives En0.994.., 2.9969..,
    4.9919..
  • N50, ?x0.1 gives En1.007.., 3.083..,
    5.397..
  • the higher eigenvalues are not so well measured
    because the eigenfunctions spread out beyond our
    lattice size.
Write a Comment
User Comments (0)
About PowerShow.com