I cannot solve this Cauchy problem: $x'-\frac{x}{t}=t, x(1)=0$
$p(t)=-\frac{1}{t} \Rightarrow u(t)=e^{-\int\frac{1}{t}dt}=e^{-ln|t|}$
$x' \cdot e^{-ln|t|}-\frac{x}{t} e^{-ln|t|}=t\cdot e^{-ln|t|}$
$(xe^{-ln|t|})'=t\cdot e^{-ln|t|}$
$xe^{-ln|t|}=t+C$
$x(t)=1+\frac{C}{t}$
So, In short, I was doing this problem by multiplying each side with e taken to the power of integral of $\frac{1}{t}$ and I get the result as $x(t)=1+\frac{C}{t}.$ The answer is completely off, I should get $x=t^2-t, t>0.$
I would follow the procedure I learned in my ODE course and textbook.
1) Write out the general form of the first order linear ODE
$$\frac{dx}{dt}+P(t)x=Q(t)$$
You are given
$$\frac{dx}{dt}-\frac{x}{t}=t \implies P(t)=-\frac1t,~Q(t)=t$$
2) Find the integrating factor
$$\mu(t)=\text{exp}{\int P(t)dt}=\text{exp}\int-\frac1t dt=\text{exp}\big({-\ln|t|}\big)=\frac{1}{t}$$
3) Multiply your original equation by the integrating factor
$$\frac1t\frac{dx}{dt}-\frac{x}{t^2}=1 $$
4) Reduce to $\frac{d}{dt}$ on the LHS
$$\frac{d}{dt}(\frac1t x)=1$$
5) Integrate both sides with respect to $t$
$$\frac x t=t+C \implies x=t^2+Ct$$
6) Evaluate the initial condition of $x(1)=0$
$$x(1)=0\implies 0=1+c \implies C=-1$$
7) Solve for $x(t)$
$$x(t)=t^2-t$$
where $t>0$ follows directly from step 2. The integrating factor of $\frac{1}{t}$ is only defined for $t>0$.