To estimate gas cost, we will derive a simple formula. To improve accuracy and practicality, the formula and the calculator below will include city miles and highway miles.
Usually, you will see MPG (miles per gallon) rating as 20 CITY / 30 HWY
This means that your vehicle will give you 20 miles per gallon driving in the city and 30 miles per gallon driving on the highway.
To derive our formula, the strategy we will use is to see how much money you spend on gas per miles. This situation can be expressed as dollar per miles.
Say the cost of gas is 3 dollars per gallon and the efficiency of your vehicle is 20 CITY / 30 HWY
Let us just work with the efficiency on the highway for now.
Look at the following ratio. It is a ratio of the cost of gas to the fuel efficiency of your specific vehicle.
Since gallon is on top and at the bottom, it will cancel in the ratio.
Now the ratio gives you the money spent per 30 miles.
To calculate money spent on gas for driving 90 miles, just multiply the ratio immediately above by 90.
Let us make a generalization of equation 1 above.
Suppose gas price is x and the efficiency of your vehicle is c CITY / h HWY
Notice that in c CITY / h HWY, c is city efficiency and h is highway efficiency.
In our example above c = 20 miles and h = 30 miles
D is the distance you drive your car on the highway
Total cost of gas =
x
h
× D +

x
c
× d

x
h
× D +

x
c
× d

Total cost of gas =
3
30
× 30 +

3
20
× 10

Total cost of gas =
90
30
+

30
20

Total cost of gas =
3
30
× 30 +

3
20
× 10

Total cost of gas =
90
30
+

30
20

The following calculator will estimate the cost of gas for any trip. You can use it as a trip planner.