What is the essence of the expression $f(\bigcup_iA_i) = \bigcup_if(A_i)$? I'm new to set theory. While reading the book "Naive Set Theory" by Paul R. Halmos, I encountered the following statement:

It is true that if $\{A_i\}$ is a family of subsets of $X$, then $f(\bigcup_iA_i) = \bigcup_if(A_i)$, but the corresponding  equation for intersection is false in genearal, and the connection between images and complements is equally unsatisfactory.

Here, I am failing to understand the essence of the expression $f(\bigcup_iA_i) = \bigcup_if(A_i)$. I cannot figure out what this expression is actually trying to convey.
From my understanding of families, if $\{A_i\}$ is a family of subsets of $X$, then $\bigcup_iA_i$ is the range of the family $A$. Now, the left hand side term $f(\bigcup_iA_i)$ is confusing me as I do not understand how we are able to feed the range of a function $A$ into the function $f$.
For the right hand side, I understand $A_i$ being the image of $A$ at the index $i$ and $\bigcup_if(A_i)$ being the union of the images obtained for $f$ at the terms $A_i$.
I am not able to understand how these two things are related to each other.
P.S. For those who  have access to the book, the statement can be found at the beginning of Section 10.
 A: Each $A_i$ is a set.
$\bigcup A_i$ is also a set.
When you write $f(\text{set})$ you are referring to the set that you get from pushing every input from that set through $f$.
So $f\left(\bigcup A_i\right)$ is the collection of all elements $f(x)$ where $x$ comes from $\bigcup A_i$.
And this turns out to be equal to the set that you get from unioning all of the $f(A_i)$, each of which is a subset of the codomain of $f$.
A: Well $\bigcup_{i} A_i$ is just a set like any other set, and in particular it is defined as
$$\bigcup_{i} A_i=\{x : x\in A_i \text{ for some } i\}.$$
Thus $f\left(\bigcup_{i} A_i\right)$ is just the image of the set $\bigcup_{i}A_i$ under $f$.
Now let's use this to prove the statement, and hopefully you'll see why it makes sense. I'll use $I$ to denote the index set of the indexed family $\{A_i\}_{i\in I}$.
We start by showing that $\bigcup_{i\in I}f(A_i)\subseteq f\left(\bigcup_{i\in I}A_i\right)$. Let $x\in\bigcup_{i\in I}f(A_i)$. Then, by definition, $x\in f(A_i)$ for some $i\in I$. In particular, this means that $x=f(y)$ for some $y\in A_i$. But if $y\in A_i$, then we also have that $y\in\bigcup_{i\in I}A_i$, and so $x\in f\left(\bigcup_{i\in I} A_i\right)$.
We now show the reverse inclusion, i.e. that $\bigcup_{i\in I}f(A_i)\supseteq f\left(\bigcup_{i\in I}A_i\right)$. Let $x\in f\left(\bigcup_{i\in I}A_i\right)$. Then $x=f(y)$ for some $y\in\bigcup_{i\in I}A_i$. Then, by definition, $y\in A_i$ for some $i\in I$. In particular, this means that $x\in f(A_i)$. But if $x\in f(A_i)$, then clearly we also have that $x\in\bigcup_{i\in I}f(A_i)$.
As you can see in the two inclusions above, we use the same ideas in both directions, and the key part of the proof is the fact that if $x$ is an element of some union of sets, then $x$ is in at least one of the sets that the union is of, and vice versa. This is what allows us to "move" the union outside and inside the function as we wish, as we can always go from considering the entire union to considering one of sets the union is of, and back.
