Suppose $\mathfrak{A}$ is an algebra (over $\mathbb{C}$, let's say), $\phi$ a linear functional on $\mathfrak{A}$, and $A_1, A_2 \subset \mathfrak{A}$ subalgebras which are $\phi$-freely independent. Then one can calculate the value of any "moment" $\phi(x_1 \dots x_n)$, where (WLOG) the $x_i$ are alternately in $A_1$ and $A_2$, even when the $x_i$ are not centered: Define the centered elements $\mathring{x}_i = x_i - \phi(x_i) \mathbf{1}$, and then write $$ x_1 \dots x_n = \big( \mathring{x}_1 + \phi(x_1) \mathbf{1} \big) \dots \big( \mathring{x}_n + \phi(x_n) \mathbf{1} \big). $$ The right-hand side can be expanded into $2^n$ terms, constants pulled out, and neighboring terms from the same subalgebra "collapsed"; when the dust settles, all remaining terms are shorter than $n$ in length, except for the term $\mathring{x}_1 \dots \mathring{x}_n$, on which $\phi$ vanishes by the free independence hypothesis. This technique is mentioned in Remark 1.5.6 of Free Random Variables, and an example of such a calculation appears on page 70 of Lectures on the Combinatorics of Free Probability.

The above description of how to calculate moments makes good enough sense, but it would be useful to me to have an actual recursive formula, for assistance in things like (i) writing some code (for Mathematica, say), or (ii) proving assorted properties of the moments.

My initial stab at how to formalize this:

- Let $[n]$ denote the set $\{1, \dots, n\}$, or sometimes the ordered tuple $(1, \dots, n)$; I'll blur that distinction a little.
- Distinguish two kinds of moments, "general moments" and "alternating moments". Given an $n$-tuple $\vec{i} = (i_1, \dots, i_n) \in \{1,2\}^n$, and an $n$-tuple $\vec{x} = (x_1, \dots, x_n) \in (A_1 \cup A_2)^n$, let $GM(\vec{i}; \vec{x})$ denote the value of $\phi(x_1 \dots x_n)$ when, for each $j \in [n]$, $x_j \in A_{i_j}$. (By "value" here I mean some formal expression in the $\phi(x_i)$.) Note that we do not require neighboring entries of $\vec{i}$ to be distinct.
- The alternating moment $AM(x_1, \dots, x_n)$ is the value of $\phi(x_1 \dots x_n)$ if the $x_i$ alternate between $A_1$ and $A_2$.
- Given a tuple $\vec{i} \in \{1,2\}^n$, define the
**consecutivity tuples**of $\vec{i}$ to be the maximal consecutive sub-tuples of $[n]$ such that, for all $j$ in such a tuple, $i_j$ is the same. For instance, if $\vec{i} = (1,2,2,1,1,2,1)$ then the consecutivity tuples of $\vec{i}$ are $\vec{c}_1 = (1)$, $\vec{c}_2 = (2,3)$, $\vec{c}_3 = (4,5)$, $\vec{c}_4 = (6)$, and $\vec{c}_5 = (7)$. - Given $\vec{i}$ with consecutivity tuples $\vec{c}_1, \dots, \vec{c}_\ell$, one has

$$ GM(\vec{i}; \vec{x}) = AM \left( \prod_{i \in \vec{c}_1} x_i, \dots, \prod_{i \in \vec{c}_\ell} x_i \right), $$

so that one can reduce any general moment to an alternating moment of at most the same length.

- The center-and-expand strategy referenced above yields

$$ AM(x_1, \dots x_n) = \sum_{\vec{i} \subset [n]} GM(\mathring{x}_{i_1}, \dots, \mathring{x}_{i_k}) \prod_{j \in [n] \setminus \vec{i}} \phi(x_j) $$

where $k$ denotes the (variable) length of $\vec{i}$. The term with $\vec{i} = [n]$ vanishes by free independence, while the other terms involve moments of shorter tuples.

This seems a bit of a mess. Any suggestions for a cleaner approach? My apologies if something of this sort is already out there in the free probability literature, which I'm not as familiar with as I'd like to be.