Solve $y’+ \frac{y}{t}=3\cos(t)$ I’m trying to Solve $y’+ \frac{y}{t}=3\cos(t)$ .
My Try :
Solving the homogeneous equation:
$y_h \rightarrow  y’=-\frac{y}{t} \rightarrow y=-C \cdot t$
Solving the p equation :
Assuming :
$y=-t \cdot C(t)$
We get :
$y’=-C(t)-t \cdot C(t)’$
I’ll plug these in the equation:
$y_p \rightarrow -C(t)-t \cdot C(t)’ - C(t) =3\cos(t)$
Which I just get back to :
$ -t\cdot C(t)’-2C(t)=3\cos(t)$
Which I’m not able to solve for C(t) .
I would like to get an idea of what I’m doing wrong and an idea of the solution.
 A: HINT
I would recommend you to multiply both sides by $t$:
\begin{align*}
y' + \frac{y}{t} = 3\cos(t) & \Longleftrightarrow ty' + y = 3t\cos(t)\\\\
& \Longleftrightarrow (ty)' = 3t\cos(t)
\end{align*}
Can you take it from here?
EDIT
If we integrate by parts, we achieve the desired result:
\begin{align*}
ty & = \int 3t\cos(t)\mathrm{d}t\\
& = 3t\sin(t) - 3\int\sin(t)\mathrm{d}t\\\
& = 3t\sin(t) + 3\cos(t) + c
\end{align*}
A: We have the inhomogeneous linear differential equation:
$$
y'(t) + p(t) y(t) = q(t),\quad\quad\quad\quad(1)
$$
where $p(t) = \dfrac{1}{t}$ and $q(t) = 3 \cos(t)$. Solution of (1) can be represented in an exact analytical form
$$
y(t) = \exp\left(-\int\limits_{t_0}^t p(\tau) d\tau\right) \left(y_0 + \int\limits_{t_0}^{t} q(\tau) \exp\left(\int\limits_{t_0}^\tau p(\xi) d\xi\right) d\tau\right),\quad\quad\quad\quad(2)
$$
where $t_0$ is any constant form the domain of definition, $y_0$ is the constant of integration.
Let us choose $t_0 = 1$ and calculate (2)
$$
y(t) = \frac{3 t \sin (t)+3 \cos (t)+y_0-3 (\sin (1)+\cos (1))}{t}
$$
or
$$
y(t) = \frac{3 t \sin (t)+3 \cos (t)+ C}{t}
$$
where $C$ is an arbitrary real constant.
A: $$y’+ \frac{y}{t}=3cos(t)$$
Solve the homogeneous DE:
$$y’+ \frac{y}{t}=0$$
$$\dfrac {y'}{y}=-\dfrac 1t$$
$$(\ln y)'=-\dfrac 1t$$
$$\ln y =-\ln t+C$$
$$y_h(t)=\dfrac Ct$$
Solve the inhomogeneous DE now.
$$y(t)=\dfrac {C(t)}t$$
$$y’+ \frac{y}{t}=3cos(t)$$
$$\dfrac {tC'-C}{t^2}+ \frac{C}{t^2}=3cos(t)$$
This DE is separable.
$$C'=3tcos(t)$$
Integrate.
$$C(t)=3t\sin(t)+3\cos t +c$$
A: Although all answers are correct, I would like to elaborate on the OP's mistake and why (IMHO) it has occurred.
The homogeneous equation is:
$$
y'=-\frac{y}{t}
$$
It is obviously separable, but let us do it very carefully using the Leibniz notation:
$$
\frac{dy}{dt}=-\frac{y}{t}
$$
so that
$$
\frac{dy}{y}=-\frac{dt}{t}
$$
which, after integration, leads us to
$$
\ln y=-\ln t +C
$$
This equation is solved for $y$ by applying the exponential:
$$
\begin{aligned}
y&=e^{-\ln t +C}\\&=e^C\,e^{-\ln t}\\&=e^C\,e^{\ln t^{-1}}\\&=e^C\,t^{-1}
\end{aligned}
$$
So the mistake is a quick and wrong assumption that $-\ln t=\ln( -t)$.
