Question: I want to solve the following linear differential equation (initial value problem):

$$t\dot{x}(t)+3x(t)=-\frac{1}{t^2+1}; x(1)=\frac{\pi}{4}$$

I first tried to solve the homogeneous diff. eq.

$$t\dot{x}(t)+3x(t)=0$$
$$x(t)=C\exp(-\int\frac{b(t)}{a(t)})dt)\iff x(t)=C\exp(-3\ln(t)+k)$$ 

Variation of parameters:

$$x(t)=f(t)\exp(-3\ln(t)+k)$$

$$\implies t\cdot f'(t)\exp(-3\ln(t)+k)=-\frac{1}{t^2+1}\iff f'(t)=-\frac{1}{t^3+t}\cdot \frac{1}{\exp(-3\ln(t)+k)} $$

$$\iff f(t)=\int -\frac{1}{t^3+t}\cdot \frac{1}{\exp(-3\ln(t)+k)} dt$$

This looks wrong because mathematica gives me the solution

$$x(t)=\frac{c\_1}{t^3}+\frac{\arctan(t)}{t^3}-\frac{1}{t^2}$$

I don't see how my solution will look anything like this. Am I making a mistake somewhere?

Also, I want to find the interval of validity but I am not exactly sure what that is. Is it like the domain where I have to check for values that would make my solution undefined?

Answer: 
You first probably need to realize that $\exp{(-3 \ln{t})} = 1/t^3$.

You can see where the solution comes from by simply multiplying through by $t^2$:

$$t^3 \dot{x} + 3 t^2 x = -\frac{t^2}{1+t^2} = \frac1{1+t^2}-1$$

or

$$\frac{d}{dt} (t^3 x) = \frac1{1+t^2}-1$$

Hopefully that makes the solution clear.
<http://mathworld.wolfram.com/IntegratingFactor.html>

You need to understand this technique. This is the general solution to all first order linear ordinary differential equations.

VERY IMPORTANT: Don't forget the arbitrary constant of integration.