It's complicated? Not sure in what way.
Right now the game doesn't even show how much XP you get per battle. Or rather it shows the progress bar moving but when you review the battle you can't see the XP reward. That's why the bug LP reported about double heroes not getting 1/2 XP was there for so long and why no one realized you are only getting 1/2 XP for defending.
The Wiki page here:
http://www.warbarons.com/wiki/hero_levelingcan be amended after the 'Battle Experience Calculation' to say:
Modifiers:
Multiple heroes - Experience divided equally among all surviving heroes (Ex. 2 heroes = 1/2 XP each) with the exception of Search A Ruin gives all XP to the hero that searches.
More than 8 units in your stack - 1/2 XP awarded
More than 16 units in your stack - 1/4 XP awarded
I am pretty sure anyone who is capable of playing this game is capable of understanding that
KGB
P.S. Right now with the 1/2 modifier on defense will make you do illogical things. For example if you see an enemy hero stack approaching your city and you have only weak defenders and you know you can't hold it and lack gold to self-raze then the absolute best thing you can do is suicide all your men (assuming you can't run away) to deny the opponent XP in a cheap manner. Not sure that kind of tactic is 'obvious' to all players given it runs counter to common sense.