The given differential equation is ( xy' + y = x ).
This is a first-order linear differential equation. We can solve it using a couple of common methods.
Method 1: Recognizing the Left Side as a Product Rule Derivative
Observe the left-hand side (LHS) of the equation: ( xy' + y ).
Recall the product rule for differentiation: (\frac{d}{dx}(u(x)v(x)) = u'(x)v(x) + u(x)v'(x)).
If we let (u(x) = x) and (v(x) = y(x)), then (u'(x) = 1) and (v'(x) = y').
So, (\frac{d}{dx}(xy) = (1)y + x(y') = y + xy').
This perfectly matches the LHS of our differential equation.
Therefore, we can rewrite the equation as:
( \frac{d}{dx}(xy) = x )
Now, we integrate both sides with respect to (x):
( \int \frac{d}{dx}(xy) dx = \int x dx )
( xy = \frac{x^2}{2} + C )
where C is the constant of integration.
Finally, solve for y (assuming (x \neq 0)):
( y = \frac{x}{2} + \frac{C}{x} )
This is the general solution to the differential equation.
Method 2: Using an Integrating Factor
A first-order linear differential equation has the standard form (y' + P(x)y = Q(x)).
First, we rewrite the given equation (xy' + y = x) in this standard form by dividing by (x) (assuming (x \neq 0)):
( y' + \frac{1}{x}y = 1 )
Here, (P(x) = \frac{1}{x}) and (Q(x) = 1).
The integrating factor (IF) is given by (I(x) = e^{\int P(x) dx}).
( \int P(x) dx = \int \frac{1}{x} dx = \ln|x| )
So, the integrating factor is ( I(x) = e^{\ln|x|} = |x| ).
We can choose (I(x) = x) (or (I(x) = -x); the choice usually doesn't affect the final family of solutions, as the constant gets absorbed. Let's use (I(x)=x), which is valid for (x>0). If (x<0), we'd use (I(x)=-x), leading to (-xy = -x^2/2 + C'), which is equivalent). For simplicity, we typically use (x).
Multiply the standard form equation by the integrating factor (x):
( x \left( y' + \frac{1}{x}y \right) = x(1) )
( xy' + y = x )
The left side should now be the derivative of ((I(x) \cdot y)):
( \frac{d}{dx}(xy) = xy' + y )
This confirms our integrating factor is correct and brings us back to the same point as in Method 1.
So, we have:
( \frac{d}{dx}(xy) = x )
Integrating both sides with respect to (x):
( \int \frac{d}{dx}(xy) dx = \int x dx )
( xy = \frac{x^2}{2} + C )
Solving for y (assuming (x \neq 0)):
( y = \frac{x}{2} + \frac{C}{x} )
Checking the solution:
If (y = \frac{x}{2} + \frac{C}{x}), then (y' = \frac{1}{2} - \frac{C}{x^2}).
Substitute these into the original equation (xy' + y = x):
( x \left( \frac{1}{2} - \frac{C}{x^2} \right) + \left( \frac{x}{2} + \frac{C}{x} \right) = x )
( \frac{x}{2} - \frac{C}{x} + \frac{x}{2} + \frac{C}{x} = x )
( \frac{x}{2} + \frac{x}{2} = x )
( x = x )
The solution is correct.
Note on x=0:
The original equation is (xy' + y = x). If (x=0), the equation becomes (0 \cdot y' + y = 0), which implies (y=0).
Looking at our general solution (y = \frac{x}{2} + \frac{C}{x}), for (y(0)=0) to hold, we cannot directly substitute (x=0) unless (C=0).
If (C=0), then (y = \frac{x}{2}). For this particular solution, (y(0) = 0), and it is valid for all (x).
For any other value of (C \neq 0), the solution has a singularity at (x=0). The solution is typically considered on intervals that do not include (x=0) (e.g., (x > 0) or (x < 0)).
Conclusion:
The general solution to the differential equation ( xy' + y = x ) is
( y = \frac{x}{2} + \frac{C}{x} )
where C is an arbitrary constant, valid for (x \neq 0). The particular solution (y=x/2) (when C=0) is valid for all x.