Section 2.7 Nonhomogeneous ODEs
y” + p(x)y’ + q(x)y = r(x)

eqn=y''[x]+y[x]==0.001 x^2

DSolve[eqn,y[x],x]

sol=DSolve[{eqn,y[0]==0,y'[0]==1.5},y,x]

f[x_]:=y[x] /. sol

Plot[{f[x],-0.002+0.001 x^2},{x,0,40}]

eqn=y''[x]+3 y'[x]+2.25 y[x]==-10 Exp[-1.5 x]

DSolve[eqn,y[x],x]

Factor[%]

sol=DSolve[{eqn,y[0]==1,y'[0]==0},y[x],x]

g[x_]:=y[x] /. sol

Plot[g[x],{x,0,6}]

eqn=y''[x] + 2y'[x] + 5y[x]==Exp[0.5 x] + 40 Cos [10x] - 190 Sin [10x]

eqnh=yh''[x] + 2yh'[x] + 5yh[x]==0

DSolve[eqnh,yh[x],x]

Factor[%]

DSolve[eqn,y[x],x]

Simplify[%]

sol=DSolve[{eqn,y[0]==0.16, y'[0]==40.08},y[x],x]

FullSimplify[sol]

sol=DSolve[{eqn,y[0]==0.16, y'[0]==40.08},y,x]

f[x_]:=y[x] /.sol

Plot[f[x],{x,0,8}]