I have a doubt on Jacobian matrices. Consider the non linear transformation
$ \left[ \begin{array}{c} x\\ y\\ z \end{array}\right] = \mathbf{G}\left( \left[ \begin{array}{c} \hat{x}\\ \hat{y}\\ \hat{z} \end{array}\right] \right) = \left[ \begin{array}{c} \hat{x}g(\hat{z})\\ \hat{y}g(\hat{z})\\ \hat{z} \end{array}\right] $ whose Jacobian reads
$ \text{J} = \left[ \begin{array}{ccc} g & 0 & \hat{x}g'\\ 0 & g & \hat{y}g'\\ 0 & 0 & 1 \end{array} \right] $
If I invert this matrix I get
$ \text{J}^{-1} = \left[ \begin{array}{ccc} 1/g & 0 & -\hat{x}g'/g\\ 0 & 1/g & -\hat{y}g'/g\\ 0 & 0 & 1 \end{array} \right] $ which I thought should be the same as the Jacobian of the inverse transformation. However, solving for $\hat{x}, \hat{y}, \hat{z}$ in the definition of the transformation, I get
$ \left[ \begin{array}{c} \hat{x}\\ \hat{y}\\ \hat{z} \end{array}\right] = \mathbf{G}^{-1}\left( \left[ \begin{array}{c} x\\ y\\ z \end{array}\right] \right) = \left[ \begin{array}{c} x/g(z)\\ y/g(z)\\ z \end{array}\right] $ whose Jacobian now reads
$ \text{J}^{-1} = \left[ \begin{array}{ccc} 1/g & 0 & -\hat{x}g'/g^2\\ 0 & 1/g & -\hat{y}g'/g^2\\ 0 & 0 & 1 \end{array} \right] $ which is slightly different. My question is: which one is the correct Jacobian for the inverse? Weren't they supposed to be the same? If so, where's my mistake?
Thank you in advance!