Author Topic: --={Challenge}=-- eigenvalues and eigenvectors of square matrix with complex num  (Read 503 times)

0 Members and 1 Guest are viewing this topic.

ribarm

• Gator
• Posts: 3334
• Marko Ribar, architect
--={Challenge}=-- eigenvalues and eigenvectors of square matrix with complex num
« on: July 31, 2024, 08:36:08 PM »
I think that this topic is somewhat incomlpete : https://www.theswamp.org/index.php?topic=43453.0
and this post is what could be used if neccesarry to use calculus with complex numbers : https://www.theswamp.org/index.php?topic=45666.0

And although I don't know what for are used eigenvalues with their eigenvectors in practical situations and with normal square matrix with normal real numbers, I suppose that question is useful for brainstorming...

If someone finds practical usage, please don't hasitate to share your opinion(s)...
nxn matrix with complex numbers is shown in second link here shown, so you can practice calculus with it for a start, though it's your turn to think if you find something more suitable...

So that's it... Challenge is open for anyone...
« Last Edit: July 31, 2024, 10:17:19 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

ribarm

• Gator
• Posts: 3334
• Marko Ribar, architect
Re: --={Challenge}=-- eigenvalues and eigenvectors of square matrix with complex num
« Reply #1 on: August 01, 2024, 05:12:42 PM »
All I did is that I combined eigenvalues with coresponding eigenvectors... Matrix is still with real numbers - not integers and without imaginary numbers i=(sqrt (- 1))

M.R.

Edit: File removed...
« Last Edit: August 03, 2024, 07:47:49 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

ribarm

• Gator
• Posts: 3334
• Marko Ribar, architect
Re: --={Challenge}=-- eigenvalues and eigenvectors of square matrix with complex num
« Reply #2 on: August 01, 2024, 05:22:30 PM »
But real challenge is this for ex.

