A sufficient condition for linearity? If $f$ is a linear function (defined on $\mathbb{R}$), then for each $x$, $f(x) – xf’(x) = f(0)$. Is the converse true? That is, is it true that if $f$ is a differentiable function defined on $\mathbb{R}$ such that for each $x$, $f(x) – xf’(x) = f(0)$, then $f$ is linear?
 A: Let $g(x)=f(x)-f(0)$, then $g(x)=xg'(x)$ for all $x$. If $g(x)\neq0$, this means that
$$
\frac{\mathrm{d}}{\mathrm{d}x}\log(g(x))=\frac{1}{x}\tag{1}
$$
Solving $(1)$ equation yields
$$
\log(g(x))=\log(k)+\log(x)\tag{2}
$$
for some constant $k$ for either $x\in\mathbb{R}^+$ or $x\in\mathbb{R}^-$ (when $x<0$ or if $g(x)<0$ use $\log(-x)=\log(x)+\pi i$). Equation $(2)$ shows that if $g(x_0)\neq 0$ for some $x_0\neq0$, $g(x)\neq0$ for any $x$ with the same sign as $x_0$.  Exponentiating equation $(2)$ and replacing $f$ yields
$$
f(x)-f(0)=kx\tag{3}
$$
Thus, $f$ is linear on $\mathbb{R}^+$ and on $\mathbb{R}^-$.  However, the slope of $f$ can be different on $\mathbb{R}^+$ than it is on $\mathbb{R}^-$.
Now that I think about it, since $f$ is differentiable at $0$, we have
$$
\lim_{x\to0+}\frac{f(x)-f(0)}{x}=f'(0)=\lim_{x\to0-}\frac{f(x)-f(0)}{x}\tag{4}
$$
Thus, the slopes on $\mathbb{R}^+$ and $\mathbb{R}^-$ have to be the same.
As Andres Caicedo pointed out, and I have tried to account for, logs of negative numbers are problematic, as is $g(x)=0$.  $g(x)=0$ is a solution, but then $f(x)=f(0)$ is still linear.
A: Suppose $f$ is differentiable and satisfies your equation, $f(x)-xf'(x)=f(0)$.
[Edit: This is a revised answer. The previous one was terribly flawed.]
Note that $\displaystyle \frac{f(x)-f(0)}x=f'(x)$ for any $x\ne0$. This shows that $f'$ is differentiable, except perhaps at 0. Differentiating this equation, we obtain $f''(x)=\displaystyle \frac{xf'(x)-(f(x)-f(0))}{x^2}=0$.
If $f''$ is continuous (at 0) it follows that $f'$ is constant and therefore $f$ is linear.
In any case, the above shows that $f$ is linear in $(-\infty,0)$ and in $(0,\infty)$, and we are given that it is differentiable at 0. 
But then $f$ is linear: Say that $f(x)=ax+b$ for $x<0$ and $f(x)=cx+d$ for $x>0$. Then $f'(x)=a$ for $x<0$ and $f'(x)=b$ for $x>0$ and $f'(0)$ exists. Since derivatives satisfy the intermediate value theorem (see for example Rudin "Principles of Mathematical Analysis" Theorem 5.12), it follows that we must have $a=f'(0)=b$. Since differentiability implies continuity, it follows that $\displaystyle b=\lim_{x\to 0^-}f(x)=f(0)=\lim_{x\to0^+}f(x)=d$.
A: If $f\in C^2$ (it is twice differentiable, and $f''$ is continuous), then the answer is yes; I don't know if it's necessarily true without this hypothesis.
If $f(x)-xf'(x)=f(0)$ for all $x$, then 
$$f(x)=xf'(x)+f(0),$$
so that
$$f'(x)=f'(x)+xf''(x)$$
$$0=xf''(x)$$
This shows that $f''(x)=0$ for all $x\neq0$, but because $f''$ is continuous this forces $f''(x)=0$ everywhere. Thus $f'$ must be constant, and thus $f$ must be linear.
A: The following argument uses not much machinery. 
Suppose that $f(0)=b$ and $f'(0)=m$.  Let $g(x)=f(x)-(mx+b)$.   Then $g(0)=0$ and $g'(0)=0$.
Note that
$$g(x)-xg'(x)=[f(x)-(mx+b)] -x(f'(x)-m)=0=g(0).$$
So $xg'(x)-g(x)=0$ for all $x$.  
For $x \ne 0$, let $h(x)=g(x)/x$.
Then for any $x \ne 0$, we have
$$h'(x)=\frac{xg'(x)-g(x)}{x^2}=0.$$
It follows that $h(x)$ is a constant $p$ on $(0, \infty)$, and a constant $n$ on $(-\infty,0)$.
Thus $g(x)=px$ on $(0,\infty)$ and $g(x)=nx$ on $ (-\infty,0)$.
But $g'(x)=0$.  So 
$$\lim_{x\to 0+} \frac{px-0}{x-0}=0.$$ 
It follows that $p=0$.  In the same way we can show that $n=0$.  So $g(x)$ is identically $0$, and therefore $f(x)=mx+b$.
A: Suppose that $y=f(x)$ is a differentiable function that satisfies $f(x)-xf'(x)=f(0)$ for all $x\in\mathbb{R}$. Then $y=f(x)$ satisfies the linear differential equation
$$y'=\frac{y-k}{x},$$
where $k=f(0)$. The homogeneous system $y'=\frac{y}{x}$ has solutions $y_\lambda=\lambda x$, for any $\lambda\in\mathbb{R}$. Also, the equation $y'=(y-k)/x$ has a solution $y_p=x +k$. Thus, all the solutions of our differential equation are of the form $y=y_\lambda+y_p$ for some $\lambda\in\mathbb{R}$, i.e.,
$$y=\mu x + k,$$
where $\mu=\lambda+1\in\mathbb{R}$. Hence, all functions $f(x)$ with said property are linear.
Note: Technically, the existence and uniqueness theorem for linear differential equations tells us that the differential equation $y'=f(x,y)=(y+k)/x$ has a unique solution $f_1(x)$ in $(0,\infty)$ and also a unique solution $f_2(x)$ in $(-\infty,0)$, because $f(x,y)$ has a discontinuity at $x=0$. The argument above says that $f_1(x)=\mu_1 x+k$ and $f_2(x)=\mu_2 x + k$ are linear. Since we are assuming that $f$ is differentiable, we must have $\mu_1=\mu_2=\mu$ and $f(x)=\mu x + k$.
