Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matrix Diagonalization with constraint

Status
Not open for further replies.

dani8586

Programmer
Jun 12, 2012
8
GB
Hi, I'm new in this forum and I hope I can find some help :)

I'm dealing with the following problem. I've got a matrix that I'm diagonalizing with the subroutine Jacobi and Eigsrt that I've found online, and everithing works very fine. But now I need to impose some constraint on the eigenvalues. Suppose I have a matrix with 2 parameters, i would like to give just one parameter in input and get the second fixed by imposing that, for example, the smallest eigenvalues is some value X.

I tried to search online functions to do this but I didn't find anything..
Could anybody can help me? :)

Thanks!!!
 
Is this at all possible ?
As far as I know to evaluate eigenvalues from a matrix is unambiguous - but not vice versa.

As far as I remember my maths courses many different matrices share the same set of eigenvalues. If your matrix has nonzeros on the diagonal only, these are the eigenvalues. But if you interchange the elements on the diagonal, the eigenvalues remain the same. Same is for triangular matrices, where all the nonzeros are assembled in a triangle above or below the diagonal. They have the diagonal elements as eigenvalues as well.

Norbert

The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.
 
This sounds like an optimization problem to me. First if you want the lowest eigenvalue to be X for any matrix A, you have to optimize your parameters p1 and p2.

Tell me where do you want your parameters to be. Along the diagonal or off-diagonal?

Suppose you want p1 to be along the diagonal. This is now a problem of finding a shift. I give an example

Code:
A =

   3   2
   2   4

eig(A)

   1.4384
   5.5616

if you want the lowest eigenvalue to be X, then start with the matrix

Code:
A =

   3+p1   2
   2      4
then minimize the function

fn(p1) = abs( min(eval(A)) - X )

where min(eval(A)) is the minimum of the eigenvalues of A.

 
@ gummibaer

Yes, is possible. I've done this with Mathematica, but I need to write the same program in fortran in order to connetc my output with some other programs.

@ melmacianalf

Can I easily find these funcions "min" and "eval" on the internete? Sorry maybe for these trivial questions but I'm quite new with the fortran, but yes at the end is a problem of optimization!

Actually the real problem is the following. I've got a 4x4 matrix with four parameters. Each entry of the matrix is a function (polinomyal, sin, cos) of this parameters. I would like to impose some condition on the eigenvalues ( or eigenvectors in the future ) of these matrix, getting rid of one parameter...
I've got as an output of the function eigsrt the eigevalues of the matrix, given the 4 parameters. I think there is a ricorsive way , by imposing a starting point to an algoritme, to express one of the four parameters by imposing a condition on one of the eigenvalue...

Hope now is more clear and thank all of you!
 
dani8586:

Sorry my last post got scattered every where. Also I think one should add the shift for all the diagonal elements. Tell us if this is what you want.

For a matrix

Code:
A =
   3   2
   2   4

and

Code:
X = 2

you can optimize a parameter 'p' such that

Code:
A(1,1) = A(1,1) + p 
A(2,2) = A(2,2) + p

Following is the result of minimization of abs( min(eval(A)) - X )

Code:
#    p               min(eig(A))
     1.10000000       2.53844719
     0.10000000       1.53844719
    -0.90000000       0.53844719
     0.60000000       2.03844719
     1.10000000       2.53844719
     0.35000000       1.78844719
     0.85000000       2.28844719
     0.47500000       1.91344719
     0.72500000       2.16344719
     0.53750000       1.97594719
...
...
     0.56155274       1.99999993
     0.56155298       2.00000016
     0.56155280       1.99999999
     0.56155274       1.99999993
     0.56155283       2.00000002
     0.56155277       1.99999996
     0.56155281       2.00000000
     0.56155283       2.00000002
     0.56155281       1.99999999
     0.56155282       2.00000001
     0.56155281       2.00000000

I did it with gnu-octave which has many optimizers. Following is the code. Save it as "file.m" and run it as "octave file.m" in a terminal in Linux.

Code:
clear all;                                                                                
                                                                                          
function fn = constrain(p)                                                                
                                                                                          
  A =  [                                                                                  
    3  2                                                                                  
    2  4                                                                                  
  ];                                                                                      
                                                                                          
  X = 2;                                                                                  
                                                                                          
  A(1,1) = A(1,1) + p;                                                                    
  A(2,2) = A(2,2) + p;                                                                    
  fn1 = min(eig(A));                                                                      
  fn2 = fn1 - X;                                                                          
  fn  = abs(fn2);                                                                         
                                                                                          
  printf('%15.8f  %15.8f\n', p, fn1);                                                     
endfunction                                                                               
                                                                                          
p = 0.1;                                                                                  
                                                                                          
[x,v,nev] = minimize('constrain',p)

Once u successfully run the above code using octave, I am sure u can easily adapt the code for your 4x4 problem.
 
Thanks! I'll try as soon as I can. It looks quite general (maybe I'm wrong... ) so I think I can adapt this event to shift in non diagonal elements!

Hope so!

Thanks again, I'll try with a 2x2 and the try to adapt to my problem!!
 
dani8586:

[quote}
Thanks again
[/quote]

... then think about starring malamcianalf's post by clicking on the icon to the bottom left of his post for all the effort he put into it.

Norbert


The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top