How to compute the local rotation of a bone in IK chain?

How do I compute the local rotation of a bone at the beginning of an IK chain (ie., the first bone in the bone chain)?

I thought I could try duplicating the bone to create a static “basis” bone, and compare their matrices using

bpy.context.object.pose.bones['Bone'].matrix

or compare their world space(?) vectors using

bpy.context.object.pose.bones['Bone'].vector

But once the IK constraint is enabled, the matrix of the original bone on the IK chain is changed, and it no longer matches the duplicated bone’s matrix.

What’s an effective way of doing this?