Say I have two finite intervals $[a,b],[c,d]\subsetneq\Bbb R$ where $a<b<c-1<c<d$ and $b-a=d-c=s<1$.
I want to find a polynomial $f \in \Bbb R[x]$ such that $$\forall x\in[a,b],\mbox{ }f(x) \in\big[\frac{a+b}{2} - r, \frac{a+b}{2} + r\big]$$ and $$\forall x\in[c,d],\mbox{ }f(x) \in\big[\frac{c+d}{2} - r, \frac{c+d}{2} + r\big]$$ for some fixed $r\in(0,\frac{s}{2})$.
Then what is the least degree polynomial I can use?
Do Chebyshev polynomials help here? I know that for each interval I can find two scaled and shifted Tchebyshev polynomials to get what I want separately in each interval. However to find one polynomial that works on both intervals is difficult. I can try to do a weighted sum of the separate Tchebyshev polynomials. However then I am unable to guarantee what I want.
Let $T_n(x)$ be Tchebyshev polynomial of some degree $n$ which takes value between $(-1,+1)$ for $x\in(-1,1)$.
Then $$f_{a,b}(x)=\frac{a+b}{2}+r\cdot T_n\big(-\frac{2}{a-b}x+\frac{a+b}{a-b}\big)$$ and $$f_{c,d}(x)=\frac{c+d}{2}+r\cdot T_n\big(-\frac{2}{c-d}x+\frac{c+d}{c-d}\big)$$ does the job for each interval separately.
Can I build $f(x)$ from $f_{a,b}(x)$ and $f_{c,d}(x)$ by using some weighted sum. What would be the degree of the resulting polynomial?
Hint:
A degree five version might work. Symmetrize things around zero, and rescale so the two midpoints are at $1,-1.$ Insist on $f(x)=ax+bx^3+cx^5,$ which since it is odd means one only needs to look at the interval containing the midpoint $1$. So if $s<1<t$ are the two ends of the interval $[s,t]$ with midpoint $1$, we will send $1$ to itself, and then choose some interval $[m,n]$ around $1$ for the image, and we may as well have the midpoint of $[m,n]$ be $1$ also. We also choose $m,n$ close enough to $1$ that the interval $[s,t]$ gets shrunken by the appropriate amount to satisfy the conditions.
Now one can check that the three equations $f(1)=1,\ f(s)=m,\ f(t)=n$ lead always to uniquely solvable equations for the coefficients $a,b,c.$ [This is a matter of looking at the determinant of the system.] If one is lucky the resulting curve will end up increasing on the interval $[s,t],$ and that interval will map into the interval $[m,n].$
As simple-minded as it seems, this scheme did indeed work when I took $s=0.8,\ t=1.2$ and went for a shrink by a factor of $1/2$ via $m=0.9,n=1.1.$ When I did this, the coefficient of $x^3$ came out negative, however the function when graphed was increasing. Likely the derivative, a quadratic in $x^2,$ had negative discriminant, though I didn't check that.
This may not always work, and to even look at whether it does would involve perhaps prohibitive symbolic algebra, in order to get sufficient information on the coefficients $a,b,c$ in terms of the chosen parameters $s,t,m,n.$