I was trying out the dual-wielding in Diablo 3, when I noticed really strange. When I equipped my off-hand, which has 0.5 less damage than my main-hand. My overall damage actually went down. So my question is, how does the dual-wielding mechanic work for calculating damage? It seems rather odd that my overall damage should be more with one weapon than with two.
Dual-wielding does not mean you attack twice as often. There is a slight attack-speed benefit, but this is apparently being offset for you by the lower damage from the offhand weapon.
According to this thread on the forums, the formula for number of attacks per second is
((Main Hand APS*1.15) + (Off-hand APS*1.15))*1/2
Which means that if you had two identical weapons, dual-wielding would give you a 15% attack speed bonus.
The main reason to dual-wield is that you get the bonus attributes from both items. This doesn't mean much early on when attributes aren't very strong, but is a big incentive later on. However, compared to a two-handed weapon that does more DPS, there isn't a clear winner. It will mostly come down to whether you've found better one-handed weapons or two-handed, and what your preference is for faster attack versus stronger attack.
When you are dual-wielding weapons, you alternate attacks between them for most attacks. Each weapon retains its own damage and attack speed. For example, if you have a 1.0 attack speed weapon and a 1.5 attack speed weapon, your main-hand weapon will swing first at an attack speed of 1.15 attacks per second (15% bonus from dual wield) and then your next weapon will swing at 1.725 attacks per second.
If we convert these numbers, this means that your main-hand will swing, there will be a .87 second delay (1 second / 1.15 attacks per second) and then your off-hand will attack. Once your off-hand attacks, there will be a .58 second delay before you swing with your main hand again.
Since you alternate attacks when you dual wield weapons, as a general rule of thumb your weapons need to be somewhat close in damage or else you may actually lose damage when you dual wield.
Imagine if you have a 20 DPS club and a 6 DPS club in your mainhand and offhand slot respectively. Even with a 15% attack speed buff, you still have to swing that weak offhand weapon one time for every time you swing your mainhand weapon. This will likely lower your DPS since it is slowing down the number of times you are swinging your much more powerful main-hand weapon.
According to my own research and experimenting in-game, I have to say that the accepted answer seems wrong. If you read the linked blog in @Midnight Sparkle's answer carefully (And also watch the video), you will see that that the two given answers are contradictory.
If you open the detailed stats panel while dual-wielding, you will see that the attack speed number alternates every time you attack. This is because the damage and speed of your attack is actually calculated independently, depending on which weapon you're going to swing next.
As @Midnight pointed out, if your 1st weapon has an 1.4 attacks/sec and the 2nd weapon has 1.1 attacks/sec, you will swing the 1st, then there will be a 1/1.4 sec delay, then you will swing the 2nd, and there will be a 1/1.1 sec delay. And then the cycle repeats. (I'm going to assume that the attack speed bonus has already been applied to those numbers)
So the actual formula for Average attack per second is:
Average APS = 2 attacks per cycle / Time of cycle
Average APS = 2 attacks per cycle / (Delay of 1st weapon + Delay of 2nd weapon)
And in my example:
Average APS = 2 / (1/1.4 + 1/1.1) = 1.23 attacks/sec
Average APS = (1.4 + 1.1)/2 = 1.25 (And I think this is wrong)
Now, you probably think that this is not much of a difference, and there is a certain range where the accepted answer and formula is a good approximation of your average attacks per second. But as the disparity between your two weapons increases, it will be completely off.
Just think about it for a second: If you have a weapon that is extremely slow, say 1, and a weapon that is extremely fast, say 100, the cycle will be dictated by the slower weapon, which creates a 1 second delay after each swing. The delay for the 2nd weapon will be completely negligible, so you will get about 2 attacks per second no matter how fast the 2nd weapon is. This is very far 50.5 attacks per second, given by the accepted formula.
I'm going to go ahead and add the Average DPS. For that we first need to calculate the average Damage per cycle. Lets add two arbitrary numbers for the average Dmg of our two weapons (Average Dmg = (Min Dmg+Max Dmg)/2). 1st = 35 Dmg and 2nd = 55 Dmg.
Average Damage = (Average Dmg 1st weapon + Average Dmg 2nd weapon) / 2 Attacks per cycle
Average DPS = Average DMG * Average APS
In our case,
Average DPS = (35+55)/2 * 2/(1/1.4 + 1/1.1) = (35+55)/(1/1.4 + 1/1.1) = 55
The other thing to remember when considering this is critical hits. A faster attack speed means more chances to crit, which in turn helps your overall DPS. While this probably isn't calculated within the game's dps system (as many things aren't,) it's very important at higher levels.
To the person asking about whether or not the 15% IAS (increased attack speed) can mitigate a 15% drop in damage, that's a very tricky question.
So with all of that said, there is a lot to take into account when comparing weapons. I really hope you understand what I'm trying to explain, but basically you should never simply look at DPS to decide which is better, and keeping your attack speed as high as possible should be one of your top priorities when looking for good weapons / items.
To calculate damage per second (DPS) when dual wielding:
This gives the damage number listed in your character sheet. A key take-away here is that both the APS bonus and base damage of both weapons are taken into account, and it does not matter whether a weapon is in your main-hand or off-hand: the same DPS will be calculated.
Another take-away is that your DPS will only be as good as the DPS of both weapons, as their DPS (with the bonus) is averaged. It will do you no good to equip a poor weapon in your off-hand to get the APS bonus to your main weapon as your overall damage will suffer.
Finally, this insight allows us to calculate the minimum damage a weapon must have to raise the net DPS when dual wielding. If x is the average damage of our main weapon and we wish to add another weapon with average damage y, with APSx and APSy attacks per second, respectively, then y~.74x(APSx/APSy). If both weapons have the same APS (APSx=APSy), then this simplifies to y~.74x, which means the off-hand weapon must average about .74 the main-hand weapon's damage per hit.