MPG Calculator Formula

Understand the math behind the mpg calculator. Each variable explained with a worked example.

Formulas Used

Miles Per Gallon

mpg = miles_driven / gallons_used

Liters per 100 km

liters_per_100km = 235.215 / (miles_driven / gallons_used)

Fuel Cost per 100 Miles (@$3.50/gal)

cost_at_350 = 100 / (miles_driven / gallons_used) * 3.50

Variables

VariableDescriptionDefault
miles_drivenMiles Driven(miles)350
gallons_usedGallons Used(gal)12.5

How It Works

How to Calculate MPG

Divide the total miles driven by the gallons of fuel consumed.

Formula

MPG = Miles Driven / Gallons Used

Conversion to L/100km

L/100km = 235.215 / MPG

Worked Example

You drove 350 miles and used 12.5 gallons.

miles_driven = 350gallons_used = 12.5
  1. 01MPG = 350 / 12.5 = 28.0 MPG
  2. 02L/100km = 235.215 / 28.0 = 8.4 L/100km
  3. 03Fuel cost per 100 miles = 100/28 x $3.50 = $12.50

Ready to run the numbers?

Open MPG Calculator