Dynamic[something]
is a spot on the screen, which gets updated when its content is updated.
There is really no dynamic variable in the traditional sense. Better to think of Dynamic[something]
as just a Dynamic spot or location on the screen at same place where Dynamic
is located.
Mathematica will update this spot on the screen when it detects something has changed. i.e. if any variable or the expression inside the Dynamic
has changed due to changes elsewhere in the notebook. That is all.
To get what you want do
z = 1;
Dynamic[z + 1]
(*2*)
Now scroll down a little, and type z=9
, then you'll notice that earlier spot on the screen now will change to 10
and not to 11
.
If you cover that spot by another window, then Mathematica will no longer update that spot. It will only update that spot if there is nothing in front of the notebook.
I could achieve it using Dynamic[z+1]
Yes, that is the right approach.
You do not get 2
when you do Dynamic[z] + 1
because there is no algebra with Dynamic. You are trying to add 1
to a spot on the screen. So Mathematica just returns 1+1
. Dynamic is like a wrapper here. You can't add to it.