An apostrophe ' is often used when we want to distinguish two variables. For example, if we already have a variable t and we may want define another variable t'. What I found weird is that, in *Mathematica` it is legitimate to define a variable with apostrophe but it just can't clear a variable which has an apostrophe in the usual way.

For example, if we write the following


and 3t' will correctly give 24

but Clear[t'] will prompt an error says

Clear::ssym: t' is not a symbol or a string

Can anyone help?

  • 6
    $\begingroup$ Apostrophe means Derivative in Mathematica. You don't define a new variable, you add a rule for Derivative function. It is not Protected, which is why you can do it. Don't use apostrophe for this purpose, this is a wrong thing to do. $\endgroup$ Commented Dec 3, 2012 at 13:59
  • 1
    $\begingroup$ @NasserM.Abbasi It is really often used in mathmatics that way and I have seen people using this notation in Mathematica very often. I'm sure if someone uses this notation, he just tries it without looking it up in the documentation and since it seems to work, they think it's fine. $\endgroup$
    – halirutan
    Commented Dec 3, 2012 at 14:50
  • 1
    $\begingroup$ Duplicate of: mathematica.stackexchange.com/q/373/5 $\endgroup$
    – rm -rf
    Commented Dec 3, 2012 at 16:21
  • $\begingroup$ I have a question! why mathematica design Derivative to be not protected?? $\endgroup$
    – matheorem
    Commented Dec 4, 2012 at 13:05

3 Answers 3


You already read from @Leonid and @halirutan that it's impossible to use the simple notation a' as a primed variable because it represents a derivative.

Of course you may now wonder if this means that primed variables are completely impossible. The answer is that you can define primed variables. To do so, you just have to introduce a different glyph for the apostrophe in your variable names. Looking at the unicode characters understood by Mathematica, I have the following suggestion.

First define an input alias, i.e., a shortcut for entering the new "prime". This alias definition is only done for the currently active notebook (edit catch the case where there are no existing InputAnliases):

 InputAliases -> 
   Join[{"prime" -> FromCharacterCode[700]}, 
    InputAliases /. 
      Quiet[Options[EvaluationNotebook[], InputAliases]] /. 
     InputAliases -> {}]

The last line says that you're now allowed to enter the keyboard sequence escprimeesc when typing variable names. For example, type

eescprimeesc = 1

to get an input line that looks like this:

eʼ = 1


Now you have a variable where the apostrophe is part of the name, as shown below:


eʼ = 1

Note that I chose a glyph for the primed symbol that is slightly slanted so that you can distinguish it visually from the derivative prime.

And of course, you can now clear the primed variable (coming back to your question) as usual:




  • $\begingroup$ Ah, clever. +1. $\endgroup$
    – rcollyer
    Commented Dec 3, 2012 at 17:20

As Leonid already pointed out in comments, it only seems that you set a variable t' here, but your assumption is wrong.

Never use ' appended to a variable to define another distinguishable variable!

The ' has the built-in meaning: It expresses the derivative of t. You can see this by using FullForm which gives you the full Mathematica expression used


(* Derivative[1][a][x] *)

Note, that your a only occurs as part of Derivative. Because of this you are able to use y'[x] as derivative of y when e.g. using DSolve. You can now almost guess, how t', which you assumed to be a valid variable name, is stored


(* Derivative[1][t] *)

The important detail is that such derivatives are not stored with the variable name. They are stored as SubValues of Derivative. Example:

a'[x] = x;

(* {HoldPattern[Derivative[1][a][x]] :> x} *)

to clear now thes SubValues you can use

SubValues[Derivative] = {}

or, which I find more unclear, ClearAll[Derivative].

and now a'[x] will no longer evaluate to x.

  • 3
    $\begingroup$ Maybe it'd be good to include FullForm[t'] in the answer, as illustration. $\endgroup$
    – Szabolcs
    Commented Dec 3, 2012 at 15:03

Thank you for all your help! Jens's alias definition is quite general. But I just found that we can write a variable with an apostrophe much more easily.

mathematica has bulit-in symbol \[Prime]

or to use keyboard, just

esc ' esc

this will give a symbol very similar to the derivative meaning apostrophe while a little lower in position.

so in conclusion, if we want to define a variable t', we just knock the keyboard in order

t esc ' esc

I think we'd better call it primed variable instead of variable with an apostrophe. You can clear this primed variable normally with "Clear".

  • 1
    $\begingroup$ Yes, that's true - as long as you're OK with the fact that your \[Prime] doesn't appear raised above the text baseline. I.e., \[Prime] doesn't actually look like the character you'd usually call an apostrophe (and it doesn't look like the one displayed in this answer). The unicode character that I found has this raised appearance. $\endgroup$
    – Jens
    Commented Dec 4, 2012 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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