Tuesday, May 3, 2016

Factorial

Question: What happens when we take a factorial of a negative number? How about a fraction/decimal? Why does it show up with the answer it gives?


Overview: We all know that the factorial of a natural number is just taking that number and multiplying it by every natural number down to one. 1! = 1, 2! = 2, 3! = 6, 4! = 24, 5! = 120, 6! = 720, (...) The issue is broken when we go back from Natural numbers to whole numbers. When we reach 0, the factorial doesn't go down from 1 to 0, it stays at 1. So what happens at a decimal?

The first thing I'm going to discuss is the fact that 0! = 1. At first, it's a bit strange, seeing as it should technically be 0. (Anything multiplied by 0 = 0.) But what we can do is look at it from a descending perspective. The current task is to get from the first factorial below to the second.





This should be simple, as n! = n * (n-1) * (n-2) ... , and (n-1)! = (n-1) * (n-2) * (n-3) ... . Simply enough, we can just divide off n and reach (n-1)! .








By following that logic, we can deduct the following image to contain true information. Because the logic can keep going, this clearly evaluates to 0! = 1. However, there's a certain flaw to this idea, which will be discussed below.

Negatives:
Assuming this statement is correct, this makes a small break when it comes to negatives. Nothing can be divided by 0. So when asked (-1)! , math gets broken. We would need 0!/0 , or 1/0. Undefined. This is why there are no integers below 0 with factorials. Going down to -2 would lead to undefined/-1. There's no such thing. Now, let's go into the odd section: Decimals and Fractions.


Fractions and Decimals:


Welcome to the world of "What the heck is going on?" This is the graph of x! where 10 ≤ x ≤ 3.2 . At least we can make some sense out of this graph so far. We have the whole numbers giving anything we would normally expect. 0! = 1 , and the numbers begin to exponentially grow. All the negative integers go to "undefined" (though unclear on the graph).

For the decimals, I decided to try looking at 0.5! , which is 0.886226925453.

My initial reaction was that it could be the result of a denominator and a numerator that were each factorials. But plugging it into the calculator yielded no fractions with that value. There goes that idea... The only fraction I can think of would be 886226925453/1000000000000.

My next reaction was to take the square root of some imperfect square. But the imperfect square would have to be less than 0.5, so how my next question is: What do we do from here? I'd rather not take the square root of a fraction, which will probably hurt me in the later-run of this exploration... So instead, I multiplied 0.5! by 2. This brings me up to 1.772453851. Alright, so now I feel like I'm getting places. I know this is the square root of a number less than 4, since that would be 2. If the square root was 2, I would be at 1.4... , and sqrt(3) = 1.73. I'm close, but just a bit below. But I don't see a reason for it to be a decimal, unless it was even at 3.5. So what's my next move? I've decided to try to square that value to see what I get. And it gives me... π? It is, unless somewhere down the line it changes away. It seems like 0.5! = sqrt(π)/2 . Well alright then. But it doesn't quite answer what happens for other things, and why does sqrt(π) work?

At this point, I think I've tried a large group of numbers, and a large number of equations to try and help myself solve this. I can't come up with a good relationship between a decimal and the square root of π in order to make a proper rule. And it doesn't exactly help that my calculator doesn't know how to do these factorials.

Edit: I've experimented with everything, even going into integrals (yes, I learned that on my own time), and I still can't find anything useful. I'm gonna Google it and write the results below.

So I found something called the Gamma Function. From what I understand, the Gamma Function is literally the Factorial Function, with the only add-on being shown like this: Γ(x) = (x-1)! . The gamma function, however, is the image below:



Let me explain what's going on in this as simply as possible. Γ(t) is just the way we name this function, similar to how we generally use f(x). But since this is a special (and a very advanced) function, we have a special name for it. After the equals sign, we have the "Integral." This basically takes the next part of the equation and finds the area formed by it from the lower bound (0) to the upper bound (infinity). The area is determined by the distance between the x axis and the function, enclosed by the integral symbol and "dx". The "dx" at the end just tells the integral "with respect to x," basically telling it to find the integral of anything between these 2 pieces of the function. The result is the factorial of the previous number. The below video is a quick simulation I made to simulate the integral of the above graph. The z in the function is essentially the constant, which is 1 higher than the constant you wish to factorial. I animated it on Desmos.



Apparently this only works for positive numbers, and there's an Alternate Gamma Function for negatives.

Sunday, May 1, 2016

Subway Sandwiches

Exploration:
Question: How many different combinations are there for sandwiches in Subway?

Background: In Math, we recently learned (or have been reminded of) a simple way to count the different outcomes, and Subway is infamous for the wide variety of sandwiches it can make, especially with the "Make Your Own Meal." This is where you choose the type and size of bread, the sandwich you want, topics, sauces, sides, beverages, and other things. For the following exploration, I will be using the menu below, which comes from this website.

Subway, Weston/Southwest Ranches Menu
*Note: Since my blog broke, the website has changed. This is a relatively old version of the menu. Some of my math will not match this version of the menu.

Several things to note beforehand:
  1. You have the choice at Subway to either toast or not toast the bread.
  2. You don't need to have everything. You can have no extra sauce or toppings if you want.
  3. I will assume you are here for a sandwich, maybe wanting a salad or side orders. You are thirsty in this scenario.
  4. You can have up to 4 vegetables per foot-long sandwich, 2 per 6-inch.
    1. I will assume you have at least 1 topping.
    2. The order you order these in will matter. Lettuce then tomato will be considered different from the other way around.
    3. You can have 1 sauce only, assuming you choose to.
  5. You can have repeats of the vegetables, so 2 tomatoes and 2 lettuce are options.
  6. All my information either comes directly from the Subway Website, or from past experience.
Process (All values are in bold):
The first thing we need to determine is: What kind of sandwich do we want? There are 16 types of sandwiches, as shown in the center of the image. After that, we determine the size. We can have either 6-inch or foot-long. This brings us to a total of 32 possibilities. Next, we can bring in the type of bread. There are 6 types of bread, and they can be toasted or not toasted. This brings us to 384 (32*12) possibilities so far. Now, we can have up to 4 toppings. Having at least 1, we'll set this to 8*9*9*9, so that you have at least 1 topping, and say no to the other 3. It's a bit strange, the way I'm doing it, as you can say no to a second, and end up with a 3rd and 4th, but this is the way I'm sticking with. Just for simplicity. Now, we're up to 2,239,488 possibilities already. Finally, we add a sauce. You can say no. According to the above image, there are 8 sauces, with a 9th being "none." With this, we are now up to 20,155,392 possibilities. How about an extra in the sandwich? The bottom left shows extra items you can add into the sandwich: Extra cheese, beef strips, double meat, or extra pepperoni. Because each of these are different options, we now multiply our previous number by 16, as it's "cheese or no cheese, meet or no meet, (...) ". We now have 322,486,272 possibilities. We can't forget about the salad you may or may not want. Multiply by 5 to get one of these or none: 1,612,431,360 possibilities. There are also 5 side orders you can choose to get, a 6th would be none, and I'm assuming you can only get one: 9,674,588,160. Last but not least, you're gonna need a drink to quench the thirst of all those different combinations: Multiply by 3, since we're assuming you have to get a drink. 29,023,764,480. This is the number of possibilities you can get in terms of sandwiches.

That would be annoying to make a tree diagram for... So many branches that keep going until you get to over 29 billion outcomes...

This large number means you would be able to go to Subway for over 29 billion days and get something different every day. This would be equivalent to 79,517,162.959 years.

My math may or may not be wrong, I would just like to point that out.