**Question:** is there any example of a finitely presented (or at least finitely generated) group $G$ with an infinite cyclic subgroup $C \leqslant G$ such that the word problem in $G$ is solvable but the membership problem for $C$ in $G$ is unsolvable?


I would guess that such examples should exist, since otherwise amalgams and HNN-extensions of f.p. groups with solvable word problem along cyclic subgroups would again have solvable word problem. But using such free constructions one could (possibly?) produce a group with unsolvable word problem, starting with a group for which the word problem is solvable...



Membership problem for cyclic subgroups
@Ashot: Finitely presented examples exist. It is in our paper with Olshanskii, Olshanskii, A. Yu.; Sapir, M. V., Length functions on subgroups in finitely presented groups. Groups—Korea '98 (Pusan), 297–304, de Gruyter, Berlin, 2000. 


An easier construction is this. Take the free Abelian group $A$ with generators $x\_i, i=0,1,...$. Consider an injective recursive function $\mathbb{N}\to \mathbb{N}$ with non-recursive image $f(n)$. 
Impose the following relations on $A$:
$x\_{f(n)}=x\_0^{n!}, n=1,2,...$. The word problem in the resulting (infinitely generated) group $A\_f$ is solvable. Indeed, consider any word $w=x\_{i\_1}^{k\_1}...x\_{i\_m}^{k\_m}$, $i\_1\lt i\_2\lt...$. That word is equal to 1 if and only if each $i\_s$ is of the form $f(n\_s)$ for some $n$ and $k\_1n\_1!+k\_2n\_2!+...=0$. That means all $n\_i$ cannot be much bigger than $\max |k\_i|$. Thus checking $w=1$ requires finite number of calculations of the function $f(n)$, so it is decidable. On the other hand the membership problem of $x\_m$ into $\langle x\_0\rangle$ is clearly undecidable since $f$ has non-recursive image. 


Now use Clapham's version of Higman's embedding and embed $A\_f$ into a finitely presented group $G$ with decidable word problem. Given $i$, one can recursively find a word in $G$ representing $x\_i$. Thus the membership problem in the cyclic subgroup $\langle x\_0\rangle$ of $G$ is undecidable. 


 **Update**  Here is how to construct an injective recursive function with non-recursive image. Using Matiyasevich's theorem, find a polynomial $p(x\_1,...,x\_s)$ such that the solvability of the equation
$a=p(x\_1,...,x\_s)$ is undecidable. Now take any Turing machine $M$ that computes $p(x\_1,...,x\_n)$ in binary. Add a new tape to $M$ and during the computation of $M$ write down the history of computation (i.e. numbers of the executed commands in binary, separated by number 3) on the new tape. When the machine stops, interpret the word written on the extra tape and the value of $p(x\_1,...,x\_s)$ as one number $f(x\_1,...,x\_s)$ (say, write first the value of $p$, then number 4, then the history, view the whole number as written in the 5-ary system). The function $n$ is clearly recursive and injective because the history determines the values of $x\_1,...,x\_s$ (make the machine scan the input before it computes $p$). It is also clear that the image of $n$ is not recursive. To make $n$ a function in one variable, precompose it with a (Goedel) function that enumerates ${\mathbb Z}^s$. 


