Does there exist a 3-dimensional subspace of real functions consisting only of monotone functions?

Somewhat simpler: Let $V$ be a $3$-dimensional vector space of monotone functions. Consider any linearly independent $f_1,f_2 \in V$. Then $g = (f_2(1) - f_2(0)) f_1 - (f_1(1) - f_1(0)) f_2 \in V$ has $g(0) = g(1)$, so since $g$ is monotone it must be constant. Moreover since $f_1$ and $f_2$ are linearly independent, $g \ne 0$. Thus the constant function $1 \in V$. But if $V$ is $3$-dimensional, it has a basis that contains $1$, and we just showed this is impossible because $1$ is in the span of the other two basis elements.

EDIT: another way to say this. Suppose $f_1$, $f_2$, $f_3$ are linearly independent members of $V$. We may assume $f_2$ is not a scalar multiple of $1$. Then $1 = a f_1 + b f_2 = c f_2 + d f_3$ for some scalars $a,b,c,d$, with $a \ne 0$. So $a f_1 + (b-c) f_2 - d f_3 = 0$, contradicting linear independence.


$\newcommand{\Zobr}[3]{{#1}\colon{#2}\to{#3}}\newcommand{\R}{\mathbb R}\newcommand{\intrv}[2]{[{#1},{#2}]}$ Lemma. Let $\Zobr{f,g}{\intrv01}{\R}$ be functions such that $f(0)=g(0)=0$ and the function $af(x)+bg(x)$ is monotone for any $a,b\in R$. Then $f=0$ or $g=cf$ for some constant $c\in\R$.

Proof. Let $f\ne 0$. Let us denote the space consisting of all linear combinations of $f$ and $g$ by $V$. We assume that all functions in $V$ are monotone.

W.l.o.g we can assume that $f$ is non-decreasing. (Otherwise we can use the same proof for $-f$.)

Let us take an $x_0>0$ such that $f(x_0)>0$.

Put \begin{align*} c&:=\frac{g(x_0)}{f(x_0)}\\ h(x)&:=g(x)-cf(x) \end{align*} We have $h(0)=h(x_0)=0$, which implies $h(t)=0$ for every $t\in\intrv0{x_0}$. (Since $h$ is monotone.)

a) If $h=0$ then $g=cf$.

b) Suppose that $h\ne 0$. Then there exists a point $y_0$ such that $h(y_0)\ne 0$. We know that $y_0\notin\intrv0{x_0}$

This implies $0<x_0<y_0$. We have \begin{align*} 0&=f(0)<f(x_0)\le f(y_0)\\ 0&=h(0)=h(x_0)\ne h(y_0) \end{align*} W.l.o.g we may assume $h(y_0)>0$. (Otherwise we can work with $-h$.)

b.1) Suppose that $f(x_0)=f(y_0)$ and define $h_1=f-h$. Clearly $h_1\in V$, but $$0<h_1(x_0)=f(x_0)>h_1(y_1)=f(x_0)-h(y_0),$$ so $h_1$ is not monotone.

b.2) Now suppose that $f(x_0)<f(y_0)$.

In this case we define $$h_1:=f-2h\frac{f(y_0)-f(x_0)}{h(y_0)}.$$ Clearly $h_1\in V$. We have $$h_1(0)=0<h_1(x_0)=f(x_0) > h_1(y_0)=f(y_0)-2[f(y_0)-f(x_0)]=f(x_0)-[f(y_0)-f(x_0)].$$ So the function $h_1$ is not monotone. $\hspace{2cm}\square$

The basic idea of the proof of this lemma is that if we have function which look similarly to the functions in the following picture, we can find a linear combination, which is not monotone.

f and h


Corollary. If $\Zobr{f,g}{\intrv01}{\R}$ are functions such that the function $af+bg$ is monotone for any $a,b\in\R$, then $f(x)=c$ for some constant $c\in\R$ or $g(x)=cf(x)+d$ for some constants $c,d\in\R$.

Proof. We apply the above lemma to the functions $f_1(x)=f(x)-f(0)$ and $g_1(x)=g(x)-g(0)$. $\hspace{2cm}\square$


The claim of the exercise follows from this corollary. Indeed, suppose that $V$ is a subspace of $\R^{\intrv01}$ which contains only monotone functions. We can assume that $V$ contains all constant functions, since adding a constant function does not influence monotonicity. The corollary says that if we take two linearly independent functions $1,f\in V$, then all remanding functions in $V$ are linear combinations of $1$ and $f$.


Remark. The above proof can be adapted without much effort to functions from $\mathbb R$ to $\mathbb R$ (instead of $[0,1]\to\mathbb R$). We just need to add one more case $y_0<0<x_0$ to our lemma. (It is sufficient to deal only with $x_0>0$, since the case $x_0<0$ is symmetric.)