If somebody wanted to develop a system between two intersecting rectangles so that the rectangles would, in a gradual process, push eachother away from one another until no longer intersecting, with the repelling force being stronger depending upon how deep the intersection is... what would the math look like?
If you want to simulate magnet behavior, you want to base forces on distance between them. Physics say so:
But you will be fine with:
And then you need to use trigonometry to apply force as velocity change: