TITLE: What is the probability of product of two elements is desired element?
QUESTION [7 upvotes]: Let $G$ be a group with $n$ element. Fix $x\in G$.
If you choose randomly two elements from $G$, what is the probability of $x$ being product of these two elements?
At first, I thought answer was $1/n$, because, if $ab=x$ and if I choose $a$, it uniquely determines $b$. I guess it is true answer when $G$ is abelian.
But when $G$ is nonabeliean, $ab$ and $ba$ may be different elements; therefore, the probability is higher than $1/n$. I can't say the answer is $2/n$ since some pairs may still commute in nonabelian group.
I also noticed that the probability also depends on $x$, because, if $x=e$, you must choose $a,a^{-1}$ as a pair, so answer is $1/n$ regardless of $G$ is abelian or not.
If we denote this probability as $P_x(G)$, I think $1/n\leq P_x(G)\leq 2/n$.
Any further result will be appreciated.
As  Geoff Robinson request let me clarify what I mean,
Let $w\in GxG$ i,e, $w=(a,b)$ let  say that $w$ know answer if $ab=x$ or $ba=x$.
What is the probability that $w$ know the answer?

REPLY [3 votes]: One could equally ask for the probability with ordered or unordered pairs, with different results.
It suffices to count the number of pairs $a,b$ satisfying $x=ab\vee x=ba$, where $x\in G$ is fixed.
Say we wish to count ordered pairs of not necessarily distinct elements. Notice the equivalence $x=ab\vee x=ba\iff b=a^{-1}x\vee b=xa^{-1}$. If we naively count two $b$s for each $a\in G$ be overcounting by one for each $a$ satisfying $a^{-1}x=xa^{-1}$, the number of which is $|C_G(x)|$, where $C_G(x)$ is the centralizer of $x$. So we conclude the number of pairs is $2|G|-|C_G(x)|$.
The corresponding probability is $$P=\frac{2|G|-|C_G(x)|}{|G|^2}. \tag{ordered}$$
Define $\sqrt{x}:=\{a\in G:x=a^2\}$, the set of "square roots" of $x$. Let $\Pi:=(x=ab\vee x=ba)$.
Suppose we wish to count the unordered pairs of not necessarily distinct elements satisying $\Pi$; say there are $N$ such pairs. If we take $N$ and subtract $|\sqrt{x}|$ we will have the number of unordered pairs of distinct elements satisfying $\Pi$. If we then multiply by two we will have the number of ordered pairs of distinct elements satisfying $\Pi$. If we then add on $|\sqrt{x}|$ we will have the number of ordered pairs of not necessarily distinct elements satisfying $\Pi -$ we already know this number. Therefore,
$$2\left(N-|\sqrt{x}|\right)+|\sqrt{x}|=2|G|-|C_G(x)|\iff N=|G|+\frac{|\sqrt{x}|-|C_G(x)|}{2}.$$
We wound up proving $|C_G(x)|\equiv|\sqrt{x}|$ mod $2$. The total number of unordered pairs of not necessarily distinct elements of $G$ is $(|G|^2+|G|)/2$. Therefore the corresponding probability is
$$P=\frac{2|G|+|\sqrt{x}|-|C_G(x)|}{|G|^2+|G|}. \tag{unordered}$$
If you force the elements to be distinct, the probabilities then become
$$P=\frac{2|G|-|\sqrt{x}|-|C_G(x)|}{|G|^2-|G|}, \tag{distinct}$$
for both ordered and unordered pairs.