Code - Auto/Visual Lisp: [Select]
1. (eigenvals+eigenvecs '(((1.0 0.5) (2.0 -0.5) (0.5 2.0) (3.0 1.0)) ((4.0 -0.6) (1.0 0.3) (0.6 1.4) (-2.7 -0.6)) ((-1.2 0.6) (2.3 1.2) (4.1 1.2) (-3.2 2.3)) ((-0.2 0.3) (-0.6 1.8) (1.4 0.4) (-0.9 0.2))))
2.
« Last Edit: August 01, 2024, 08:08:41 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

ribarm

• Gator
• Posts: 3334
• Marko Ribar, architect
Re: --={Challenge}=-- eigenvalues and eigenvectors of square matrix with complex num
« Reply #3 on: August 01, 2024, 09:10:29 PM »
Code: [Select]
`  : (eigenvals+eigenvecs '(((1.0 2.0) (2.0 3.0) (0.5 7.0) (3.0 4.0)) ((4.0 1.0) (1.0 2.0) (0.6 3.0) (-2.7 6.0)) ((-1.2 9.0) (2.3 3.0) (4.1 4.0) (-3.2 2.0)) ((-0.2 8.0) (-0.6 4.0) (1.4 5.0) (-0.9 6.0))))  Real part of matrix...  eigenvalue : (-3.10709325337578 0.0)  eigenvectors : ((1.0 0.0) (-1.36926008001226 0.0) (0.373298144625995 0.0) (-0.518407388873907 0.0))  checking solution...  sum-eigenval*eigenvecs : (1.59819345715225 0.0)  sum-eigenvecs*mat : (1.59819345619477 0.0)  eigenvalue : (1.8113164375 -1.98745309375)  eigenvectors : ((1.0 0.0) (-0.274129672907482 1.24580850756096) (-0.497902712395894 -2.3576943282289) (0.536177151713595 -1.1000671791139))  checking solution...  sum-eigenval*eigenvecs : (-3.0120448566176 -5.52524870755717)  sum-eigenvecs*mat : (-3.0120448566176 -5.52524870755717)  eigenvalue : (1.8113164375 1.98745290625)  eigenvectors : ((1.0 0.0) (-0.274129777303998 -1.24580853350094) (-0.497902579829243 2.35769472530721) (0.536177279962932 1.100067332957))  checking solution...  sum-eigenval*eigenvecs : (-3.01204520192711 5.52524982606384)  sum-eigenvecs*mat : (-3.01204520192711 5.52524982606384)  eigenvalue : (4.68445570698305 0.0)  eigenvectors : ((1.0 0.0) (1.17394600127587 0.0) (1.45548511989103 0.0) (0.202940380682898 0.0))  checking solution...  sum-eigenval*eigenvecs : (17.9525745531195 0.0)  sum-eigenvecs*mat : (17.9525745506823 0.0)  Complex part of matrix...  eigenvalue : (0.0 -5.37623580749263)  eigenvectors : ((1.0 0.0) (-0.47491481773585 -0.784026923130698) (-0.348271431316148 0.950233603622257) (-0.536744948125564 0.211767847335822))  checking solution...  sum-eigenval*eigenvec : (2.03208019082569 1.93507499049969)  sum-eigenvec*mat : (2.03208019082569 1.93507499049969)  eigenvalue : (0.0 -0.283478153834717)  eigenvectors : ((1.0 0.0) (-2.40133057575776 -2.12532632536138) (-0.798066486464023 1.65280697353639) (0.932396171316304 -0.00450725192062479))  checking solution...  sum-eigenval*eigenvec : (-0.135226620959851 0.359167073460827)  sum-eigenvec*mat : (-0.135226620959851 0.359167073460827)  eigenvalue : (0.0 2.09152537243999)  eigenvectors : ((1.0 0.0) (-0.688806536472434 2.16696279976989) (-0.529008924338052 -1.89415444590614) (-0.427936305148885 -0.0153531015926592))  checking solution...  sum-eigenval*eigenvec : (-0.538474192392917 -1.35060620280196)  sum-eigenvec*mat : (-0.538474192392917 -1.35060620280196)  eigenvalue : (0.0 17.5681885888874)  eigenvectors : ((1.0 0.0) (-0.172120911191864 0.0570279764147821) (-0.123294535940686 -0.430392020572182) (-0.214625469048622 -0.307788753170472))  checking solution...  sum-eigenval*eigenvec : (11.9666208013043 8.60769358536768)  sum-eigenvec*mat : (11.9666208013043 8.60769358536768)`
Code: [Select]
`  : (eigenvals+eigenvecs '(((1.0 0.5) (2.0 -0.5) (0.5 2.0) (3.0 1.0)) ((4.0 -0.6) (1.0 0.3) (0.6 1.4) (-2.7 -0.6)) ((-1.2 0.6) (2.3 1.2) (4.1 1.2) (-3.2 2.3)) ((-0.2 0.3) (-0.6 1.8) (1.4 0.4) (-0.9 0.2))))  Real part of matrix...  eigenvalue : (-3.10709325337578 0.0)  eigenvectors : ((1.0 0.0) (-1.36926008001226 0.0) (0.373298144625995 0.0) (-0.518407388873907 0.0))  checking solution...  sum-eigenval*eigenvecs : (1.59819345715225 0.0)  sum-eigenvecs*mat : (1.59819345619477 0.0)  eigenvalue : (1.8113164375 -1.98745309375)  eigenvectors : ((1.0 0.0) (-0.274129672907482 1.24580850756096) (-0.497902712395894 -2.3576943282289) (0.536177151713595 -1.1000671791139))  checking solution...  sum-eigenval*eigenvecs : (-3.0120448566176 -5.52524870755717)  sum-eigenvecs*mat : (-3.0120448566176 -5.52524870755717)  eigenvalue : (1.8113164375 1.98745290625)  eigenvectors : ((1.0 0.0) (-0.274129777303998 -1.24580853350094) (-0.497902579829243 2.35769472530721) (0.536177279962932 1.100067332957))  checking solution...  sum-eigenval*eigenvecs : (-3.01204520192711 5.52524982606384)  sum-eigenvecs*mat : (-3.01204520192711 5.52524982606384)  eigenvalue : (4.68445570698305 0.0)  eigenvectors : ((1.0 0.0) (1.17394600127587 0.0) (1.45548511989103 0.0) (0.202940380682898 0.0))  checking solution...  sum-eigenval*eigenvecs : (17.9525745531195 0.0)  sum-eigenvecs*mat : (17.9525745506823 0.0)  Complex part of matrix...  eigenvalue : (0.0 0.971154166666668)  eigenvectors : ((1.0 0.0) (-0.449594447365009 -0.143635009007765) (0.519929117381395 -0.126587446209991) (-0.244115512254408 0.360520989120683))  checking solution...  sum-eigenval*eigenvec : (-0.0876937974437197 0.80238617764037)  sum-eigenvec*mat : (-0.0876937974437197 0.80238617764037)  eigenvalue : (0.0 2.94564583333332)  eigenvectors : ((1.0 0.0) (-0.0802333591325678 0.255053958596088) (-0.0400822957494955 -0.247220017297657) (0.118522347707787 -0.055421294357849))  checking solution...  sum-eigenval*eigenvec : (0.140175488258836 2.94036338552753)  sum-eigenvec*mat : (0.140175488258836 2.94036338552753)`
P.S. In attachment is my lastly modified version...
« Last Edit: August 03, 2024, 10:18:00 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

Stefan

• Bull Frog
• Posts: 321
• The most I miss IRL is the Undo button
Re: --={Challenge}=-- eigenvalues and eigenvectors of square matrix with complex num
« Reply #4 on: August 02, 2024, 02:20:59 PM »
Hi Marko

Seems like your check didn't quite match.
Here is Wolfram solution

And here is my solution
Code: [Select]
`A = Input matrix((1.0 0.5) (2.0 -0.5) (0.5 2.0) (3.0 1.0)) ((4.0 -0.6) (1.0 0.3) (0.6 1.4) (-2.7 -0.6)) ((-1.2 0.6) (2.3 1.2) (4.1 1.2) (-3.2 2.3)) ((-0.2 0.3) (-0.6 1.8) (1.4 0.4) (-0.9 0.2)) Det(A) = (-202.691 64.132)Characteristic polynomial = (1.0 (-5.2 -2.2) (0.2 9.12) (53.246 -38.656) (-202.691 64.132))EigenValue: (4.38714 1.17097)EigenVector: ((0.598196 0.211489) (0.784874 -0.155389) (0.426953 -0.0841711) (0.104031 0.301694))Verification Av=lv:Av = ((2.37672 1.62831) (3.62531 0.237353) (1.97166 0.130679) (0.103124 1.44539))lv = ((2.37672 1.62831) (3.62531 0.237353) (1.97166 0.130679) (0.103124 1.44539))-----------------------------------EigenValue: (-3.46913 1.27897)EigenVector: ((0.647871 -0.0778881) (-0.717905 -0.06007) (0.213061 0.217154) (-0.304411 0.127887))Verification Av=lv:Av = ((-2.14793 1.09881) (2.56733 -0.709787) (-1.01687 -0.480838) (0.892478 -0.832989))lv = ((-2.14793 1.09881) (2.56733 -0.709787) (-1.01687 -0.480838) (0.892478 -0.832989))-----------------------------------EigenValue: (2.52306 2.6949)EigenVector: ((-0.687759 0.188282) (-0.146035 0.486079) (-0.753715 -0.237471) (-0.517126 -0.0415601))Verification Av=lv:Av = ((-2.24266 -1.37839) (-1.67839 0.832858) (-1.26171 -2.63034) (-1.19274 -1.49846))lv = ((-2.24266 -1.37839) (-1.67839 0.832858) (-1.26171 -2.63034) (-1.19274 -1.49846))-----------------------------------EigenValue: (1.75892 -2.94484)EigenVector: ((-0.460627 0.473245) (-0.715456 -0.513732) (0.733856 -0.411936) (0.668689 0.228414))Verification Av=lv:Av = ((0.583425 2.18887) (-2.77129 1.20329) (0.0777078 -2.88565) (1.84881 -1.56742))lv = ((0.583425 2.18887) (-2.77129 1.20329) (0.0777078 -2.88565) (1.84881 -1.56742))-----------------------------------DiagonalizationS = matrix with eigenvectors as columns((0.598196 0.211489) (0.647871 -0.0778881) (-0.687759 0.188282) (-0.460627 0.473245)) ((0.784874 -0.155389) (-0.717905 -0.06007) (-0.146035 0.486079) (-0.715456 -0.513732)) ((0.426953 -0.0841711) (0.213061 0.217154) (-0.753715 -0.237471) (0.733856 -0.411936)) ((0.104031 0.301694) (-0.304411 0.127887) (-0.517126 -0.0415601) (0.668689 0.228414)) J = diagonal matrix with eigenvalues on the main diagonal((4.38714 1.17097) 0.0 0.0 0.0) (0.0 (-3.46913 1.27897) 0.0 0.0) (0.0 0.0 (2.52306 2.6949) 0.0) (0.0 0.0 0.0 (1.75892 -2.94484)) S^-1 = inverse of S((0.336414 -0.32062) (0.499714 0.119857) (0.369659 0.956816) (-0.725748 -0.521228)) ((0.476307 -0.039944) (-0.556818 0.095628) (0.129504 0.0989395) (-0.732553 -0.46865)) ((-0.173855 -0.24299) (-0.0475059 0.142827) (-0.394249 0.859301) (-0.832361 -0.829618)) ((-0.221336 -0.334293) (-0.268556 0.105158) (0.189394 0.279974) (0.211035 -0.430116)) SJS^-1 = A((1.0 0.5) (2.0 -0.5) (0.5 2.0) (3.0 1.0)) ((4.0 -0.6) (1.0 0.3) (0.6 1.4) (-2.7 -0.6)) ((-1.2 0.6) (2.3 1.2) (4.1 1.2) (-3.2 2.3)) ((-0.2 0.3) (-0.6 1.8) (1.4 0.4) (-0.9 0.2)) `
Notice the Eigenvectors are different. That is because each scaled Eigenvector is also an eigenvector.

Code: [Select]
`_\$ (setq eigenval1 (caar r))(4.38714 1.17097)_\$ (setq wolf_eigenvec (mapcar 'car wolf))((0.472509 0.280214) (0.692753 0.0) (0.376781 0.000302835) (0.0376274 0.273733))_\$ (setq my_eigenvec (mapcar 'car s1))((0.598196 0.211489) (0.784874 -0.155389) (0.426953 -0.0841711) (0.104031 0.301694))_\$ (mapcar 'c/ wolf_eigenvec my_eigenvec)((0.849339 0.168152) (0.849339 0.168151) (0.849339 0.168151) (0.849339 0.168151))_\$ `
Edit: file removed
« Last Edit: August 02, 2024, 05:01:28 PM by Stefan »

ribarm

• Gator
• Posts: 3334
• Marko Ribar, architect
Re: --={Challenge}=-- eigenvalues and eigenvectors of square matrix with complex num
« Reply #5 on: August 03, 2024, 11:54:07 PM »
@Stefan, thanks for reply, but this Challenge isn't completed in a manner I wish yet...
I posted *.lsp file and I want that someone download it and try to fix it, so that everything matches correctly without separating real part of matrix and complex part of matrix... So everything should match in checking solutions : sum-eigenval*eigenvecs = sum-eigenvecs*matrix...
P.S. I don't know why you posted *.lsp and then you removed it - perhaps it also had some lacks...
Marko Ribar, d.i.a. (graduated engineer of architecture)