File:Diagonalization as rotation.gif

From testwiki
Jump to navigation Jump to search

Diagonalization_as_rotation.gif(357 × 197 pixels, file size: 556 KB, MIME type: image/gif, looped, 153 frames)

This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

Summary

Description
English: You can visualize a matrix diagonalization as a rotation of your axis to align them with the matrix eigenvectors.
Date
Source https://twitter.com/j_bertolotti/status/1192396841381515264
Author Jacopo Bertolotti
Permission
(Reusing this file)
https://twitter.com/j_bertolotti/status/1030470604418428929
Camera location52° 44′ 24.84″ N, 8° 11′ 40.65″ E Kartographer map based on OpenStreetMap.View this and other nearby images on: OpenStreetMapinfo

Mathematica 11.0 code

m = RandomReal[{-10, 10}, {3, 3}];
m = Round[(m + Transpose[m])/2, 0.01];
\[Lambda] = Eigenvalues[m];
\[Psi] = Eigenvectors[m];

angle[u_, v_] := ArcCos[u.v/(Norm[u] Norm[v])];
xyz = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
\[Alpha]1 = \[Alpha] /. NMinimize[Norm[EulerMatrix[{\[Alpha], 0, 0}].xyz[[2]] - Cross[{0, 0, 1}, \[Psi][[3]]]/Norm[Cross[{0, 0, 1}, \[Psi][[3]]]] ], \[Alpha]][[2]];(*rotate y in the plane perpendicular to Subscript[\[Psi], z]*)
\[Beta]1 = angle[{0, 0, 1}, \[Psi][[3]]];
\[Gamma]1 = -angle[Cross[{0, 0, 1}, \[Psi][[3]]], \[Psi][[2]]];

p1 = Table[
   Grid[{{
      PaddedForm[MatrixForm[Inverse[EulerMatrix[{\[Alpha], 0, 0}]].m.EulerMatrix[{\[Alpha], 0, 0}] ], {3, 2}], Graphics3D[{Gray, Table[Arrow[{{0, 0, 0}, xyz[[j]]}], {j, 1, 3}], Sphere[{0, 0, 0}, 0.1]
        , Black, Table[Arrow[{{0, 0, 0}, EulerMatrix[{\[Alpha], 0, 0}].xyz[[j]]}], {j, 1, 3}] }, Boxed -> False, PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}]
      }}]
   , {\[Alpha], 0, \[Alpha]1, \[Alpha]1/40}];
p2 = Table[
   Grid[{{
      PaddedForm[MatrixForm[Round[Inverse[EulerMatrix[{\[Alpha]1, \[Beta], 0}]].m.EulerMatrix[{\[Alpha]1, \[Beta], 0}], 0.01] ], {3,2}], Graphics3D[{Gray, Table[Arrow[{{0, 0, 0}, xyz[[j]]}], {j, 1, 3}], 
        Sphere[{0, 0, 0}, 0.1], Black, Table[Arrow[{{0, 0, 0}, EulerMatrix[{\[Alpha]1, \[Beta], 0}].xyz[[j]]}], {j, 1, 3}]
        }, Boxed -> False, PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}]
      }}]
   , {\[Beta], 0, \[Beta]1, \[Beta]1/40}];
p3 = Table[
   Grid[{{
      PaddedForm[MatrixForm[Round[Inverse[EulerMatrix[{\[Alpha]1, \[Beta]1, \[Gamma]}]].m.EulerMatrix[{\[Alpha]1, \[Beta]1, \[Gamma]}], 0.01] ], {3, 2}], Graphics3D[{Gray, Table[Arrow[{{0, 0, 0}, xyz[[j]]}], {j, 1, 3}], Sphere[{0, 0, 0}, 0.1], Black, Table[Arrow[{{0, 0, 0}, EulerMatrix[{\[Alpha]1, \[Beta]1, \[Gamma]}].xyz[[j]]}], {j, 1, 3}]
        }, Boxed -> False, PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}]
      }}]
   , {\[Gamma], 0, \[Gamma]1, \[Gamma]1/40}];
ListAnimate[Join[p1, p2, p3, Table[p3[[-1]], 30]]]

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Captions

Add a one-line explanation of what this file represents

7 November 2019

image/gif

52°44'24.8402"N, 8°11'40.6547"E

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current11:01, 11 November 2019Thumbnail for version as of 11:01, 11 November 2019357 × 197 (556 KB)wikimediacommons>BertoUser created page with UploadWizard

The following page uses this file: