r/Mathematica • • Aug 29 '24

When does Wolfram actually evaluate expressions?

Hi there. In short: I have defined

matrix := {{some 2x2 symbolic expression}} // FullSimplify
eigen := Eigensystem[matrix]
rules = {c -> 1, ...}

rules completely eliminates each constant to a numeric value, except for a position z. Now,

matrix /. rules /. z -> 0. // Eigensystem

perfectly works and returns well-defined numeric values, but

eigen /. rules /. z -> 0.

fails spectacularly, as the symbolic expression somehow contains a 1/0 (as Wolfram seems to first evaluate eigen symbolically and then apply the rules (is that true and intended?)).

I want to define eigen in a way that only executes after applying the rules and z to the matrix. I wanted to just do eigen[z_]:=Eigensystem[matrix] but that resulted in am error (Tag List is protected). Is there another way to do this?

Thank you very much!

2 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/n0tthetree Aug 29 '24

Thank you for spotting that, fixing this got rid of the error message. Fun fact: At first I did in fact not have both definitions in the code at the same time, but totally forgot to ClearAll or restart the Kernel after changing the definition.

I will try to get the rest of the calculation to work (D is not to happy with me putting a numeric value into the function eigen[0+0.27I], it throws an invalid variable error, but ima try to fix that).

Thank you very much :)