0
$\begingroup$

I'm trying to define a custom matrix Ry with a parameter x, in Mathematica.

Ry[x_] = {{Cos[x/2], Sin[x/2]}, {-Sin[x/2], Cos[x/2]}}

However, when I execute the cell using Shift+Enter, I always get the same output no matter what value of x I plug in.

In[130]:  Ry[5]
Out[130]: {{Cos[1/2], Sin[1/2]}, {-Sin[1/2], Cos[1/2]}} 

What am I missing?

$\endgroup$
  • 1
    $\begingroup$ Probably you need to Clear[x] before defining your matrix. Or, use SetDelayed (:=) instead of Set (=). $\endgroup$ – Carl Woll May 27 at 18:04
  • $\begingroup$ Thanks, Clear[x] solved the problem. That should be an answer! :) $\endgroup$ – Blue May 27 at 18:05

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.