How do I define exactly what a function is?

5xum is right -- your definition is not sufficient. However, you may be interested to know that your definition,

A relation $R \subset (D \times C)$ is a function if: $$ (\forall (d_1, c_1) \in R)(\forall (d_2, c_2) \in R)(d_1 = d_2 \rightarrow c_1 = c_2)$$

is something we care about in some braches of math! This is called a partial function $D \to C$.

Partial functions are especially used in the theory of recursive functions (or computable functions from $\mathbb{N}$ to $\mathbb{N}$).


The usual way to define a function, you are correct, is by relations. However, your definition is not ok, because for example, an empty relation fits your definition.

The correct definition must say something like:

A relation $R\subset A\times B$ is a function if each element $a$ of $A$ is contained in exactly one relation $(a,b)\in R$

In pure terms, you can write this as

$$\forall a\in A\exists! b\in B: (a,b)\in R$$

Where the $\exists!$ quantifier means "exists precisely one". A longer version (with only $\exists$ and $\forall$) would be

$$\forall a\in A \exists b\in B:((a,b)\in R\land \forall b'\in B:(a,b')\in R\implies b=b').$$


Answer to your other question about functions on multiple inputs:

No, functions are always binary relations. A function of "multiple (say, $n$ inputs" is actuall a function whose domain is a cartesian product. So, for example, a function of $n$ real numbers is in fact a function whose domain is equal to $\mathbb R^3$.

This means that technically, we shouldn't write $f(x,y)=xy$, for example. We should write $f((x,y))=xy$, because $f$ takes only one input, and that input is a tuple of two numbers.