In Python programming, normally an array is considered a vector:
example an array b is defined as:
$b = b_n \in \mathbb{R}^{|N|} =[b_{0}, b_{1},....b_{|N-1|}] $
lets say there is now a vector c
Instead of real numbers in vector c like above, I now have one dictionary in the vector. (I just happen to code it so, changing it now would be problematic)
From what I know dictionary is considered a function that map a parameters to a variable
How do I define vector c like I did vector b ? is it normal to have a function in a vector in math ?
One question here is how to model Python mathematically.
This is actually somewhat non-trivial because Python allows many features which make this difficult. Consider the following code:
How does one model the resulting
xmathematically? It is a list that contains itself. Mathematics does allow for this, but it requires an understanding of "corecursion", which is a highly nontrivial topic.But the issue actually runs even deeper. If we write
then in any "nice" mathematical model, we should expect
xandyto behave identically to one another. But this is not the case at all, since the statementsx.append(1)andy.append(1)have completely different behaviour.The nature of Python means that if we wish to model what is going on in Python, we must model the entire state of the program from top to bottom as a single mathematical object. This is quite undesirable and cumbersome.
Another question is: what is the mathematical equivalent of a dictionary?
In set-based mathematics, it is possible to define a "sequence" as a function, the domain of which is $\{0, 1, ..., n - 1\}$ for some $n$ (possibly including $n = 0$). This is the mathematical equivalent of a "list" or "tuple" from Python.
More generally, one can define a "dictionary" as a function whose domain is finite. Clearly, sequences are a special case of "dictionaries" in mathematics. Generally, mathematicians have little use for "dictionaries" (and don't call them dictionaries), preferring to simply work with functions in general.
Note that the "values" of a sequence or a dictionary can be anything at all under this definition. It is quite normal in mathematics to work with sequences of all kinds of things. One speaks of sequences of sets, sequences of numbers, sequences of functions, sequences of sequences, etc.