Proof of linearity of a linear operator My course problem booklet (mathematics BSc, second year module in algebra, unpublished) has a question (I paraphrase),

Prove that the operator $D:=x\frac{\text{d}}{\text{d}x}$ on $C^\infty(\mathbb{R},\mathbb{R})$ is linear.

The first half of the proof in the solution booklet has,
\begin{aligned}
D[f_1(x)+f_2(x)]
& = x\frac{\text{d}}{\text{d}x}\left[f_1(x)+f_2(x)\right] && (1) \\
& = x\left(\frac{\text{d}}{\text{d}x}[f_1(x)]+\frac{\text{d}}{\text{d}x}[f_2(x)]\right) && (2) \\
& = x\frac{\text{d}}{\text{d}x}[f_1(x)] + x\frac{\text{d}}{\text{d}x}[f_2(x)] && (3) \\
& = D[f_1(x)] + D[f_2(x)] && (4)
\end{aligned}
My question is about the step from (2) to (3). What sort of thing is $x$ that it can distribute over $\frac{\text{d}}{\text{d}x}[f(x)]$? For instance, is it a function in $C^\infty(\mathbb{R},\mathbb{R})$? Is it an operator in $L(C^\infty(\mathbb{R},\mathbb{R}))$?
 A: $$x\frac{d}{dx}(f(x)+g(x))=x\frac{df(x)}{dx}+x\frac{dg(x)}{dx}=D(f(x))+D(g(x))$$
I think you are having trouble because you have not defined how the "operator" acts on a function.
$x\frac{d}{dx}(f(x))=x\frac{df(x)}{dx}$
That is $D(\sin(x))=x\frac{d(\sin(x))}{dx}=x\cos(x)$.
Even more clearly $D(f(x))=xf'(x)$ Now I think it should be clear.
And $D$ is a linear transformation from $C^{\infty}(\mathbb{R})$ to itself.
That is $D\in L(C^{\infty}(\mathbb{R}),C^{\infty}(\mathbb{R}))$.
Since you tagged as "self learning", let me give you some advice.
The space is $ C^{\infty}(\mathbb{R})$ so actually each smooth "function" is a vector. So it might help if you stop thinking of them as $f(x)$ and write them just as $f$. Now as to what are these functions and what they do....there you need to write as $f(x)=x$ or $f(x)=e^{x}$. Going a step further , this $D$ can be thought of also as just a "vector" in $L(C^{\infty}(\mathbb{R}),C^{\infty}(\mathbb{R}))$. That is $D$ is a linear transformation which takes as input a smooth function and gives you back as it's output the derivative of that function times $x$ which is also smooth as multiplication of smooth functions is smooth.
A: Let $V=C^{\infty}(\Bbb{R},\Bbb{R})$; this is a vector space over $\Bbb{R}$ (I hope you've already justified this). The definition of $D$ is that for each $f\in V$, $Df:\Bbb{R}\to\Bbb{R}$ is the function defined as $(Df)(x):= x\cdot f'(x)$. The usual calculus rules tell us that $Df\in V$, hence $D$ is a mapping $V\to V$. The question is whether it is linear, i.e if for all $c\in\Bbb{R}, f_1,f_2\in V$, we have $D(cf_1+f_2)=cD(f_1)+D(f_2)$? The answer is yes. Why? This is a question about functions, and equality of functions is defined pointwise. So fix any $x\in\Bbb{R}$. Then,
\begin{align}
[D(cf_1+f_2)](x)&= x\cdot (cf_1+f_2)'(x)\tag{i}\\
&=x\cdot \left(cf_1'(x)+f_2'(x)\right)\tag{ii}\\
&= c\cdot x\cdot f_1'(x)+ x\cdot f_2'(x)\tag{iii}\\
&= c\cdot D(f_1)(x) + D(f_2)(x)\tag{iv}\\
&=[c\cdot D(f_1)+ D(f_2)](x)\tag{v}
\end{align}

*

*(i) is by definition of $D$ acting on the function $cf_1+f_2$, and evaluating that at $x$.

*(ii) is by basic rules of derivatives.

*(iii) is by distributivity and commutativity of multiplication of real numbers (remember that $x,c,f_1'(x), f_2'(x)$ are all just numbers)

*(iv) is by definition of $D$ applied to $f_1$ and $f_2$, and then evaluated at $x$.

*(v) is the definition of scalar multiplication and addition of the functions $c\cdot D(f_1)+ D(f_2)$ is that function $\Bbb{R}\to\Bbb{R}$ whose value at any point $x\in\Bbb{R}$  is equal to the number given in (iv).

Finally, looking at (v), notice that we have proved this for all $x\in\Bbb{R}$, so by definition of equality of functions, $D(cf_1+f_2)=cD(f_1)+D(f_2)$. Finally, since $c\in\Bbb{R}, f_1,f_2\in V$ were arbitrary, this shows $D:V\to V$  is indeed a linear transformation.
A: $x$ is a number, so moving from (2) to (3) is just the simple distributive law.
A: OP answering own question.
On reflection, it seems to me that there are two different types of $x$ here. As I now see it, the $x$ in $D:=x\frac{\text{d}}{\text{d}x}$ is a linear operator in $L(C^\infty(\mathbb{R},\mathbb{R}))$ given by $f \mapsto xf$, while the $x$ in $f_1(x),f_2(x)$ is a number in $\mathbb{R}$.
If we write the argument in the form I used in the OP (call it form A), we have to accept that
\begin{aligned}
& \;\; D:C^\infty(\mathbb{R},\mathbb{R})\rightarrow C^\infty(\mathbb{R},\mathbb{R}) \\
\therefore & \;\; \text{for any } f_1,f_2 \text{ that } D \text{ can take as arguments, } f_1,f_2 \in C^\infty(\mathbb{R},\mathbb{R}) \\
\therefore & \;\; f_1,f_2:\mathbb{R}\rightarrow\mathbb{R} \\
\therefore & \;\; f_1(x),f_2(x)\in\mathbb{R} \\
\therefore & \;\; \frac{\text{d}}{\text{d}x}[f_1(x)] = \frac{\text{d}}{\text{d}x}[f_2(x)] = 0 \\
\therefore & \;\; D[f_1(x)+f_2(x)] = 0 \; \forall \; f_1,f_2 \in C^\infty(\mathbb{R},\mathbb{R}),
\end{aligned}
which is obviously not what we want.
I now write the argument as follows (form B):
\begin{aligned}
\left[D(f_1+f_2)\right](y)
& = \left[x\left(\frac{\text{d}}{\text{d}x}(f_1+f_2)\right)\right](y) && (i) \\
& = \left[x\left(\frac{\text{d}f_1}{\text{d}x}+\frac{\text{d}f_2}{\text{d}x}\right)\right](y), \text{ since } \frac{\text{d}}{\text{d}x} \in L(C^\infty(\mathbb{R},\mathbb{R})) \text{ is linear} && (ii) \\
& = \left[x\frac{\text{d}f_1}{\text{d}x}+x\frac{\text{d}f_2}{\text{d}x}\right](y), \text{ since } x \in L(C^\infty(\mathbb{R},\mathbb{R})) \text{ is linear} && (iii) \\
& = [D(f_1)+D(f_2)](y), \text{ as desired}. && (iv)
\end{aligned}
To be fair to the writer of the problem and solution, they used $y_1,y_2$ where I used $f_1(x),f_2(x)$ in the OP. I wanted to write these as functions in order to get at the point that puzzled me.
Comments are welcome, particularly from previous answerers @Lukas, @5xum and @Mr.Gandalf Sauron
