My car gets 13 miles per gallon in the city and 30 miles per gallon on the highway. Suppose I used 15.867 gallons of gas and got an average of 15 miles per gallon for the trip.

How many gallons did I use for each part of the trip?

To determine the number of gallons used for each part of the trip (city and highway), we can set up a system of equations to solve for the unknowns.

Let's assume 'C' represents the number of miles driven in the city, and 'H' represents the number of miles driven on the highway.

From the given information, we can set up the following equations:

Equation 1: C + H = total distance traveled
Equation 2: C/13 + H/30 = total gallons used

We know the total distance traveled is equal to the average mileage multiplied by the total gallons used: total distance = average mileage x total gallons used.
Therefore, we have another equation:

Equation 3: (C + H) / (C/13 + H/30) = average mileage

Substituting the values into the equations:

Total distance = average mileage x total gallons used
= 15 miles per gallon x 15.867 gallons
= 238 miles

Equation 1: C + H = 238
Equation 2: C/13 + H/30 = 15.867

To solve these equations, we can use a method like substitution or elimination.

Using substitution:

From Equation 1, we can express C as C = 238 - H.
Now, substitute this expression for C in Equation 2:

(238 - H)/13 + H/30 = 15.867

Multiply the entire equation by the least common denominator, which is 390:

30(238 - H) + 13H = 15.867 * 390

7140 - 30H + 13H = 6213.93

Combine like terms:

-17H = 6213.93 - 7140
-17H = -925.07

Divide both sides by -17:

H = (-925.07) / (-17)
H ≈ 54.42

Now that we have the value for H, we can substitute it back into Equation 1 to find C:

C + 54.42 = 238
C ≈ 183.58

Therefore, for the trip, you used approximately 183.58 gallons in the city and 54.42 gallons on the highway.