1 STEP: solve the homogeneous equation.
x2⋅dxdy=−2xy∣∣⋅yx2dx⟶ydy=−2⋅xdx⟶
∫ydy=−2⋅∫xdx⟶ln∣y∣=−2⋅ln∣x∣+ln∣C∣⟶
yhom(x)=x2C
2 STEP: solve the inhomogeneous equation.
We use the constant variation method
y(x)=x2C(x)⟶dxdy=x2C′(x)−2⋅x3C(x)
Substitute the found derivative into the initial equation
x2⋅dxdy=−2xy⟶x2⋅(x2C′(x)−2⋅x3C(x))=−2x⋅x2C(x)+cos(x)⟶
C′(x)−2⋅xC(x)=−2⋅xC(x)+cos(x)⟶
C′(x)=cos(x)⟶C(x)=sin(x)+C1
Conclusion,
y(x)=x2sin(x)+C1
It remains to determine the integration constant, for this we use the initial condition:
y(π)=0⟶0=π2C1+sin(π)⟶0=π2C1⟶C1=0
ANSWER
y(x)=x2sin(x)
Comments