Here, John Lawler writes the following:
Commas are not determined by grammar or by which words they follow. Comma indicates a particular intonation. If you would use that intonation in speaking the sentence, use a comma; if not, don't. So it's important to hear what you're writing, in your mind if nowhere else.
Sticking to this advice, how would you punctuate the following sentence without setting a comma before "then"?
If f, g, and h are functions then f(gh) = (fg)h.