OK, it's surprising that there seems to be no regular answer to this common problem for beginners, let me elaborate my comment into an answer. If you restart your Mathematica and run your code again then you'll find your problem no longer exists anymore! Then, why? Because Mathematica is unstable?
Of course not. Just recall what you've done before meeting the error, you may find the following scene in the corner of memory:
The value of
kb is chosen at random.
It's another common mistake of Mathematica newbies, that is, mix up
Your code was in a mess now, but you didn't feel worried because you've already learned from some material that you can use
to fix this. You cheerfully placed this line at the beginning of your code and ran it again, only to find:
What happened? Why does the magic of
Clear["Global`*"] lose its power?
To answer this I'd like to first explain why you need to clear the variables after you mistyped
= since I presumingly guess you may still be vague about this. Try the following code:
A = 0
A == 0
A == 0
A == 0
BTW, though I've execute
A for several times to show the variation, you can judge whether
A owns a value just by observing its color: it's black when it does, otherwise it'll be blue.
As you see,
=) will give value to its left hand side. (Of course there exist cases that the left hand side is
Protected, for example
a + b = 4 won't give the left side a value, but it's another story and I'd like not to talk about it here. ) If you don't
Clear it, it'll be always there and break your equations. When introducing this issue, many materials will tell readers that you can simply use
Clear["Global`*"] to "clear all the variables" at once, but it doesn't work for your case, yeah, you already know that, but do you know what's the exact meaning of
If you check "Details" of document of Clear, you'll find the following description:
Clear["context`*"] clears all symbols in a particular context.
What's "context"? "context" is something that every symbol in Mathematica owns. You can check it by function
Context, for example:
Clear["Global`*"] is clearing the values of symbols under context
Global`, which is the stronghold for most symbols that'll have values (at least for beginners), but, what you can
Clear is only "most", not "all". Try the following code:
A' = 0
A' is one of the exceptions, the value of
A' isn't stored in
A, in fact it's stored as
SubValues (this is another story that I'd like to omit here, you can search it in this site or have a look at Leonid Shifrin's excellent book ) of
Derivative, then what's the context of
So values in it can't be cleared by
Clear["Global`*] (BTW 2, for most cases it can be shortened as
Clear["`*"], meaning clear all the values of symbols under the current context, which is usually
Global`), what you need to clear it is
Though some warnings generated,
Clear["System`*"] can be used too if you like.
BTW 3, another symbol that is likely to trig this problem is