Finding an example of a $C^1$ function satisfying a certain boundary condition + derivative condition I have a real function $f\in C^1([a,b])$. I wish to find another function, $g\in C^1([a,b])$, which is NOT $f$, which satisfies the following conditions:

*

*$g(a)=f(a),g(b)=f(b)$

*$g'(a)=f'(a),g'(b)=f'(b)$

*$|g'(x)|\leq |f'(x)|$ for all $x\in [a,b]$
Is there a 'simple' way of finding an example of such a function? My idea we taking:
$$g(x)=f(a)+\frac{f(b)-f(a)}{b-a}x+\epsilon(x)$$
Where $\epsilon(x)$ is some $C^1$ function satisfying:

*

*$\epsilon(a)=\epsilon(b)=0$

*$\epsilon'(a)=f'(a)-\frac{f(b)-f(a)}{b-a}, \epsilon'(b)=f'(b)-\frac{f(b)-f(a)}{b-a}$

*$|\epsilon'(x)|\leq |g'(x)-\frac{f(b)-f(a)}{b-a}|$ for all $x$.

Intuitively, this is taking a function which is a straight line between the two boundary points of $f$, plus some small perturbation which makes things $C^1$ while keeping the derivative 'small'. So now I just need to find an example of such an $\epsilon(x)$. Condition $3$ is especially challenging since I can't just pick one of the famous 'bump functions', since I cannot guarantee $3$ generally.
It seems that conceptually I'm pretty much facing the same question as before, and so I'm a bit stuck. Does anyone have an idea? If $f$ is linear than clearly I cannot find such an $\epsilon$ (which is not identically $0$), so let's ignore this case.
Thanks in advance
 A: There is no solution $g$ if $f$ is monotonic. (By a solution I mean a function $g\ne f$ that satisfies your conditions.)
Proof: Assume WLOG $f$ is increasing, and that $g$ is a solution. Then we have $g'\le |g'| \le |f'| = f'.$ This forces $g'<f'$ somewhere. Otherwise $g'=f'$ everywhere, and since $f(a)=g(a),$ we would then have $f= g,$ contradiction.
It follows that
$$g(b) = g(a)+\int_a^b g' < g(a)+\int_a^b f' =  f(a)+\int_a^b f' = f(b),$$
contradiction.
In fact I think the following is true for your question: There exists a solution $g$ iff $f$ is not monotonic. I need to work a bit more on that.
Previous answer: At first I thought condition 3 said $|g|\le|f|.$ Below I solved the problem assuming that. Who knows, an answer to the altered problem might be useful to someone some day.
WLOG there is $c, a<c<b,$ such that $f(c)\ne 0.$ Choose $a',b'$ such that $a<a'<c<b'<b.$
Standard bump function result: There exists a $C^1$-function $\phi$ on $\mathbb R$ such that $0\le \phi\le 1$ everywhere, $\phi = 0$ on $(-\infty,a'] \cup [b',\infty),$ $\phi >0$ on $(a',b')$ and $\phi(c)=1.$ (Good to draw a picture here.)
The function $1-\phi$ then equals $1$ on $(-\infty,a'] \cup [b',\infty),$ $0\le 1-\phi \le 1$ everywhere, and $1-\phi(c)=0.$
Now set $g(x)=f(x)(1-\phi(x).$ Then $g=f$ on $(-\infty,a'] \cup [b',\infty).$ Thus $g,g'$ match $f,f'$ at $a,b.$ We have $|g|\le |f|$ on $[a,b].$ And because $g(c) = 0,$ we have $g(c)\ne f(c)$ because we assumed $f(c)\ne 0.$ Thus $g$ is NOT $f$ as desired, and we're done.
