How to calculate bone localRotation

I want to understand how local rotation for the bone works. I should be able to calculate it based on up, right, forward vectors.

If I try like this:

    var qc = Quaternion.LookRotation(bone.transform.forward, bone.transform.up);
    var qp = Quaternion.LookRotation(bone.transform.parent.forward, bone.transform.parent.up);
    
    var q = Quaternion.Slerp(qp, qc, 1f);
    bone.t.localRotation = q;

it doesn’t seem to work.

OK finally I got it:

var rp = Quaternion.LookRotation(bone.transform.parent.forward, bone.transform.parent.up);

var cf = Quaternion.Inverse(rp) * bone.transform.forward;
var cu = Quaternion.Inverse(rp) * bone.transform.up;

var q = Quaternion.LookRotation(cf, cu);
bone.transform.localRotation = q;

or better still:

var rp = Quaternion.LookRotation(bone.t.parent.forward, bone.t.parent.up);
var rc = Quaternion.LookRotation(bone.t.forward, bone.t.up);
var q = Quaternion.Inverse(rp) * rc;
bone.t.localRotation = q;