Solving ODEs with non-homogeneous terms