I wrote this post to sort my thoughts because my formulas were wrong. But I think I've got it now, it's very simple.
Formula seems to be:
EWD = (BWD + BWDMod1 + BWDMod2) * Weapon Perk Bonus ( * Other Perk Bonuses * Drug Bonuses )
Variables: (you can call the variables whatever you like obviously, I tried to give them self-explanatory names)
EWD = End Weapon Damage, what it says your Damage is in Pip Boy
BWD = Base Weapon Damage (the Damage the Weapon has with no modifications, that mod is usually called Standard Receiver or something like that)
BWDMod1 = BWD * Damage Modification #1
BWDMod2 = BWD * Damage Modification #2 (some weapons have multiple damage modifications, not just the receiver. If not, we can set BWDMod2 to 0)
Took me a while to figure out that you have to calculate and round down each variable (except EWD) separately. In programming languages there are very simple expressions to round down numbers (or simply strike decimal places).
for example php: echo floor(4.95); would output 4.
But I don't know if there's an expression for rounding down in mathematics. (There's "~=" but that usually means you round a digit up or down to whichever is nearer).
That's why I can't write the formula in a simpler way. Maybe a smarter person can help.
Anyway, so if we take Combat Rifle (Standard Receiver does 33 Damage) with Powerful Automatic Receiver (BWD * 0.15 (had to look at the game files to get this value)) as an example:
BWD = 33
BWDMod1 = 33 * 0.15 = 4.95 = 4 (rounded down!)
So without Perks:
EWD = BWD + BWDMod1 = 33 + 4 = 37
With 3 Ranks in Commando (+60% Damage or simplified to * 1.6) :
EWD = (BWD + BWDMod1) * Weapon Perk Bonus = (33 + 4) * 1.6 = 59.2
With 5 Ranks in Commando (+100% Damage or simplified to * 2):
EWD = (BWD + BWDMod1) * Weapon Perk Bonus = (33 + 4) * 2 = 74
End Weapon Damage does not seem get rounded down however. It only shows as being rounded down in Pip Boy. Why?
Because with 3 Ranks in Commando (see above) I was at 59.2 Damage. Pip Boy showed 59 Damage. I took a Psycho (+25% Damage) which brought me to 74 Damage.
Now if it had been 59 Damage then that would mean 59 * 1.25 = 73.75
But Pip Boy displayed 74 Damage so it must have been 59.2 * 1.25 = 74 (exactly! )
Damage Bonuses like the one from the Astoundingly Awesome 7 Perk (+5% Damage at Night) also seem to be applied to the End Weapon Damage.
So if you had 59.2 Damage and used a Psycho and it was Nighttime:
59.2 * 1.25 * 1.05 = 77.7 (Pip Boy Shows 77)