Let $G$ be the dihedral group defined as the set of all formal symbols $x^iy^j$, $i=0,1$, $j=0,1,\ldots,n-1$, where $x^2=e$, $y^n=e$, $xy=y^{-1}x$.
EDIT - My proof is wrong .But i will be thankful to someone who help's me to identify where i was wrong in my proof (due to which i will learn more).
The following is my proof -
since $xy = y^{-1}x$
$yx=xy^{-1}$
$x^ay^b.x^iy^j$ = $(x^ay^{b-1}y)(xx^{i-1}y^j)$
=$(x^ay^{b-1}xy^{-1})(x^{i-1}y^j)$
=$(x^{a+1}y^{-b})(x^{i-1}y^j)$
=$(x^{a+1}y^{-b+1}y^{-1}x)({x^{i-2}y^j})$
=$(x^{a+1}y^{-b+1}xy)({x^{i-2}y^j})$
=$(x^{a+2}y^{b})(x^{i-2}y^j)$
Repeating the process $i$ times we will get final answer as -
$x^{a+i}y^{b+j}$
from above proof we can also conclude that centre of the given group $G$ is $G$ itself.
Can someone tell at which how i am wrong ?
$\textbf{True Concept:}$
If $n=1$ or $n=2$, then $D_{2n}$ is abelian and hence $\Bbb Z(D_{2n})=D_{2n}$. Suppose $n\geq 3$. By definition, we have $D_{2n}=\{a^ib^j: i=0,1, j=0,1,\cdots, n-1\}$ where $a$ is an element of order $2$, $b$ is an element of order $n$ and $a,b$ are related by the relation $ba=ab^{-1}$. It then follows that $b^2 a= bab^{-1}=ab^{-2}$ and in general $$b^ra=ab^{-r}, \ \ \ \ \ \ \ \ \ \ (1)$$ for all integers $r \geq 0$. Now, since $a$ and $b$ together generate $D_{2n}$, an element of $D_{2n}$ is in the center if and only if it commutes with both $a$ and $b$. So $x=a^ib^j \in Z(D_{2n})$ if and only if $xa=ax$ and $xb=bx$. The condition $xb=bx$ gives us $a^ib^{j+1}=ba^ib^j$ and thus $$a^ib=ba^i. \ \ \ \ \ \ \ \ \ \ (2)$$ Clearly we can have $i=0$ in $(2)$ but can we have $i=1$ ? The answer is no because if $i=1$, then $(2)$ gives $ab=ba$ and we know from $(1)$ that $ba=ab^{-1}$. But then $ab=ab^{-1}$ and so $b^2=1$, which is not possible because $n \geq 3$. So $i=0$ and thus $x=b^j$. The condition $xa=ax$ then becomes $b^ja=ab^j$ and hence, by $(1)$, $ab^{-j}=ab^j$. Therefore $$b^{2j}=1. \ \ \ \ \ \ \ \ \ \ \ \ \ (3)$$
Hence, since $o(b)=n$, we get from $(3)$ that $n \mid 2j$. Thus either $j=0$ or $2j=n$ because $0 \leq j \leq n-1$. If $j=0$, then $x=b^j=1$. If $2j=n$, then $n$ is even and $x=b^j = b^{n/2}$. So we have proved
$$ Z(D_{2n})= \begin{cases} D_{2n} & \text{if} \ \ n=1,2 \\ \{1\} & \text{if} \ \ n>2 \ \text{is odd} \\ \{1,b^{\frac{n}{2}} & \text{if} \ \ n>2 \ \text{is even} \end{cases} $$