Error with tag times in MATLAB

6 replies · 21K views · last reply
EdisT
Messages
17
Reaction score
0
Hey, I'm unsure why the following returns an error:

Mathematica session showing In[47] defining K[q_, N_] := (q + N - 1)! / (q! (N - 1)!), followed by a SetDelayed::write error that Tag Times in a factorial expression is protected.


Any ideas on how to fix this?
 
It means that you already defined K. Entering K = . will remove the previous definition of K, so you can define it again as a function.
 
  • Like
Likes   Reactions: EdisT
DrClaude said:
It means that you already defined K. Entering K = . will remove the previous definition of K, so you can define it again as a function.
Ah thank you!
 
Mark44 said:
Not the most helpful error message...
That's because the error occurs after the substitution has been done. If you look carefully,
EdisT said:
Mathematica input In[47] defining K[q_, N_] := (q + N - 1)! / (q! (N - 1)!), followed by a SetDelayed::write error: Tag Times in (299 - 100 (()..))! (299 + 100 (()..))! is Protected.
you will see the presence of [q_, N_] after a bunch of math. That bunch of math is what K was equal to: K[q_, N_] was substituted by <<value of K>>[q_, N_], including some mathematical operations that cannot appear on the left side of := .

It doesn't take long to get acquainted with "Tag [...] is Protected" in Mathematica, and one never forgets what they are due to :smile:
 
Mark44 said:
I get "Tag" but "Tag Times in ... " is inscrutable. Is "Times" the name of a variable in the OP's script?
No, it's multiplication (in the core Mathematica language).