Your algorithm is correct if your transformation matrix does not skew the gradient.
In your case, the final transformation applied to the gradient,
translate(0,-924.36218) matrix(0.95516166,-0.46694301,0.71994792,0.61949768,-706.90347,408.6637) matrix(0.96592583,-0.25881905,0.25881905,0.96592583,-17.36888,938.82017)
which coincides with
matrix(0.7363,-0.6113,0.9426,0.4775,-47.6376,74.0101)
which is equivalent
translate(-47.6376, 74.0101) rotate(-39.7) scale(0.957, 0.9695) skewX(23.4337)
If the latest skew(23.4337) were not there, everything should work as you wish.
This is rather complicated, or rather, I have to say that it is impossible to achieve a skew effect without using the gradientTransform attribute. According to SVG 1.1 specification :
gradientTransform contains the definition of an optional additional transformation from the gradient coordinate system to the target coordinate system (i.e. userSpaceOnUse or objectBoundingBox). This allows things like gradient skew.
It is designed to achieve a skew effect.
If you are still wondering why this is not possible, I made a simple example, shown in the image below.

On the left, we have a horizontal linear gradient applied to the square. If we shift the gradient on the X axis by 20 degrees, the effect will look like a combination of two figures:
- a triangle on the left side whose fill is a solid color
- the same square filled with the same gradient, but the square itself is skewed by 20 degrees, and then tied to its original shape.
Now you canโt just use the string to describe the gradient, so we need to use the gradientTransform attribute.