Method or algorithm for choosing a color that “goes well” with other colors [migrated]

This may be more of a computer science question than a UX question, but it’s a question of what pleases the human eye. Take Bootstrap buttons, for example. The version 3 button colors “go well together”. The version 4 buttons also “go well” together, but are starker than the version 3 buttons.

If I wanted to find a new color that “goes well” with a group of existing colors, is there some way of mathematically interpolating or algorithmically determining a color that “goes with” the reference group of colors?

To use the Bootstrap example, I want a way to find which shade of, say, pink, will “go with” the version 3 button colors, without eyeballing it until I find something that looks pleasing. For the version 4 buttons, the same method should produce a (starker) pink that nicely matches the (starker) version 4 colors.

Is this possible, or must we eyeball it?