Use finite difference method to solve for eigenvalue E from the following second order ODE:(adsbygoogle = window.adsbygoogle || []).push({});

- y'' + (x2/4) y = E y

I discretize the equation so that it becomes

yi-1 - [2 + h2(x2i/4)] yi + yi+1 = - E h2 yi

where xi = i*h, and h is the distance between any two adjacent mesh points.

This is my Matlab code:

it returnsCode (Text):clear all

n = 27;

h = 1/(n+1);

voffdiag = ones(n-1,1);

for i = 1:n

xi(i) = i*h;

end

mymat = -2*eye(n)-diag(((xi.^2).*(h^2)./4),0)+diag(voffdiag,1)+diag(voffdiag,-1);

D=sort(eig(mymat),'descend');

lam= -D/(h^2);

spy(mymat)

fprintf(1,' The smallest eigenvalue is %g \n',lam(1));

fprintf(1,' The second smallest eigenvalue is %g \n',lam(2));

fprintf(1,' The 3rd eigenvalue is %g \n',lam(3));

Obviously, something wrong here, since the analytic solution should beCode (Text):The smallest eigenvalue is 9.92985

The second smallest eigenvalue is 39.3932

The 3rd eigenvalue is 88.0729

E = N + 1/2 (for N = 0, 1, 2, 3...)

The smallest eigenvalue should be 0.5, instead of 9.92985.

I don't know whether my numerical solution agrees with the analytic solution or not, if I impose a boundary condition (ie. when x goes to infinity, y(x) should vanish to 0). And I don't know how to impose boundary condition. Please help, thank you very much!

By the way, is there any another numerical way to find the eigenvalue E please?

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Use finite difference method to solve for eigenvalue E

Loading...

Similar Threads for finite difference method | Date |
---|---|

Finite difference method to solve first-order, multivariable | Oct 17, 2015 |

Finite Difference Method for non-square grid | Sep 14, 2015 |

Heat equation order of accuracy (Crank-Nicolson) | Jun 2, 2015 |

Finite difference method nonlinear PDE | Mar 27, 2015 |

**Physics Forums - The Fusion of Science and Community**