(Newbie question)

For every function I define I get this message:

enter image description here

When I close and reopen Mathematica, and re-enter the function definition, I don't get the message anymore. What does it mean?

  • 5
    $\begingroup$ You can see that f is already defined because it's coloured black. You can verify this using ?f too. Instead of the drastic Remove[f] you can also use Clear[f] to clear all definitions, or f =. to remove f's value if f is a simple variable (in Mathematica terms: it only has OwnValues but not DownValues). $\endgroup$ – Szabolcs Jun 13 '12 at 7:29
  • 2
    $\begingroup$ You may find this discussion of some relevance. $\endgroup$ – Leonid Shifrin Jun 13 '12 at 9:00
  • 1
    $\begingroup$ I can't stand seeing the typo ... when you want to define functions with variables (which appears to be what you are doing) you don't use the = sign alone. You should be use the SetDelayed := sign: f[Rx_] := 25 Rx/(Rx+50)^2 $\endgroup$ – Nick Aug 12 '14 at 20:07
  • 1
    $\begingroup$ Nick, I am glad you have chosen to contribute to our site. However, this isn't really an Answer as it does not directly relate to the message in Question. You are correct that (usually) one wants SetDelayed when defining a function, but this note belongs as a comment, not an Answer. I know you do not yet have the "privilege" of posting comments but if you continue to participate that will change. For now I am converting your post into a comment on your behalf. $\endgroup$ – Mr.Wizard Aug 12 '14 at 20:14
  • 2
    $\begingroup$ @Nick you are usually correct in that you want to use SetDelayed instead of Set. But, on occasion, you can use Set if you need the right-hand-side to be evaluated, e.g. f[x_] = Integrate[q^2, {q, 0, x}]. This is cleaner looking than using Evaluate, but with the same effect. $\endgroup$ – rcollyer Aug 12 '14 at 20:20

It means you set f = 156 sometime before you executed that function definition. Executing a Remove[f] before your new definition should have fixed the problem.

  • $\begingroup$ Thanks. Makes sense. But I also got this in a new notebook. Does that mean that the scope of symbols is session-wide instead of notebook-constrained? (Not what I would expect) $\endgroup$ – stevenvh Jun 13 '12 at 7:19
  • 1
    $\begingroup$ Yes, session-wide. If you want to constrain your symbols to a particular notebook, see this question. $\endgroup$ – J. M.'s ennui Jun 13 '12 at 7:25
  • 4
    $\begingroup$ @stevenvh The kernel state is not specific to the notebook. You have to restart the kernel to clear its state completely. But if you want notebook-local symbols, you can use Evaluation -> Notebook's Default Context -> Unique to This Notebook. This option is available since version 6. $\endgroup$ – Szabolcs Jun 13 '12 at 7:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.