Why does a function need a fixed number of arguments? I was thinking about how common commutative and associative operations can be thought of as acting on several numbers even though we do it in many separate binary steps, such as $a+b+c+d$ being expressible as $a+(b+(c+d))$ and we call the value that any of these expressions have as their 'Sum' but can we define a function/operation or mapping that takes $n$ number inputs for any $n$ and returns their sum? The issue is, we could give it $3$ inputs, or two inputs and for each there would be a different tuple, (or real number), so the function would have a non-constant number of arguments, is this possible to define?
As in general for a function $f(x_1,x_2....x_n$) for a different $n$ it must be a different function denoted by $f$.
 A: Strictly speaking a function can be regarded as a quadruple of

*

*A label or name, like $\sin$.


*A domain $D$.


*A codomain $C$.


*A mapping that for each element of $D$ tells how to "compute" its image in $C$.
Functions with variable number of arguments can be convenient, there are several ways to approach them.
I. Use different functions with the same label
(Ab)using notation, you could have functions with the same name indexed by their number of arguments like:
$$\gcd\nolimits_n:\Bbb Z^n\to\Bbb Z$$
defined recursively as
$$\gcd\nolimits_n(x_1,\dots,x_n)=\begin{cases}
x_1, &\text{ if } n=1\\
\gcd(x_1, x_2), &\text{ if } n=2\\
\gcd(\gcd_\nolimits{n-1}(x_1,\dots, x_{n-1}), x_n), &\text{ if } n>2\\
\end{cases}$$
and then, as a matter of convenience / lazyness, drop the index and just write $\gcd(a,b,c,d)$ etc. where it's unabgiguously clear that you mean the specimen $\gcd_4$.
II. Use a domain that contains all possible $n$-tuples
You can use a domain that contais all possible tuples of values:
$$D^\cup=\bigcup_{n\in\Bbb N} D = D\cup D^2\cup D^3\cup\cdots$$
The $\gcd$-example from above would be $\gcd:\Bbb Z^\cup\to\Bbb Z$.   Notice however, that we didn't yet define the function law, and doing it recursively gets much more convoluted than with approach I.  To write it down, we'd need to define a function that "forgets" the last component of a $n$-dimensional vector etc., and all that notations is just cluttering up things and making things more convoluted than needed.
III. Use already existing notation
As you are referrung to sums:
Functions with variable number of arguments are already in wide-spread use, and using them is usually not a deep dive in the rabbithole of nitpicking, it's just a notation that's been taken for granted.  For example, the sum notation $\sum$ is a very generic device.  It's supposed to be meaningful over any domain that knows of summation, different notations of specifying the indices are understood, etc. like
$$\sum_{n\in\Bbb N}\frac1{n^2}=\sum_{n=1}^\infty\frac1{n^2}$$
and it can even cope with zero arguments: The empty sum is defined to be $0$.
On Notation
The previous sections make it very clear that variable-argument functions is more a matter of notation, that help to improve reader's experience by not going into 200% nitpick mode.  To that end, the notation for arguments that are vectors is already bit sloppy but still consistent.  Take for example again $$\gcd:\Bbb Z^2\to\Bbb Z$$
This can be seen as

*

*A function that takes two arguments from $\Bbb Z$.


*A function that takes one vector-argument from $\Bbb Z^2$.
In the first case, the notation is $\gcd(a,b)$ with $a,b\in\Bbb Z$. In the second case, it is $\gcd(v)=\gcd((a,b))$ with $v=(a,b)\in\Bbb Z^2$.
A: The way functions are defined is as a relation between two sets. A function $f: A \to B$ can be thought as a subset $G = (x, f(x))$ of the cartesian product
$$A \times B = \{ (a,b); a \in A, b \in B\}$$
satisfying the property that for each $x \in A$ there's is only one $f(x) \in B$ such that $(x, f(x)) \in G$. Heuristically, this is basically defining what a function is by means of its graph. Of course, what we usually do in a daily basis is to think of $f$ not as an subset, but as a rule $x \mapsto f(x)$ relating to each object of $A$ an object in $B$
In this sense, you could say that, technically, every function $f$ has only one argument, which is the element in $A$. When you write something like $f(x_1, \cdots, x_n)$ and say $f$ is a function of $n$ arguments you are simply considering a function whose domain $A$ is written as product $A = A_1 \times A_2 \times \cdots \times A_n$. In this case, each $n$-tuple $(x_1, \cdots, x_n)$ is a single element $x$ of $A$, so in the end $f(x_1, \cdots, x_n)$ is simply $f(x)$.
By adding or removing arguments I'm changing the product $A$, so I end up with different functions, strictly speaking, because I'm varying the domain.
What you can do is consider a huge set with all possible arguments, and fill most of them with constants. Let's think of real numbers, for example. You let the domain be
$$ \mathbb{R}^\mathbb{N} = \mathbb{R} \times \mathbb{R} \times \mathbb{R} \times \cdots = \{(x_1, x_2, \cdots, x_n, \cdots); x_i \in \mathbb{R}\}, $$
which is basically the set of all sequences $\{a_n\}_{n \in \mathbb{N}}$. Let $f:\mathbb{R}^\mathbb{N} \to B$ be a function. If you make the convention that every $m$-tuple $(x_1, \cdots, x_m)$ corresponds to the sequence $(x_1, \cdots, x_m, 0, 0, 0, \cdots)$, then it makes sense to write things like $f(x_1, x_2)$ or $f(x_1, x_2, x_3, x_4,x_5)$, and you can think of this as a fucntion where the number of arguments is varying. But in the end there is only one argument, which is a sequence in $\mathbb{R}^\mathbb{N}$.
This would work in a general infinite product $A_1 \times A_2 \times \cdots$ as well, but then you would have to choose elements $a_n \in A_n$ to play the role of $0$.

A: You can actually simulate a function with an arbitrary finite number of arguments: if the domain of your variables is $X$, then your function's domain could be $\coprod_{n\in \mathbb N}X^n$.
