When is a system called linear? In real time systems / control engineering we have to solve exercises like this:

Check if the following systems are linear:
1) $0.2\ddot{x}(t) - (t^2 + 2t -1) x(t) = 3 w(t)$
2) $\ddot{x}(t) + \dot{x}(t) + x(t) = w(t)$

A student created the following solution:

1) $$\begin{align}&0.2 \frac{d^2 (h x_1 (t) + l x_2(t))}{d t^2} - (t^2 +2t-1)(h x_1(t) + l x_2(t))\\
=&0.2 h \ddot{x_1}(t) - (t^2 + 2t-1) h x_1(t) + 0.2 l \ddot{x}_2(t) - (t^2 + 2t-1) l x_2(t)\\
=& h w_1(t) + l w_2(t) \Rightarrow \text{linear}\end{align}$$
2) not linear because of +1
see Laplace: $s^2 X(s) + s X(s) + X(s) + \frac{1}{s} = W(1) \Rightarrow \frac{X(s)}{W(s)} = \frac{1}{s^2 + s +1} - \frac{1}{s(s^2 + s + 1) W(s)} \Rightarrow$ no transfer function $\Rightarrow$ not linear.

Could somebody please explain how one can decide for arbitrary systems if they are linear?
I don't understand the steps which were done in (1) either.
 A: A function $L$ acting on some collection of "vectors" is called linear if for any scalar $c$ and two "vectors" $x_1,x_2$, we have $L(cx_1+x_2)=cL(x_1)+L(x_2)$. In other words, $L$ commutes with scalar multiplication and distributes over vector addition. In differential equations these are usually functions themselves, but I call them "vectors" because they are elements of some vector space, which means that many of the tools from linear algebra are applicable in this setting.
An equation is called linear if it is of the form $Lx=y$ for some linear function $L$, some unknown "vector" $x$, and some known "vector" $y$ (which, because it's known, cannot have any explicit dependence on $x$).
Here, unless $w$ implicitly depends on $x$ in some fashion that you haven't specified, both of your equations are linear. That's because differentiation is linear, multiplication by a fixed function of $t$ is linear, and sums of linear functions are linear.
I don't really understand why you would need to calculate the transfer function to determine if your equation is linear or not.
A: All differential equations that can be written on the form
$$f_0(t)x(t)+\sum\limits_{j=1}^n f_j (t)\frac{\mathrm{d}^jx(t)}{\mathrm{d}t^j} = g(t) $$
are linear ordinary differential equations.
If $f_0(t),f_1(t),...,f_n(t)$ are all constant (with respect to $t$), we call it a differential equation with constant coefficients. If $g(t)$ is identical to $0$, then we call the differential equation for homogeneous, otherwise inhomogeneous/nonhomogeneous. If $f_n(t)$ is not identical to $0$ we call the differential equation to be of order $n$.
Example 1.
We have the differential equation
$$0.2 \cdot\frac{\mathrm{d}^2x(t)}{\mathrm{d}t^2} - (t^2+2t-1) x(t) = 3w(t).$$
This is an inhomogeneous, linear ordinary differential equation (of order $2$) with variable coefficients. This is because it is of the given form with
$$f_0(t) = -(t^2+2t-1),\quad f_1(t) = 0,\quad f_2(t) = 0.2 $$
and $g(t) = 3w(t).$
Example 2.
We have the differential equation
$$\frac{\mathrm{d}^2x(t)}{\mathrm{d}t^2}+\frac{\mathrm{d}x(t)}{\mathrm{d}t} + x(t) = w(t).$$
This is an inhomogenous, linear ordinary differential equation (of order $2$) with constant variables, because it is of the given form and 
$f_0(t) = f_1(t) = f_2(t) = 1$
are constants, and $g(t) = w(t)$.
Therefore we conclude that both of the given differential equations are linear.
