This comment was posted to reddit on Aug 20, 2020 at 3:08 am and was deleted within 10 hour(s) and 25 minutes.

A possible derivation without using any formulae:

Assuming 0 is the lowest number and n is the highest number (e.g. 80-120 would be converted to 0-40, later you can add back the 80), the chance for each individual number x is as follows:

P(x) = (1/(n+1))^2 + 1/(n+1) * (n-x)/(n+1) * 2

The first term is the chance of rolling x twice and the second term is the chance of rolling x once and a higher number on the other roll, multiplied by two since either number could be the lower one.

The expected value can then be calculated by summing up all numbers multiplied by their probabilities:

E(n) = sum_(x=0 to n) ((1/(n+1))^2 + 1/(n+1) * (n-x)/(n+1) * 2) * x

Obviously you could rearrange that but I'm lazy and it looks like that's equivalent to what you're getting anyway, suggesting that OP made a mistake.