Today i was studying on a textbook and i crossed a paragraph that confused me a little.
Suppose you have an algebra generated by $\hat{X}$ and $\hat{P}$ and a function $f(\hat{X},\hat{P})$ that commutes with $\hat{X}$ and $\hat{P}$. Then you can prove that this function is proportional to the identity.
Here comes the issue, i don't understand the proof of this.
Reasoning in Position representation (meaning that $\hat{X}=x$ and $\hat{P}=-i\hbar\frac{d}{dx}$), i don't get why $[x,f]=0$ implies that $f=f(x)$ and why $[-i\hbar\frac{d}{dx},f]=0$ implies that $i\hbar\frac{df(x)}{dx}=0$.