Dynamic variable
Dear Analytical users,
I am newbe.
If I define inv_t as:
Dynamic[i_t](inv_0,Self[i_t-1]-dem_t[i_t]+lambda[i_t])
And i_t as:
1 .. 365
I will obtein in inv_t as
first value
inv_0
inv_0
second value
inv_0 - dem_t[1] + lambda[1]
or second value is
inv_0 - dem_t[2] + lambda[2]
Thanks in advance,
Sebastián.
The second value will be
inv_0 - dem_t[1] + lambda[1]Â
Let's take some example values:
Inv_0 := 100000 Dem_t := 10 * I_t Lambda := 100 * I_t
The result sequence will be:
100000
100000 + 200 - 20 = 100180
100180 + 300 - 30 = 100450
100450 + 400 - 40 = 100810
...
By the way, if you prefer writing dem_t[I_t] then that is fine, but the [I_t] part is not doing anything since variable names in a Dynamic automatically use the current time slice. So it is entirely equivalent to write
Dynamic[i_t](inv_0, Self[i_t-1] - dem_t + lambda)
 My own preference is to not include the extra subscript notation.
In a Dynamic, the notation X[I_t - k] is by position, not by value. So this notation is an abbreviated for X[@I_t = @I_t - k]. In general, this is not the same as X[ I_t = I_t - k ] nor X[ @I_t = I_t - k ].Â
Since positions are numbered starting at 1, positional and associative subscripts are the same in your example where you haveÂ
Index I_t := 1..365
But, if your change your example to instead use
Index I_t := 0..364
now you can see it makes a difference. When you are at the second position along I_t, the value of I_t is now 1, but the position is 2.
Changing the index in this way would not change the result of your Dynamic expression, because it is using positions and not the index values.
I point this out because your question about which one was the result sounded to me like you might have been wondering whether it was by position or by value, and maybe you were thinking that positions start at 0, as they do in C or Python languages.
Â
- 4 Forums
- 87 Topics
- 286 Posts
- 2 Online
- 1,887 Members