Prices are typically driven by supply and demand. I was curious
about the price of gasoline. When I buy a gallon of gasoline,
I pay for it, but others pay for it
too. My purchase increases the aggregate demand. Higher demand
means higher prices. Higher prices means other people pay more
for gas.

How much more do others have to pay?

I can't calculate exactly but with some simplifying assumptions
I can make an estimate:

Limit this calculation to the United States. There are
complex issues that influence gas prices around the world, some
economic and some political, and it's much simpler to make this
estimate with just one country. This would ordinarily not work,
except the next assumption makes it possible:

Gasoline supply in the U.S. is limited by refining capacity in
the U.S. With “maintenance”, “shutdowns”, “inspections”,
fires, and other capacity issues, I believe it's reasonable to
say the supply — at least in the short term — is fixed, and
that everything that is produced is consumed.

In other words, if I buy one extra gallon of gas, other
Americans need to buy one less gallon. What would it take to
make them buy less? Raise the price. By how much?

Let's call the total quantity consumed by everyone else Q. Let's
call the current price P. We want to know how much the price has
to go up to make Q go down by 1. If everyone else (collectively)
buys 1 gallon les, then I can buy that gallon. The key to the
relationship between P and Q is the price
elasticity of demand:

e = %ΔQ / %ΔP = (ΔQ/Q)/(ΔP/P)

What I really want to know is when I spend $D on gas, how much
more do other Americans have to spend? Spending $D means
ΔQ = D/P, which can also be written as D =
ΔQ×P. What everyone else has to spend is
Q×ΔP. So let's compute Q×ΔP. First,
let's rearrange e:

e = (ΔQ/Q)/(ΔP/P) = (ΔQ×P) / (Q×ΔP)

So Q×ΔP = (ΔQ×P)/e = D/e.

When I spend an extra $D on gas, others have to spend an extra
$D/e on gas. That's the answer I was looking for.

Except … what's the value of e?

There are various estimates: 0.2, 0.01, 0.1,
0.034
to 0.077 in 2001-2006, and 0.26.
When I spend an extra $40 on gas, other Americans have to spend
between $153 and $4000. I'm not sure which to believe, but I'm
going to guess it's around 0.1, which means others have to spend
an extra $400 on gas. Where does that money go? To the oil companies.

Let's look at it in reverse: if you found a way to spend $40
less on gas (maybe carpooling, planning errands better, or
driving less aggressively), not only would you save that $40,
the oil companies would miss out on $400 (maybe as much as
$4000), because you'd be helping other Americans spend less on
gas.

I'm not even going to try estimating how much more everyone pays
when someone drives a big SUV instead of a fuel efficient car…