I feel I have a profound misunderstanding of how Mathematica works. Here's an example that confuses me: Say that for a matrix $A$ I want to extract the first $\mathrm{Tr}(A)$ normalized eigenvectors (the trace is guaranteed to be an integer). I would write a function

f[A_]= Normalize /@ Part[Part[Eigensystem[A], 2] , Range[Tr[A]]];

Nevertheless this doesn't work, it just outputs


and $...$ are the unnormalized eigenvectors. Meanwhile, if write

f[A_]= Part[Part[Eigensystem[A], 2] , Range[Tr[A]]];
v=Normalize /@ f[A]

it works perfectly. What is going on here?

  • $\begingroup$ Can you provide an example with a suitable matrix A? $\endgroup$ – Whelp Dec 17 '19 at 11:02
  • $\begingroup$ I will. By the way, I just solved my problem by replacing f[A_]= ... with f[A_]:= ..., but I don't understand what's the difference between these two.. $\endgroup$ – user2723984 Dec 17 '19 at 11:04
  • 2
    $\begingroup$ @user2723984 See (8829) and links therein. $\endgroup$ – Mr.Wizard Dec 17 '19 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.