We are given the differential equation:
\[
y = \left( x - y \frac{dx}{dy} \right) \sin\left( \frac{x}{y} \right), \, y > 0 \, \text{and} \, x(1) = \frac{\pi}{2}.
\]
Rearrange the equation to solve for \( \frac{dx}{dy} \):
\[
y = x \sin\left( \frac{x}{y} \right) - y \frac{dx}{dy} \sin\left( \frac{x}{y} \right),
\]
\[
y + y \frac{dx}{dy} \sin\left( \frac{x}{y} \right) = x \sin\left( \frac{x}{y} \right),
\]
\[
\frac{dx}{dy} \sin\left( \frac{x}{y} \right) = \frac{x}{y} \sin\left( \frac{x}{y} \right) - 1.
\]
Now, simplify and integrate the equation. Applying the initial condition \( x(1) = \frac{\pi}{2} \), we solve for \( \cos(x(2)) \).
After the solution and substitution, we find that:
\[
\cos(x(2)) = 2(\log 2)^2 - 1.
\]