 Sometimes, we use different formulas for different input values. For example, maybe shipping is $5.99, but free for orders over $100. Or maybe tuition costs $3,000 for up to six credits and an additional $300 per credit over six. And your bank might extort a convenience fee if your balance is under $25,000. Now it's important to recognize that in all of these cases there is still a function defined for each input, but the formula used depends on the input value. And this leads to what's called a piecewise function. Our notation for piecewise functions looks something like this. Here we have our function, and it's equal to, well in this case, three different formulas depending on the value of x. So if x is less than 100, we use the function 10. If x is between 100 and 150, we use 50x, and if x is greater than 150, we use x squared. We can still try to find function values as we have before. So for f of 10, we have x equal to 10, and so this means we'll use a formula for x less than 100. One way of looking at it is that for this particular value of x, these other two lines don't exist, and our function is just 10. So f of 10 is equal to 10. For f of 125, we have x equal to 125, and so we use the formula where x is between 100 and 150. And again, it's helpful to pretend that the other two lines of this function definition don't exist because we don't have x less than 100, and we don't have x greater than 150, so we'll cover them up. And our function definition says that f of 125 is 50 times 125, which gives us our function value. For f of 500, we have x equal to 500, so we use the formula for x greater than 150. And again, these first two lines aren't applicable because x is not less than 100, and x is not between 100 and 150, so we can ignore them. Our formula says to square 500, and so we get. Now if a piecewise function drops out of the sky and hits us on the head, we're probably walking in the wrong neighborhood. More likely, we're going to need to write the piecewise function, and we can also write a piecewise function by writing a formula to compute a function value and then identifying where the formula applies. For example, suppose a company charges $5.99 for shipping, but offers free shipping on orders over $100. Let s of x be the total cost when you order x dollars of merchandise. So a helpful strategy here is to try some examples to familiarize yourself with the problem. So suppose you order x equals $50 worth of merchandise. Then the total cost will be the cost of the merchandise plus the cost of shipping. Now the cost of the merchandise is $50, and since we have to pay for shipping on orders under $100, we have to pay that $5.99, and so our total cost is $50 plus $5.99. Now again, since we're trying to do the algebra, it helps NOT to do the arithmetic. So remember, equals means replaceable. Saying x equals 50 means that any place I see x, I can replace it with 50, well I don't see it anywhere, but also any place I see 50, I can replace it with x. And the important thing to remember is that because there is a change when our orders hit $100, this formula only applies on orders less than or equal to $100. And so when we write our function, we'll include the formula with a note that this is only good if x is less than or equal to $100. What if you order more than $100 worth of merchandise? So again, we can try some specific examples. If x equals $200, then again our total cost is the cost of the merchandise plus the cost of shipping, and so that's going to be $200 plus our shipping is going to be free, so it'll cost $0. And again, since x equals $200, we can replace $200 with x and get our formula. And so our formula, but this only applies on orders more than $100. So we can write down our formula with a note that this only holds if x is greater than $100. Or let's consider tuition. Tuition for our college costs $3,000 plus $300 per credit over $6. So write a function t of c, giving the cost of tuition when c credits are taken. And here we might notice that the formula changes when you go over six credits, so there's going to be two rules. A rule when the number of credits is less than or equal to six, and a rule when the number of credits is greater than six. So again, we can try some specific examples to see how this works. Suppose you take c equal to five credits. Then our tuition formula is $3,000 plus $300 per credit over $6. And since the number of credits we're taking five is less than six, then there are zero credits over six, and so t of five is equal to $3,000. And again, equals means replaceable. Since c is equal to five, we can replace five with c and get our formula, t of c is equal to $3,000, which is the rule for c less than or equal to six. What if you take more than six credits? So suppose you take eight credits. Then again, our tuition is $3,000 plus $300 per credit over $6. And this time, there are eight minus six credits over $6. Again, it helps not to do the arithmetic. What are we going to do with this amount? Well, since it's $300 per credit over $6, that means we're going to multiply this eight minus six by $300 and then add it to our $3,000. And since c equals eight, everywhere we see an eight, we can replace it with a c and get our formula, which applies wherever c is greater than six.