Manipulate $\cos(x)$ to return $1$ if median value in a fixed range is provided I know nothing about maths, so please forgive my poor explanation and the title of the question.
I need a function f(x) that given a range consisting of a lower bound (b1) and a upper bound (b2), returns 1 if x is exactly (b1+b2)/2 and that tends to 0 (returning exactly 0) if x tends to the bounds. The function should produce any value between [0,1] given values between [b1,b2].
I tried playing with cos(x) with no success.
Thanks

You have the right idea with $\cos(x)$, since we have $\cos(-\frac{\pi}{2})=\cos(\frac{\pi}{2})=0$ and $\cos(0)=1,$ so it already satisfies the properties of your function with $b_1=-\frac{\pi}{2}$ and $b_2=\frac{\pi}{2}.$
How do you obtain the correct function for any $b_1$ and $b_2$?
You will have to stretch and translate your function, so consider $f(x)=\cos(ax+b)$, where $a$ and $b$ are constants to be determined. Since $f(b_1)=f(b_2)=0$ we have the system
$$\cos(ab_1+b)=\cos\left(-\frac{\pi}{2}\right)=0\implies ab_1+b=-\frac{\pi}{2}$$
$$\cos(ab_2+b)=\cos\left(\frac{\pi}{2}\right)=0\implies ab_2+b=\frac{\pi}{2}$$
Can you take it from here?
Note the solution will not be unique and you can also consider $\sin(x)$ as mentioned by projectilemotion in the comments.
