Dirac notation, integral and change of basis Suppose, I have some operator $\hat{A}$, such that in the $x$-basis, it is written as $f(x).$ I'm trying to calculate the expectation value of this operator in integral form. That is given by the following expression :
$$\langle\hat{A}\rangle = \int\psi^*(x)f(x)\psi(x)dx$$
We have assumed that the wave function is normalized here.
In this case, we have done the entire integral in the $x$-basis. I suppose, we can actually write the above integral as :
$$\langle\hat{A}\rangle = \int\langle \psi|x\rangle\langle x|\hat{A}|x\rangle\langle x|\psi\rangle dx$$
However, suppose my wave function evolves and becomes $\psi(u)$, where $u=g(x)$. We can try to find the expectation value of this new wave function. We know :
$$\langle\hat{A}\rangle = \frac{\int\psi^*(u)f(x)\psi(u)dx}{\int\psi^*(u)\psi(u)dx}$$
However, we need to change the  variable of integration to $u$, and so we do the following:
$$\langle\hat{A}\rangle = \frac{\int\psi^*(u)f\space o\space g^{-1}(u)\psi(u)\frac{du}{g' \space o \space g^{-1}(u)}}{\int\psi^*(u)\psi(u)\frac{du}{g' \space o \space g^{-1}(u)}}$$
Now we can evaluate the integral, as everything is in the $u$ basis.
However, what we did here is first write the integral in the $x$ basis, and then use suitable transformations to make $u$ the variable of integration. However, how can I write the integral directly in the $u$ basis.
For example, we know: $$\langle\hat{A}\rangle=\frac{\langle\psi|\hat{A}|\psi\rangle}{\langle\psi|\psi\rangle}$$
I suppose we can insert any basis here in the following way:
$$\langle\hat{A}\rangle=\frac{\langle\psi|x\rangle\langle x|\hat{A}|x\rangle\langle x|\psi\rangle}{\langle\psi|x\rangle\langle x|\psi\rangle}=\frac{\langle\psi|u\rangle\langle u|\hat{A}|u\rangle\langle u|\psi\rangle}{\langle\psi|u\rangle\langle u|\psi\rangle}$$
Moreover, $$\frac{\langle\psi|x\rangle\langle x|\hat{A}|x\rangle\langle x|\psi\rangle}{\langle\psi|x\rangle\langle x|\psi\rangle}=\int\psi^*(x)f(x)\psi(x)dx$$
Hence, we must have :
$$\frac{\langle\psi|u\rangle\langle u|\hat{A}|u\rangle\langle u|\psi\rangle}{\langle\psi|u\rangle\langle u|\psi\rangle}=\frac{\int\psi^*(u)f\space o\space g^{-1}(u)\psi(u)\frac{du}{g' \space o \space g^{-1}(u)}}{\int\psi^*(u)\psi(u)\frac{du}{g' \space o \space g^{-1}(u)}}$$
Now I can see that $f(x)$ is replaced by $f\space o\space g^{-1}(u)$, as this is the representation of the operator in the $u$ basis. However there is also a $g'\space o \space g^{-1}(u)$ term below the differential $du$.
My question is, where is this factor coming from ? How do we formulate the entire thing using dirac notation ? I know the initial equation in terms of the $x$ basis, and so I use the transformations to convert the integral into the $u$ basis. This can be shown as :
$$\langle \hat{A}\rangle=\frac{\int\psi^*(g(x))f(x)\psi(g(x))dx}{\int\psi^*(g(x))\psi(g(x))dx}=\frac{\int\psi^*(u)f\space o\space g^{-1}(u)\psi(u)\frac{du}{g' \space o \space g^{-1}(u)}}{\int\psi^*(u)\psi(u)\frac{du}{g' \space o \space g^{-1}(u)}}$$
Using Bra-Ket notation, I can write the integral in $x$ basis, and then transform it into the $u$ basis. However, I don't see how to write the integral directly in the $u$ basis, using Bra-ket notation. It is clear to me, how the expression of the operator changes in the Bra-ket notation, in the new basis. However, it is unclear to me where the factor under the differential comes from, if we try to write the integral directly using Bra-Ket notation.
I hope I've been able to explain my confusion. Any help would be highly appreciated.
EDIT:
My initial intuition is that the term under the differential $du$ is the weight factor of the integral. However, I have no idea how it is represented in Dirac notation. For example, in the $x$ basis, the weight factor is clearly $1$ as there is nothing under the differential $dx$. Where does this come from in Dirac notation to integral notation conversion?
 A: As you suggest, $u=g(x)$, taken invertible, and
$$
[\hat u, \hat x]=[\hat A, \hat x]=[\hat u, \hat  A]=0,\\
\hat u \equiv g(\hat x), ~~~\leadsto |u\rangle \propto |x\rangle ~~~\leadsto \hat u |x\rangle = g(\hat x)|x\rangle = g(x)|x\rangle .
$$
Likewise,
$$
\hat A |x\rangle=  f(x) |x\rangle= f(g^{-1}(\hat u))  |x\rangle \leadsto  \\
\hat A |u\rangle=   f(g^{-1}(  u))  |u\rangle  .
$$
In your sibling question you seem to appreciate that $\psi(x)$ does not "evolve" unitarily to $\psi (u)=\psi(g(x))\equiv \tilde \psi(x)$, since
$|\psi\rangle$ and $|\tilde \psi\rangle$ have different normalizations--see example below.
Let's illustrate some of this with the trivial scaling case g(x)=ax suggested in the sibling question, so g'=a, so du=a dx.
$$
{\mathbb I}=\int \!\!dx~~ |x\rangle \langle x|= \int \!\!du~~ \frac{1}{a}|x\rangle \langle x| \\
=\int \!\!du~~ |u\rangle \langle u| ,
$$
That is, $|u\rangle=\frac{1}{\sqrt{a}}|x\rangle$.
You then have,
$$\psi(u)=\langle u|\psi\rangle  =\frac{1}{\sqrt{a}}\langle x|\psi\rangle= \psi (x)/\sqrt{a} =\langle x|\tilde \psi\rangle=\tilde \psi(x)=\psi(ax),\\
|\tilde \psi\rangle= |\psi\rangle / \sqrt{a} ~~~\implies ~~~
\langle \tilde \psi | \tilde \psi \rangle = \langle   \psi |  \psi \rangle/a,
$$
as remarked at the beginning.  For this trivial case (only), the two expectation values you are computing turn out to be equal, but this is not a general feature, of course!
You may take it from here,
$$|\tilde \psi\rangle= \frac{1}{\sqrt{g'(\hat x)}}|\psi\rangle, ~~  |u\rangle= {1\over \sqrt{g'}}|x\rangle\leadsto \\ \frac{\langle\psi|\hat{A}|\psi\rangle}{\langle\psi|\psi\rangle}
 = \int\!\! du |\psi(u)|^2 f(g^{-1}(u)) , ~~\mathbf{ but}\\
\frac{\langle\tilde\psi|\hat{A}|\tilde\psi\rangle}{\langle\tilde \psi|\tilde \psi\rangle} 
 = {\int\!\! {du\over g'(g^{-1}(u))} |\psi(u)|^2 f(g^{-1}(u)) \over   \int\!\! {du\over g'(g^{-1}(u))} |\psi(u)|^2  }~~,  
$$
as stressed! Check their identity for simple scaling, as per above remark.
