# Step Functions - Problem 3

###### Transcript

Step functions occur a lot actually in the real world and a couple examples are of if you go to the post office and you mail a package, your base rate is going to be something and if it's a certain amount of weight, what's going to happen is that your price is going to jump, it's not actually a fluid climb between two weight classes.

Somewhere it currently happens in a parking structure. If you go to park your car for a certain little while, what ends up happening is you pay a certain amount for the first hour, after an hour your price jumps up to the next hour, so what really is going to happen is it's a step, you jump from one rate to the next rate.

The example we're going to look at now is a taxi ride and basically what we have is a situation set up. Taxi ride is San Francisco charges a base rate of $3. Each fifth of a mile or fraction thereafter is 50 cents. Each minute of waiting or traffic delay is 50 cents and then given an airport sub-charge of $2. How much would it cost me from to my house which is 14 point 1 miles with 3 minutes and 17 seconds of traffic delay.

So I just want to put in some clarification of this, each fifth of a fraction thereof or each minute or fraction thereof. Basically what is happening is for each fifth of a mile you go into, you pay 50 cents, so if you travel anything less than a fifth of a mile, you still pay that 50 cents. You go a block more than a fifth of a mile, you're now into your second fifth of a mile and you're actually going to end up paying for that entire fifth of a mile so you pay a dollar.

So no matter which fifth of a mile you go into, you are going to end up paying for that. Same for the minute of waiting time. You wait for a minute exactly it's 50 cents, you wait for a minute and 1 second, it's going to jump up to be a dollar.

So there's a lot of information in this problem, so what I've done is taken out the bulk of it and written on the board over here. So what we have is our four different fees; our base rate, our fifth of a mile, our waiting time and our airport charge and my trip being broken down into 14.1 miles, 3 minutes and 17 seconds of waiting time and we are going with the airport.

So let's first talk just our set fees. So we have the base fee which is 3 and the airport which is going to be 2, so right there I made 5 dollars. Now I want to talk about our distance; 14.1 miles and the way I'm going to think about this is I'm going 50 cents per fifth of a mile there's five-fifths in a mile so this is actually 5 times 50, this correlates to 250 per mile.

So what I have then is 14 of those 250s, so I have my base and my airport and let's jump to distance, so that's going to be 250 times 14, where is my eraser, 250 times 40 and that still hasn't allotted for that .1. One-fifth as a decimal is .2 so what I actually have is just have to pay for that one extra fifth of a mile, so this is then going to be plus we'll just say .5 because we're working in dollars. So I have my base fee, my airport fee and my distance fee.

The last thing we have to do is waiting time, let's do that in blue. Waiting for 3 minutes and 17 seconds, my fee for waiting is 50 cents a minute, so for the 3 minutes I have to pay a dollar and 50, but I have that 17 seconds and remember that's going to round up, so I'm actually paying for 4 minutes of waiting time, 4 times 50 cents which is going to be $2. So then all we have to do is add up all of our various fees.

So we add it together 3 for our base fee, 2 for our airport, add in our 2 and a half times 14 plus 50 cents for our distance fee and then add in our $2 for our waiting fee and we end up with a grand total of $42 and 50 cents, not the cheapest rate.

So what we've really done here is looked at a number of different step functions thrown in together. So there's really a step function for the distance, there's also a step function for the waiting time as well and what we've done is we've tackled both of those in a single problem.