There are no true formulas to how much or how big of a fish you can keep in a tank. What should be done instead of taking a lucky guess based on some magical universal formulas that allow you to fit whatever you want in your tank, is researching the particular species of fish online before you buy it because your tank can hold x inches of fish or your tank can hold x big of fish cause it's big in comparison to them.
For example, we have convict and firemouth cichlids, and larger gourami species, they grow to be pretty big fish, about 6 inches, not counting for their bulk (let's remember this, 1 of these fish is bigger than 6 1 inch guppies. The inch rule of thumb is pretty bogus.) but are fairly inactive. I read around, and for the most part, people keep these fish in 30 inch long tanks with no issue. Not together, of course, but alone or with with that won't bother or that won't be bothered by them.
A rule of thumb I followed for a short period of time was dividing the length of the tank by 4, width of the tank by 1.5, and height of the tank by 1.5. the smallest number in that formula is the biggest fish you can hold. Following this formula, I could theoretically keep a 7.5 inch long fish in my 37, an 8 inch long fish in my 55, and as for my 20, it's a hexagon, I don't wanna figure that one out.
That didn't make much sense to me, the 55g tank is about a foot and a half longer, and I can only keep half an inch more of fish in it, according to this key. But that's because its width doesn't allow much wiggle room for bigger fish.
Keep in mind, this is theoretical, and I do still use those measurements as a small key of sorts. If a fish gets bigger than 7.5 or 8, I don't bother looking into them all too much, at least not to buy. If they don't get larger, I take a further step into researching, going online, asking questions, reading profiles, and digging out what sounds best for the fish. If they fit, great, if they don't, well, that sucks. better luck next time.
I also use the gallon=1 inch of full grown fish as a general guideline too, to make sure I'm not slamming my tank full of fish. As tempting as it is to have a tank full of little fish from the store, it's good to keep in mind that they don't stay little forever.
It's bad advice, but it's general newbie advise that keeps you from buying like 40 1 inch fish that will grow to be 3-6 inches for your 20 gallon tank cause they're really small and you don't think they'll grow too much. It sets a general limit on your item that you can surpass in some cases, and will have to undershoot in others.
Research is not that hard to do, it's somewhat enjoyable (for me, anyway) and it keeps us from making big mistakes and risking the happy life of a pet. It tells you how big it'll get, how much space it'll need, what kind of water it likes, and what tank mates it can stay with. All that information can be obtained just by typing in their name on your favorable search engine, and if you're too lazy to do that, you shouldn't be keeping fish.