We can write:
$6 for 2 miles or less (fixed).
$2 for every additional mile after 2 miles.
$4 for every additional mile after 6 miles.
We have a function defined by parts:
For 0
For 2<=x<6, the function is f(x) = 6 + 2(x-2).
For x>=6, the function is f(x) = 6 + 2(x-2) + 4(x-6)
Between 1 mile and 2 miles, the cost is fixed in $6.