To solve the differential equation
\[
(x \, dy - y \, dx) \, y \sin\left(\frac{y}{x}\right) = (y \, dx + x \, dy) \, x \cos\left(\frac{y}{x}\right),
\]
we will follow these steps:
### Step 1: Rewrite the Equation
We start with the given equation:
\[
(x \, dy - y \, dx) \, y \sin\left(\frac{y}{x}\right) = (y \, dx + x \, dy) \, x \cos\left(\frac{y}{x}\right).
\]
### Step 2: Expand Both Sides
Expanding both sides gives:
\[
x y \sin\left(\frac{y}{x}\right) \, dy - y^2 \sin\left(\frac{y}{x}\right) \, dx = x y \cos\left(\frac{y}{x}\right) \, dx + x^2 \cos\left(\frac{y}{x}\right) \, dy.
\]
### Step 3: Rearranging the Terms
Rearranging the terms leads to:
\[
\left(x y \sin\left(\frac{y}{x}\right) - x^2 \cos\left(\frac{y}{x}\right)\right) dy = \left(x y \cos\left(\frac{y}{x}\right) + y^2 \sin\left(\frac{y}{x}\right)\right) dx.
\]
### Step 4: Separate Variables
Now we can separate the variables \(dy\) and \(dx\):
\[
\frac{dy}{dx} = \frac{x y \cos\left(\frac{y}{x}\right) + y^2 \sin\left(\frac{y}{x}\right)}{x y \sin\left(\frac{y}{x}\right) - x^2 \cos\left(\frac{y}{x}\right)}.
\]
### Step 5: Introduce Substitution
Let \(v = \frac{y}{x}\), then \(y = vx\) and \(dy = v \, dx + x \, dv\). Substitute these into the equation:
\[
\frac{dy}{dx} = v + x \frac{dv}{dx}.
\]
### Step 6: Substitute and Simplify
Substituting \(y = vx\) into the equation gives:
\[
v + x \frac{dv}{dx} = \frac{x(vx) \cos(v) + (vx)^2 \sin(v)}{x(vx) \sin(v) - x^2 \cos(v)}.
\]
### Step 7: Simplify Further
This simplifies to:
\[
x \frac{dv}{dx} = \frac{v^2 \sin(v) + v \cos(v)}{v \sin(v) - \cos(v)} - v.
\]
### Step 8: Rearranging Again
Rearranging gives:
\[
x \frac{dv}{dx} = \frac{v^2 \sin(v) + v \cos(v) - v(v \sin(v) - \cos(v))}{v \sin(v) - \cos(v)}.
\]
### Step 9: Integrate
Separate variables and integrate both sides:
\[
\int \frac{v \sin(v) - \cos(v)}{2v \cos(v)} dv = \int \frac{dx}{x}.
\]
### Step 10: Final Solution
After integrating and simplifying, we arrive at:
\[
\sec\left(\frac{y}{x}\right) = kxy,
\]
where \(k\) is a constant of integration.