We are given the differential equation:
\[
\frac{1}{2} \frac{dy}{dx} + \frac{y}{x} = 1
\]
Step 1:
Multiply the entire equation by 2 to simplify:
\[
\frac{dy}{dx} + \frac{2y}{x} = 2
\]
Step 2:
Recognize the equation as a linear first-order ODE. This is in the form:
\[
\frac{dy}{dx} + P(x) y = Q(x)
\]
Where \( P(x) = \frac{2}{x} \) and \( Q(x) = 2 \).
Step 3:
Find the integrating factor:
The integrating factor \( \mu(x) \) is given by:
\[
\mu(x) = e^{\int P(x) \, dx} = e^{\int \frac{2}{x} \, dx} = e^{2\ln x} = x^2
\]
Step 4:
Multiply through by the integrating factor:
\[
x^2 \frac{dy}{dx} + 2xy = 2x^2
\]
Now, the left-hand side is the derivative of \( x^2 y \):
\[
\frac{d}{dx} (x^2 y) = 2x^2
\]
Step 5:
Integrate both sides:
\[
x^2 y = \int 2x^2 \, dx = \frac{2x^3}{3} + C
\]
Thus:
\[
y = \frac{2x}{3} + \frac{C}{x^2}
\]
Step 6:
Use the initial condition to find \( C \):
We are given that \( y = \frac{2}{3} \) when \( x = 1 \):
\[
\frac{2}{3} = \frac{2(1)}{3} + \frac{C}{1^2}
\]
\[
\frac{2}{3} = \frac{2}{3} + C
\]
So, \( C = 0 \).
Step 7:
Find the value of \( y \) at \( x = 3 \):
Substitute \( C = 0 \) into the equation for \( y \):
\[
y = \frac{2x}{3}
\]
Now, evaluate at \( x = 3 \):
\[
y = \frac{2(3)}{3} = 2
\]
Thus, the value of \( y \) at \( x = 3 \) is:
\[
\boxed{2}
\]