It is not just one formula, but several. They have the names Maxwell, Lorentz, right-hand rule, left-hand rule, etc.
Do you wish to construct a relay? That's a difficult project. The coil needs to generate a minimum flux field, so it activates the mechanism. The coil consists of many turns of very thin wire. You can apply a higher voltage and less Amperes, or vice versa.
You need to make the mechanical section so it only needs little 'pull' to operate. It needs to be made with precision. It would be a big challenge to build it yourself.