I know we can write $\langle f(x), g(x) \rangle = \int f(x)g(x)dx$ and if we discretize the latter we can write $ <f, g> = tr(g^T f)$.
But how could one write this in the general case where $f$ and $g$ depend on $n$ independent variables? $\langle f(x_1,x_2,...,x_n), g(x_1,x_2,...,x_n) \rangle $ = ?
Are there any good resources where I can learn more about this kind of mathematics?
Measure theory has means to unite the "discretized" and "continuous versions" and also cover all those pernicious examples that involve both. It also extends to all numbers of dimensions:
If $A$ is a set provided with a (countably) additive set function $\mu$ then we can define an inner product on the set $L_\mu^2(A)$ of all $\mu$-square-integrable functions from $A \to \Bbb R$ by $$\langle f, g \rangle = \int fg \,\,d\mu$$
If $A$ is a connected subset of $\Bbb R$, the $\mu$ is Lesbegue measure and the integration is just ordinary integeration.
If $A$ is a finite set, for example, the integers from $1$ to $n$, then we can defined $\mu$ to be the cardinality: for $C \subseteq A$, $\mu(C) = |C|$, the number of elements in $C$. With this definition $$\int fg\,\,d\mu = \sum_{i \in A} f(i)g(i)$$
You can also combine the two: Let $A = \Bbb R \cup C$ where $C$ is finite, and define $U \subseteq A$ to be measurable if $U \cap \Bbb R$ is measurable. Define $\mu(U)$ to be sum of the Lesbegue measure of $U \cap \Bbb R$ and $|U \cap C|$. Then $$\int fg\,\,d\mu = \int_{U \cap \Bbb R} fg dx + \sum_{i \in U\cap C} f(i)g(i)$$
What about your question? That is just a matter of defining $\mu$ for multiple dimensions. If you mean the variables $x_i$ to be continuous variables, then the integral is just higher dimensional integration: For example, when $A = \Bbb R^2$, $$\langle f, g\rangle = \iint f(x,y)g(x,y)\,\, dx dy$$
If the $x_i$ are to be discrete, then the set A of all tuples $(x_1, x_2, ..., x_n)$ within the domain is still a finite set, so the definition I gave above still works: $$\langle f,g \rangle = \sum_{i \in A} f(i)g(i)$$ The only difference is that $i$ happens to be a tuple instead of an integer. In particular, if $A = \{1, 2, ..., m\}^n$ then the sum can also be expressed as $$\sum_{i \in A} f(i)g(i) = \sum_{x_1 = 1}^m \sum_{x_2 = 1}^m ... \sum_{x_n = 1}^m f(x_1, x_2, ..., x_n)g(x_1, x_2, ..., x_n)$$