Hot answers tagged

89

A dictionary is just a function $\mathrm{Dict}\colon \mathrm{Keys} \rightarrow \mathrm{Values}\cup\{\epsilon\}$ where $\epsilon$ is a "null character" with the understanding that $\epsilon\notin\mathrm{Values}$. For example, let $\mathrm{Keys}=\{A,B,C,...,Z\}$, and $\mathrm{Values}=\mathbb{Z}$. Then, in your case, $$ \mathrm{Dict}(x)=\begin{cases} 1 & \...


14

A standard Python dict corresponds to a function $f\colon K\to U$ in mathematics, where $U$ is the set of all possible Python objects or values of built-in types, and $K$ is a finite subset of $U$. I.e., for some finite set $K$ of keys it associates to each key an arbitrary (Python) value. When trying to evaluate a dict on a value that is not in $K$, a ...


9

Adding to @par 's excellent answer to deal with the second part of the question: I would like to use the structure for taking sums: e.g. 'AAAA' is interpreted as 1+1+1+1 etc. What kind of notation should I use? In your case the Keys are characters which you want to think of as Strings that happen to have length 1. The Strings have a natural ...


8

While par's answer is essentially the right response there are still a few subtle issues: A "dictionary type" is an abstract data type. An instance (basically an element) of that type is literally a function like the one par describes. But the "dictionary type" comes with a bunch of operations that you are allowed to do with its members, for example: ...


7

Spaces in which countable intersections of open sets are open are called $P$-spaces. (Warning: the same term is also used with a completely different meaning.) The co-countable topology on an uncountable set is an example of a non-discrete $T_1$ $P$-space. In general we can start with any space $\langle X,\tau\rangle$ and let $\tau'$ be the collection of $G_\...


6

The geometric meaning of $\pi$ and $\sin$ is really not that far from those other examples. In the case of the second-order differential equation $y'' + y = 0$, this naturally transforms to the first-order system $$ \eqalign{y' = v\cr v' = -y\cr}$$ Now notice that $y^2 + v^2$ is an invariant for this system: $$\dfrac{d}{dt} (y^2 + v^2) = 2 y v -...


5

The mostly commonly used AC has 3 forms: choice function: suppose you have a bag of inhabited sets $A$, then you can just say: oh, let $f$ be a function on $A$, with the action $f(x)\in x$ for each $x\in A$. zorn's lemma: suppose you have a partial order $A$ with the property that every linearly ordered subset (chain) is bounded above, then you can say: ...


3

That $y''=-y$ is satisfied by sine and cosine comes geometrically from the fact that something rotating around the unit circle at unit speed (something at $(\cos t,\sin t)$ by definition) has acceleration vector pointing towards the center of the circle, which is the negative of the position vector. By this reasoning, I don't think it's too strange that sine ...


3

A dictionary is a partial function from the key space $K$ to the value space $V$, where $K$ is the set of all hashable objects, and $V$ is the set of all Python objects. A partial function from $K$ to $V$ is a subset of $K\times V$ with the condition that for each $k\in K$ it contains at most one pair that has $k$ as first element. The difference to a ...


2

Your conditions imply $|f(x_1, y) - f(x_2, y)| \le 0$, hence, $f(x,y)$ is independent of $x$. Then, you can take any $x$ with $K(x) < +\infty$ and get $|f(x, y_1) - f(x, y_2)| \le K(x) \, |y_1 - y_2|$. Hence, $f$ is constant w.r.t. $x$ and Lipschitz w.r.t. $y$.


2

The whole point of "indexed family" is that it is a function. It is a function mapping the index to some object. So if you consider the first statement, it just says in a more complicated language that every family of non-empty sets has a choice function. Why more complicated? Because it requires the understanding that an indexed family is a function, ...


2

You begin your question with: Sine is usually defined as the ratio of the opposite side to an angle to the hypotenuse in a right angle triangle. Another common definition is based on the unit circle. This very beginning is the problem with your question, because sine and cosine are defined as you say only in middle and high school. Mathematics students ...


1

What a nice idea. For any relation $R$ on a set $X$, you might more generally define $$X / R \equiv \{ \{ y \in X : y R x\} : x \in R \}$$ (In order theory, these are related to the notion of ideals.) This construction has the property that if $R$ is a partial order on $X$, then $X/R \cong X$, and if $R$ is an equivalence relation then $X/R$ is the ...


1

A possible sub-base would be to take balls of only rational radius. Any ball of irrational radius can be realized as the infinite union of balls of rational radius. E.g. $ \ \ B_\pi(x) = B_3(x) \cup B_{3.1}(x) \cup B_{3.14}(x) \cup \cdots$ I hope I've interpreted the definitions correctly. I'm taking "sub-base" to mean a subset $S \subset B$ that serves ...



Only top voted, non community-wiki answers of a minimum length are eligible