I want to devise a function $f(x)$ such that $f(4) = 160, f(16)=80, f(28)=40$ and $f(40)=20$, as well as all the other values in between $4-40$. As in, the numbers between $4-12$ have a proportional value between $160-80$. Numbers between $28-40$ have a proportional value between $40-20$ etc.
The values on the left go up linearly and the values on the right go down exponentially.
I hope this makes sense. But would appreciate any help. Thanks
Since your $x$-values are spaced linearly and your $y$-values are spaced exponentially, we can find an exponential function based solely on the first two points and it will hold for all of them. Let $f(x) = a(b)^x$ for unknown $a,b$. Based on your first two points, we have \begin{align} 160 &= a(b)^{4}\\ 80 &= a(b)^{16}. \end{align} Dividing the first equation by the second lets us eliminate $a$: $$2 = b^{-12} \implies b = 2^{-1/12}.$$
Plugging this back in to either equation (I'll use the second): $$80 = a(2^{-1/12})^16) = a(2)^{-16/12} = a(2^{-4/3}) \implies a = 80(2)^{4/3}.$$
Putting it all together gives us $$f(x) = 80(2)^{4/3}(2^{-1/12})^{x},$$ which if we want we can rewrite as $$f(x) = 80(2)^{\frac{4}{3} - \frac{x}{12}} = 80(2)^{\frac{16-x}{12}}.$$
If for some reason you wanted to use base $e$ instead this would become $$\ f(x) = 80\left(2\right)^{\frac{4}{3}}e^{\ln\left(2^{-\frac{1}{12}}\right)x}.$$