For a positive integer $n$, let $S(n) $be the set of complex numbers $z = x+iy$  ($x,y \in R$) with $ |z| = 1$ satisfying
$(x+iy)^n+(x-iy)^n = 2x^n$ .
(a) Determine $S(n)$ for $n = 2,3,4$.
(b) Find an upper bound (depending on $n$) of the number of elements of $S(n)$ for $n > 5$.
Given the problem, we need to determine the set \( S(n) \) for \( n = 2, 3, 4 \) and find an upper bound for the number of elements in \( S(n) \) for \( n > 5 \).

### Part (a): Determine \( S(n) \) for \( n = 2, 3, 4 \)

1. **For \( n = 2 \):**

   We start with the equation:
   \[
   (x + iy)^2 + (x - iy)^2 = 2x^2
   \]
   Expanding both sides, we get:
   \[
   (x^2 - y^2 + 2ixy) + (x^2 - y^2 - 2ixy) = 2x^2
   \]
   Simplifying, we obtain:
   \[
   2(x^2 - y^2) = 2x^2
   \]
   Dividing both sides by 2:
   \[
   x^2 - y^2 = x^2
   \]
   This implies:
   \[
   y^2 = 0 \implies y = 0
   \]
   Since \( |z| = 1 \), we have \( x^2 + y^2 = 1 \). With \( y = 0 \), it follows that:
   \[
   x^2 = 1 \implies x = \pm 1
   \]
   Therefore, \( S(2) = \{1, -1\} \).

2. **For \( n = 3 \):**

   We start with the equation:
   \[
   (x + iy)^3 + (x - iy)^3 = 2x^3
   \]
   Expanding both sides, we get:
   \[
   (x^3 + 3x^2(iy) + 3x(iy)^2 + (iy)^3) + (x^3 + 3x^2(-iy) + 3x(-iy)^2 + (-iy)^3) = 2x^3
   \]
   Simplifying, we obtain:
   \[
   x^3 + 3x^2(iy) - 3xy^2 - y^3i + x^3 - 3x^2(iy) - 3xy^2 + y^3i = 2x^3
   \]
   Combining like terms:
   \[
   2x^3 - 6xy^2 = 2x^3
   \]
   Subtracting \( 2x^3 \) from both sides:
   \[
   -6xy^2 = 0
   \]
   This implies:
   \[
   y^2 = 0 \implies y = 0
   \]
   Since \( |z| = 1 \), we have \( x^2 + y^2 = 1 \). With \( y = 0 \), it follows that:
   \[
   x^2 = 1 \implies x = \pm 1
   \]
   Therefore, \( S(3) = \{1, -1\} \).

3. **For \( n = 4 \):**

   We start with the equation:
   \[
   (x + iy)^4 + (x - iy)^4 = 2x^4
   \]
   Expanding both sides, we get:
   \[
   (x^4 + 4x^3(iy) + 6x^2(iy)^2 + 4x(iy)^3 + (iy)^4) + (x^4 + 4x^3(-iy) + 6x^2(-iy)^2 + 4x(-iy)^3 + (-iy)^4) = 2x^4
   \]
   Simplifying, we obtain:
   \[
   x^4 + 4x^3(iy) - 6x^2y^2 - 4xy^3i + y^4 + x^4 - 4x^3(iy) - 6x^2y^2 + 4xy^3i + y^4 = 2x^4
   \]
   Combining like terms:
   \[
   2x^4 - 12x^2y^2 + 2y^4 = 2x^4
   \]
   Subtracting \( 2x^4 \) from both sides:
   \[
   -12x^2y^2 + 2y^4 = 0
   \]
   Factoring out \( 2y^2 \):
   \[
   2y^2(-6x^2 + y^2) = 0
   \]
   This implies:
   \[
   y^2 = 0 \quad \text{or} \quad y^2 = 6x^2
   \]
   If \( y^2 = 0 \), then \( y = 0 \). Since \( |z| = 1 \), we have \( x^2 + y^2 = 1 \). With \( y = 0 \), it follows that:
   \[
   x^2 = 1 \implies x = \pm 1
   \]
   If \( y^2 = 6x^2 \), then substituting into \( x^2 + y^2 = 1 \):
   \[
   x^2 + 6x^2 = 1 \implies 7x^2 = 1 \implies x^2 = \frac{1}{7} \implies x = \pm \frac{1}{\sqrt{7}}
   \]
   Substituting \( x = \pm \frac{1}{\sqrt{7}} \) into \( y^2 = 6x^2 \):
   \[
   y^2 = 6 \left( \frac{1}{7} \right) = \frac{6}{7} \implies y = \pm \sqrt{\frac{6}{7}}
   \]
   Therefore, \( S(4) = \{1, -1, \frac{1}{\sqrt{7}} + i\sqrt{\frac{6}{7}}, \frac{1}{\sqrt{7}} - i\sqrt{\frac{6}{7}}, -\frac{1}{\sqrt{7}} + i\sqrt{\frac{6}{7}}, -\frac{1}{\sqrt{7}} - i\sqrt{\frac{6}{7}}\} \).

### Part (b): Find an upper bound for the number of elements of \( S(n) \) for \( n > 5 \)

To find an upper bound for the number of elements of \( S(n) \), we note that the equation:
\[
(x + iy)^n + (x - iy)^n = 2x^n
\]
is a polynomial equation of degree \( n \). The number of solutions to this equation is at most \( n \), as a polynomial of degree \( n \) has at most \( n \) roots.

Therefore, the upper bound for the number of elements of \( S(n) \) for \( n > 5 \) is \( n \).

The final answer is \( \boxed{ n } \)