A first-order linear equation has the form y′+p(x)y=q(x) on an interval where its coefficients are continuous. It need not be separable. Set μ(x)=exp(∫p(x)dx). Since μ′=pμ, multiplying gives (μy)′=μq, hence y=μ⁻¹(∫μq dx+C). Choose any convenient antiderivative for p; its integration constant only rescales μ and cancels from the solution. Apply initial data after integration, and keep any singular coefficient points outside the chosen interval.
For y′+2xy=x with y(0)=1, μ=e^(x²). Then (e^(x²)y)′=x e^(x²), whose integral is e^(x²)/2+C. Thus y=1/2+C e^(−x²), and the initial condition gives C=1/2. Direct substitution checks y′+2xy=x. The integrating factor makes the left side a product derivative; it is not an extra factor that remains multiplying the original right side in the final answer.
For ay″+by′+cy=r(x) with a nonzero, solve the characteristic equation aλ²+bλ+c=0 for the homogeneous part. Distinct real roots give two exponentials; a repeated root λ gives (C₁+C₂x)e^(λx); roots α±iβ give e^(αx)(C₁ cos βx+C₂ sin βx). The complete solution is y_h+y_p. A polynomial forcing suggests a polynomial particular trial; an exponential or sine/cosine forcing suggests the corresponding family, with enough coefficients to account for differentiation.
If a particular trial duplicates a homogeneous solution, it cannot produce the forcing: multiply by x once for a simple root, twice for a repeated root. For y″−3y′+2y=e^x, the naive Ke^x is annihilated. Trying Kxe^x gives −Ke^x, so y_p=−xe^x. Initial conditions determine the homogeneous constants only after adding y_p. Substitute the final function into the original equation to check signs and forcing; an initial-value check alone cannot verify the differential equation.