# Matrices – Decompose \$ A ^ {1} cdot B \$ in translation, rotation, scaling

I noticed the following problem in my code:

• There are 2 transformation matrices $$A, B in mathbb {R} ^ {4 times 4}$$
• $$A, B$$ have this shape $$begin {bmatrix} R cdot s && t \ 0 && 1 end {bmatrix}$$

• The goal is to decompose $$A ^ {- 1} cdot B$$ in the translation $$t in mathbb {R} ^ 3$$, Rotation $$q in text {quaternion}$$ and scale $$s in mathbb {R} ^ 3$$

For the safety check I introduce Round trip (Decomposition and compilation of a matrix):

• $$comp (dec (A)) == A$$
• $$comp (dec (B)) == B$$
• $$comp (dec (A cdot B)) == A cdot B$$

However, if I try to make the tour with

• $$comp (dec (A ^ {- 1} cdot B))$$

Then I get a relatively large error in the rotation part. What is the reason for this phenomenon? Is it numerically unstable or is the inversion too inaccurate?

Many Thanks

Note: The decomposition is done as described here