3.1. ** Let $\left\{a_{n}\right\}$ be an arithmetic sequence with common difference $d, d \neq 0$, and $\left\{b_{n}\right\}$ be a geometric sequence with common ratio $q$. Given that $a_{1}=b_{1}, a_{3}=b_{3}, a_{7}-b_{5}$. Find the relationship between $n$ and $m$ when $a_{n}=b_{m}$.
Let $a_{1}=b_{1}=a$, then $a_{n}=a+(n-1) d, b_{m}=a q^{m-1}$. From the given, we have
$$
\left\{\begin{array}{l}
a+2 d=a q^{2} \\
a+6 d=a q^{4} .
\end{array}\right.
$$

Clearly, $a \neq 0$. By (1) $\times 3-$ (2) we get $2 a=3 a q^{2}-a q^{4}$, which simplifies to $q^{4}-3 q^{2}+2=0$. Therefore, $q^{2}=1$ or $q^{2}=2$. If $q^{2}=1$, then from (1) we get $d=0$, which is a contradiction; if $q^{2}=2$, we get $d=\frac{a}{2}$.
Thus, $a_{n}=b_{m}$ if and only if $a+(n-1) \frac{a}{2}=a q^{m-1}$. That is,
$$
1+\frac{n-1}{2}=q^{m-1}=\left(q^{2}\right)^{(m-1) / 2}=2^{(m+1) / 2} .
$$

Therefore, $a_{n}=b_{m}$ only when $m$ is an odd number, and $n=2^{(m+1) / 2}-1$.