octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

## [Octave-bug-tracker] [bug #44004] eig and eigs routine

 From: Sebastian Glane Subject: [Octave-bug-tracker] [bug #44004] eig and eigs routine Date: Wed, 14 Jan 2015 18:06:43 +0000 User-agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:34.0) Gecko/20100101 Firefox/34.0

```URL:
<http://savannah.gnu.org/bugs/?44004>

Summary: eig and eigs routine
Project: GNU Octave
Submitted by: sebastian_g
Submitted on: Wed 14 Jan 2015 06:06:42 PM GMT
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Inaccurate Result
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 3.8.1
Operating System: GNU/Linux

_______________________________________________________

Details:

The code below demonstrates a large difference in the computed eigenvalues of
the eig- and eigs-routine. eigs will find complex pairs whereas eig finds real
ones.

It gets much better if you replace 'sm' by 'sr'. Execute the script a few
times and observe that somehow large difference occure. This seems unreliable
to me.

By the way, if you choose 'sr' and p=3, you will get the error

sigma = "sr" requires complex or unsymmetric problem

% solves Eigenvalue Problem
%   -y''= lambda^2 y on the interval (a,b)
%
% with mixed boundary conditions
%   -- dirichlet boundary condition y(a)=0
%   -- robin boundary condition   y'(b)=y(b)
clear all;
close all;
p=6;
%% number of points
n=2^p;
%% grid space
h=1/2^p;
%% numbers of eigenvalues to find
kmax=8;
%% assemble symmetric 2nd finite difference matrix
Lh=-gallery('tridiag',n,1,-2,1)./(h^2);
%% apply robin boundary in last line
Lh(n,:)=0.0;
Lh(n,n-1)=-2/h^2;
Lh(n,n)=-1/h^2*(2*h-2);
%% use eig to get all eigenvalues
[~,LambdaEig]=eig(Lh);
LambdaEig=sort(diag(LambdaEig));
lambdaEig=LambdaEig(1:kmax);
%% use eigs routine to get 1st kmax eigenvalues of smallest magnitude
[~,LambdaEigs,fl]=eigs(Lh,kmax,'sm');
lambdaEigs=sort(diag(LambdaEigs))(1:kmax);
%% compute difference of 1st kmax eigenvalues of smallest magnitude
err=abs(lambdaEig-lambdaEigs)

_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?44004>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/

```

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]