Hi,
The first formula is only used with diadem (with an high lvl enough char

), it won't work with any other item that will loose ilvl too fast (if you wanna reroll claws using that, you may roll it 1 or 2 time max before it's ilvl < the required ilvl of the mods you seek after, depending on the monster you droped (or if you gambled it))
the second formula would allow 'eternal' rerolling untill you get what you want, but are you willing to use a soj for each roll knowing the low chance you have at getting something good ??