Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linear boundary value problems:

Similar presentations


Presentation on theme: "Linear boundary value problems:"— Presentation transcript:

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 n=1 n=2 n=3

7 given that the boundary conditions are: x0=0, x4=1, 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 Schrodinger’s equation: matrix method
we want to solve subject to the boundary conditions

10 Back to Schrodinger’s 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 <nagmk21.h> //link to NAG library #include <stdio.h> #include <math.h> #include <stdlib.h> main(void) { }

14 F08JEF: the tri-diagonal NAG routine
#include <nagmk21.h> //link to NAG library #include <stdio.h> #include <math.h> #include <stdlib.h> int const N=100; //Size of matrix main(void) { char COMPZ='I'; //Calculate eigenvalues and eigenvectors int CLEN=1; //Character length int INFO=0; //Gives error information double D[N]; //Input diagonal elements //and returns eigenvalues double E[N-1]; //Input off diagonal elements double Z[N][N]; //Returns array of eigenvectors //as Z[quantum state][i] double WORK[2*(N-1)]; //Work space int i; for(i=0;i<N;i++) D[i]= 1.0; //Diagonal elements go here for(i=0;i<N-1;i++) E[i]= 2.0; //Off diagonal elements go here F08JEF(&COMPZ,CLEN,&N,(double *)D,(double *)E,(double *)Z,&N,(double *)WORK,&INFO); printf("%f\n",D[i]); //Print eigenvalues printf("%f\n",Z[0][i]); //Print first eigenvector }

15 F08JEF and the harmonic oscillator:
For the harmonic oscillator the diagonal elements are the off-diagonal elements are E[i]=-1; the results depend on N and x N=500, x=0.1 gives En= , , N=100, x=0.1 gives En= , , N=50, x=0.1 gives En= , , the higher eigenvalues are not so well measured because the eigenfunctions spread out beyond our lattice size.


Download ppt "Linear boundary value problems:"

Similar presentations


Ads by Google