How to get relative velocity without parenting?

In my scene there are two moving objects, I need to get the first object’s velocity relative to the second object’s velocity without parenting one to another. I would like to get the same result as if I used rigidbody.relativeVelocity if objects were parented, the only problem is that they can’t be. Is there any way to do this?

Velocity is a vector.

If V1 is the velocity of object 1 and V2 is the velocity of object 2 then
V2 - V1 is the difference between the two, or the “second velocity relative to the first”.

This is basic vector math.