Doesn't this formula also punish circular trade patterns in a strange way, like if the US imports $X of good from country B and country B imports $X of goods from country C and country C imports $X of goods from the US, and there are no flows in the opposite direction, then the US would impose an infinite tariff on country B since US imports from B are zero?
Almost but the formula actually says trade with B is X, deficit is X, their effective tariff on the US is X/X =1 or 100%, the US tariff on them would be half or that or 50%.
The circular situation seems not so common but countries like Camboidia don't import much from the US because the people there don't have much money, so the Trump formula makes their 'effective rate' 97% whereas their actual tariffs are 7.9%. The net effect is to hammer the poorest countries.
Ironically the Cambodians don't have much money to buy US stuff because of terrible governments that got in partly as a result of the US destabilizing things by bombing the country. They don't seem to have much luck with the US.