Here's your equation:
Weight(octagon) = [d² - (d/(1+√2))² - π(c/2)²]* L * .283lb/in³
Where
d = diameter of barrel (flat to flat)
c = caliber of bore
L = length of barrel
Note, all measurements are inches. If you change measurements, you'd have to change the density as well.
If you had a round barrel, the weight would be expressed by:
Weight(round) = π[(d-c)/2]² * L * .283lb/in³
Similarly, if you had an octagon to round, you would calculate the weights of each section using the above formulas and add them together.
Edit: It's kind of hard to tell due to the font, but the π is pi, which is approximately 3.14159, or 3.14.
Also note, these are equations for straight barrels. For a taper, integration would be required, though the core of these equations would be the same, except that you'd have a ∆d/∆dL, which is to say a change in diameter as you go down the Length of the barrel.