When optimizing character builds, it is common to use the average expected damage to estimate damage output. Calculating the average of a single die is simple, fixed modifiers are then added to it to obtain raw damage output. That raw damage output is then multiplied with the expected to-hit chance for the share of attacks that actually, connect to arrive at the expected damage from the attack.
However, there is the issue of critical hits and misses - a one always misses, and a 20 always hits, and there are also some ways to increase the critical range, for example the Champion fighter has an Improved Critical feature that allow them to critically hit on a 19 or 20, and a Superior Critical feature that does the same for a roll of 18 to 20. A correct calculation for expected damage needs to factor this in.
The rule for calculating damage of a critical hit is:
When you score a critical hit, you get to roll extra dice for the attack’s damage against the target. Roll all of the attack’s damage dice twice and add them together. Then add any relevant modifiers as normal.
What is the correct formula for seprately calculating the added expected damage from just the critical hit contribution?
What is the factor with which you can multiply the average damage dice result to obtain the raw die damage from the attack including expected contribution of criticals, for then adding static bonuses and multiplying the result with the to hit chance?
Bonus question: how do these formulas look like when you attacking with advantage or disadvantage?
To clarify what I am looking for using an example :
Attack damage is 1d6+3, and I hit 65% of the time and crit on a 20.
Expected damage without considering critical is 6.5. What is the expected average damage with crits factored in?
Is it (3.5+3) x 65% + 3.5 x 5%? Is there a factor with which I can multiply the 3.5 in the parentheses instead of adding 3.5 x 5% afterwards? What is it?
With advantage, is it (3.5+3) x 87.75% + 3.5 x 9.75%, and what would the factor in parentheses be?