Taking a function out from between a bra- and ket-vectors in the general case

I had a guestion on what kind of functions can one pull out of braket-term. For example I know that

$$\langle{\psi_1}|c|\psi_2\rangle = c\langle{\psi_1}|\psi_2\rangle, \hspace{0.5cm} c\in \mathbb{C}.$$

Does this apply to arbitrary function f, which depends on same parameter as $$|\psi\rangle$$. In other words, is the following equation true?

$$\langle{\psi_1(x)}|f(x)|\psi_2(x)\rangle = f(x)\langle{\psi_1(x)}|\psi_2(x)\rangle$$

I know that this isn't true for operators, for example for the position operator

$$\langle{\psi_1}|\hat{x}|\psi_2\rangle \neq \hat{x}\langle{\psi_1}|\psi_2\rangle.$$

But then again, maybe

$$\langle{\psi_1}|x|\psi_2\rangle = x\langle{\psi_1}|\psi_2\rangle,$$

where $$x$$ is viewed as just a real number.

EDIT:

The first comment below might already answer my guestion, but I'm still a bit confused. From the comment below I get that

$$\langle{\psi_1(x)}|\hat{x}|\psi_2(x)\rangle \neq \hat{x}\langle{\psi_1(x)}|\psi_2(x)\rangle$$ and $$\langle{\psi_1(x)}|x|\psi_2(x)\rangle = x\langle{\psi_1(x)}|\psi_2(x)\rangle,$$

$$\langle{\psi_1(x)}|x|\psi_2(x)\rangle = \int dx\psi^*(x) x \psi(x)?$$

Clearly you can't take x outside the integral.

• Do you mean that $f(x) \in \mathbb C$? Then what is the problem? Do you have an example in mind? I don't get your example with the position operator: $\hat x$ acts on elements of the Hilbert space, you cannot take it out of the inner product - this would be completely undefined. OTOH, a real/complex number $x$ can be taken out - it does not matter if you label it by $x$ or $y$ or $:)$. Are you confused by the difference between an abstract vector and the position representation/wave functions? Is your question clear if you relabel $x$ by say $p$? Feb 9, 2023 at 22:03
• You're mixing up different notations and conventions, I am afraid. Can you please spell out with what kind of Hilbert space you're working, what kind of objects rae $\psi_1(x)$? All your problems are due to an improper use and an abuse of notation... Let me give you some hints: $\psi(x) \in \mathbb C$ and $|\psi\rangle \in L^2(\mathbb R)$, $x\in \mathbb R$ and $\int \mathrm dx F(x) = \int \mathrm dy F(y)$ where $F$ is a place holder for any functions you can consider- so under an integral sign these are dummy variables... Feb 9, 2023 at 22:11
• I tried to clarify the problem in an edit. I'm afraid I can't specify what @TobiasFünke is asking, I'm just a mere physics student :D. All I know about Hilbert spaces is that these things exist there and that's about it xD. Feb 9, 2023 at 22:16
• To add to @Tobias Fünke's comments: What do you mean by $|\psi(x)\rangle$? If you mean the wavefunction in the $\hat x$eigenvalue basis , then $\psi(x)= \langle x|\psi\rangle$ where $|\psi\rangle$ is an abract vector that does not depend on $x$. Feb 9, 2023 at 22:18
• I am trying to tell you that you all your problems arise solely from an abuse of notation: To start, $\psi$ or $|\psi\rangle$ is a function (seen as an element of a vector space), but $\psi(x) \in \mathbb C$ is a number. The inner product you want to perform is only defined for elements of the said vector space, hence you should write $\langle \psi_1|\psi_2\rangle = \int \mathrm dx \psi_1^*(x) \psi_2(x)$, for example. And again: the $x$ in this integration is a dummy variable - nothing in this expression depends on $x$. Feb 9, 2023 at 22:22

$$\langle \psi_1 | f(x) | \psi_2 \rangle = \int dy \psi^*(y) f(x) \psi(y) = f(x) \int dy \psi^*(y) \psi(y) = f(x) \langle \psi_1 | \psi_2 \rangle$$
for every function $$f$$. In contrast, if $$\hat{A}$$ is an operator, then
$$\langle \psi_1 | \hat{A} | \psi_2 \rangle \neq \hat{A} \langle \psi_1 | \psi_2 \rangle.$$