# Wrongly assigning a value to an expression

Sometimes I misstype an equality and I write an assignment instead.

For example, if I write

f'[x] = 2


instead of an equation, f'[x] == 2, it seems that the expression f'[x] now works as a variable which stores the value 2. And in fact,

f'[x] // FullForm
(* 2 *)


I can undo this by unsetting the assignment,

f'[x] =. ;

f'[x]
(* f'[x] *)


But I do not understand how and where this value is stored.

If I write

f[x] = 2;


I know that f gets a downvalue for when evaluated at x, but in the case of f'[x] I do not understand, is it modifying the definition of Derivative?

• Related: (40314). Actually halirutan's answer to that question makes this seem like a duplicate, but I don't want to cast a binding vote on it. – Mr.Wizard Jun 7 '17 at 11:51

## 2 Answers

Yes, it will be associated to Derivative. The basic way to check this is to look at the definition of Derivative:

?? Derivative


This won't show anything about f, but it will show that Derivative has the ReadProtected attribute. This prevents the definitions from being printed. It also shows that Derivative does not have the Protected attribute, which is a big hint that its definitions can be easily changed.

So let us remove ReadProtected,

ClearAttributes[Derivative, ReadProtected]


and check again

??Derivative


Now you can see the definition.

As @Kuba said, there is a more convenient undocumented way (since version 10) that works without needing to remove attributes:

<< GeneralUtilities

PrintDefinitions[Derivative]


Consider the FullForm of f'[x]:

f'[x] // FullForm // HoldForm

Derivative[1][f][x]


If we make a definition on a similar object with a substitution for Derivative, the rule is bound to that substitution:

foo[1][f][x] = 5;

? foo

Globalfoo

foo[1][f][x]=5


More specifically it appears in the SubValues list:

SubValues[foo]

{HoldPattern[foo[1][f][x]] :> 5}


That itself could be found with:

LanguageExtendedDefinition[foo]

LanguageDefinitionList[
foo -> {OwnValues -> {}, SubValues -> {HoldPattern[foo[1][f][x]] -> 5},
UpValues -> {}, DownValues -> {}, NValues -> {}, FormatValues -> {},
DefaultValues -> {}, Messages -> {}, Attributes -> {}}]


Reference: Copying one symbol into another

Exactly the same evaluation is followed for your case, and indeed the rule is found in:

f'[x] = 2;

SubValues[Derivative]

{HoldPattern[Derivative[1][f][x]] :> 2, . . . }


My point is other than the parsing of f'[x] into Derivative[1][f][x] no special behavior is observed here.