tag:blogger.com,1999:blog-43971593623958401982024-06-02T03:12:08.989-07:00My Math DiaryIn this blog I will post about my mathematical questions, answers, little coding experiments, my friends' questions etc.Suhttp://www.blogger.com/profile/02056139727550558490noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-4397159362395840198.post-84583798847752804112022-03-21T14:44:00.001-07:002022-03-22T14:15:26.799-07:00How many towers can you build such that a layer cannot have more blocks than the last one?<p> Or in mathematical words:</p><p>How many possible combinations for $1 \le i_1 \le ... \le i_k \le n $?<br /></p><p>This week's problem was inspired by a simple question from my discrete mathematics class. The original question the teacher asked was:</p><p>\[a_n = |(i_1,...,i_k) \in \mathbb{Z}^k :1 \le i_1 < ...<i_k \le n| \]</p><p>The answer to this question is $\binom{n}{k}$ since we are picking k many different numbers smaller than n. Afterwards a simple question came to my mind. What's $b_n$ such that:</p><p>\[b_n = |(i_1,...,i_k) \in \mathbb{Z}^k :1 \le i_1 \le ... \le i_k \le n| \]</p><h3 style="text-align: left;">The Visualization <br /></h3><p>If these notations seem a bit confusing there is another way to ask these questions. Let's say $a_n$ is the number of possible buildings with k many floors such that every floor has at least 1 and at most n rooms and such that a floor must have less rooms than the one below it. And $b_n$ is the number of possible buildings with k many floors such that every floor
has at least 1 and at most n rooms and such that a floor can have at most as many rooms as the one below it. So, $a_n$ is the number of possible card towers while $b_n$ is the possible towers built using small building blocks.You can visualize the possible buildings for $b_2$ where k=3 as:</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEioUYZoz6dCSzGY7awbF78Sxj22jB6J1xACc8QSdQ7E9g56OPCduSSwdPxLOv-afc9l9ir4JY2_pL5k-jutz-y8vuwlj-N5xtcVlr1qvpSi4MBkNnMscdgV9f7koOpAjIGe56103tcjMfxIMeVKzuCpg8dH20bVlznbGxrQjK8ugSxdbAcdnL0dBkO0Aw=s926" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="354" data-original-width="926" height="122" src="https://blogger.googleusercontent.com/img/a/AVvXsEioUYZoz6dCSzGY7awbF78Sxj22jB6J1xACc8QSdQ7E9g56OPCduSSwdPxLOv-afc9l9ir4JY2_pL5k-jutz-y8vuwlj-N5xtcVlr1qvpSi4MBkNnMscdgV9f7koOpAjIGe56103tcjMfxIMeVKzuCpg8dH20bVlznbGxrQjK8ugSxdbAcdnL0dBkO0Aw=s320" width="320" /></a></div><br /><h3 style="text-align: left;">The Initial Instinct <br /></h3><p>When you look at this question, it looks simple enough but if you try to fight it head on you'll realize that it gets very complicated. </p><p>Let's try to calculate the number of possibilities such that there are no equal pairs. The answer is $\binom{n}{k}$ like we did earlier.</p><p>Then it's time to calculate the number of possibilities such that there is only 1 pair of equal numbers. So we'll pick $\binom{n}{k-1}$ many different numbers and then, we'll pick one number to be the equal pair. So the answer for this sub question is $\binom{n}{k} \times \binom{k-1}{1}$. Seems easy enough.</p><p>But when we have to calculate other possibilities such as where there are 2 distinct pairs, where there 3 of the $i$'s which have the same value, where 3 of the i's have the same value and there is an extra pair etc etc it becomes a very long equation. While working on it, I asked my good friend Nevzat Akkaya if he had any ideas. He came up with a pretty elegant idea. So the credit goes to him.</p><h3 style="text-align: left;">The Solution</h3><p style="text-align: left;">We know that there are $k-1$ many signs between the $i$'s when we try to order them. So instead of trying to calculate a formula where we decide how many $i$'s are gonna be equal, we decide how many signs will be "=" and how many of them will be "<". But in order to prove the question this way, first, we have to see:</p><p style="text-align: left;">-<i>If we have n many numbers and we order them using only "<" and "=", then there is only one possible ordering. </i></p><p style="text-align: left;">Well this is clear due to $\mathbb{Z}$ being a well ordered set.</p><p style="text-align: left;">Now let's say we have $x$ many distinct numbers. Then we must have $x-1$ "<" signs and subsequently $(k-1)-(x-1)=k-x$ many "=" signs. How many orderings of these sign are possible? Well the answer is: $\frac{(k-1)!}{(x-1)! \times (k-x)!}$. </p><p style="text-align: left;">When we have an ordering of signs, there is only 1 possible way to fill the slots up since there are $x-1$ many "<" signs and x many distinct numbers. The slots between the "=" signs already fill themselves up. </p><p style="text-align: left;">We are assuming that $n \geq k$ (if not just let $\binom{n}{k}$s where $k >n$, equal to zero). Then the answer is:</p><p style="text-align: left;"> \[ \binom{n}{1} \times \frac{(k-1)!}{(1-1)! \times (k-1)!} + \binom{n}{2} \times \frac{(k-1)!}{(2-1)! \times (k-2)!} + ... + \binom{n}{k} \times \frac{(k-1)!}{(k-1)! \times (k-k)!} \]</p><p style="text-align: left;"> \[= \sum_{i=1}^{k} \binom{n}{i} \frac{(k-1)!}{(i-1)! \times (k-i)!} \] </p><p style="text-align: left;">We finially get the answer:</p><p style="text-align: left;">\[ \sum_{i=1}^{k} \binom{n}{i} \binom{k-1}{i-1} \]<br /></p><br /><p style="text-align: left;"><br /></p>
<div><div style="text-align: left;"><script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js" type="text/javascript">
MathJax.Hub.Config({
extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
},
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script>
</div></div>Suhttp://www.blogger.com/profile/02056139727550558490noreply@blogger.com5tag:blogger.com,1999:blog-4397159362395840198.post-12772413924197789122022-03-06T09:05:00.006-08:002022-03-22T14:18:15.347-07:00Biggest k such that n over k is less than or equal to n!<p>Let's find the biggest k such that $n^k \le n! $<br /></p><p>In an introductory class for the induction method, one of the common examples given by the teachers is "prove that $n^n \ge n!$". This problem is intuitive since both of the sides are calculated doing n different multiplications while in $n!$ the multipliers are generally less than n. </p><p>While the teacher was proving this in the whiteboard, I came up with a simple question: What is the biggest possible value for k such that $n^k \le n! $. At first I wanted k and n to be an integers but the question can be solved in a similar manner if k is a positive real number. You should try to solve it on your own but here's my solution:</p><p>Take the logarithm of both sides with your favorite base:<br /></p><p>\[\ln{n^k} \le \ln{n!} \]</p><p>\[k \, \ln{n} \le \ln{n} +\ln{n-1}+....+ \ln{2} + \ln{1} \]</p><p>\[ k \le \frac{ \ln{n} +\ln{n-1}+....+ \ln{2} + \ln{1} }{\ln{n}} \]</p><p>Round k to the biggest possible integer such that this holds.<br /></p><div><div style="text-align: left;"><script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js" type="text/javascript">
MathJax.Hub.Config({
extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
},
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script> </div></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjIc9093ttEQ10TWPfSCZ_gfNCe1kjsctyPPSKkkhwlAmSjXcOovAyMq6pUTaR5F2cRYLRJG4HcI9rKgJ7cpqn3L2L3b_qoAsoO8-LCWr6JhPZ8oFMxiJIGquZOidMOSSCK2R68r_QYPgerMLXH8PRmyzSPkKKG5D0Y6P0Q93VEycHBUPXp4xcGaC1soA=s629" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="463" data-original-width="629" height="236" src="https://blogger.googleusercontent.com/img/a/AVvXsEjIc9093ttEQ10TWPfSCZ_gfNCe1kjsctyPPSKkkhwlAmSjXcOovAyMq6pUTaR5F2cRYLRJG4HcI9rKgJ7cpqn3L2L3b_qoAsoO8-LCWr6JhPZ8oFMxiJIGquZOidMOSSCK2R68r_QYPgerMLXH8PRmyzSPkKKG5D0Y6P0Q93VEycHBUPXp4xcGaC1soA=s320" width="320" /></a></div>As you can see when we plot the numbers it's a pretty linear graph but when we look at the ratio between n and k the graph changes:<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiYU7IPN-8U_vgyEgUdXUQ3IkEOQyEzRAEBwP8B9TL8Yx7ftGRz8lFdkQdkmqt5oGA7LN3Vs8iaWxys38LAw3TQl7CI4cKFXrAlwmCPgxcgmOvlpSxw1d89KcvRn5korfS69_0UFADZfcsvBCklzMz_q2CnJ2PUr2Yan0OfRtNFdK4bnUc4lp_VGC3F0w=s623" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="463" data-original-width="623" height="238" src="https://blogger.googleusercontent.com/img/a/AVvXsEiYU7IPN-8U_vgyEgUdXUQ3IkEOQyEzRAEBwP8B9TL8Yx7ftGRz8lFdkQdkmqt5oGA7LN3Vs8iaWxys38LAw3TQl7CI4cKFXrAlwmCPgxcgmOvlpSxw1d89KcvRn5korfS69_0UFADZfcsvBCklzMz_q2CnJ2PUr2Yan0OfRtNFdK4bnUc4lp_VGC3F0w=s320" width="320" /></a></div><p>And when we look at the limit using wolframalpha, just like you can see from the graph, n/k converges to 1.</p><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiWX2cTZutzliT8ZcXP23UKBehlLykG6IGtQHE318I3fX_dZkAfUTIZgg3olylhJioLz3k5W8mVyBcpgxYh-cmssKKuam3uVckiDWWRU2F0O_3J_vQOVwWSLoUBeF75Fz4N6e3Om4H7iG0MRU-NNZ-IVmuX5rP5qgi7K8Zatq0yfjd7A_vmzaq-SMfOCg=s496" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="237" data-original-width="496" height="153" src="https://blogger.googleusercontent.com/img/a/AVvXsEiWX2cTZutzliT8ZcXP23UKBehlLykG6IGtQHE318I3fX_dZkAfUTIZgg3olylhJioLz3k5W8mVyBcpgxYh-cmssKKuam3uVckiDWWRU2F0O_3J_vQOVwWSLoUBeF75Fz4N6e3Om4H7iG0MRU-NNZ-IVmuX5rP5qgi7K8Zatq0yfjd7A_vmzaq-SMfOCg=s320" width="320" /></a></div><p>You can find this sequence in <a href="https://oeis.org/A039960" target="_blank">OEIS</a> with the code number A039960.</p><p> <br /></p>Suhttp://www.blogger.com/profile/02056139727550558490noreply@blogger.com1tag:blogger.com,1999:blog-4397159362395840198.post-31490193239252792222022-02-27T03:27:00.006-08:002022-02-27T03:35:12.577-08:00Partitions and OEIS: On-Line Encyclopedia of Integer Sequences<div><div style="text-align: left;"><script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js" type="text/javascript">
MathJax.Hub.Config({
extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
},
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script>
<p> For this term I decided to take a non-credit lesson called Experimental Mathematics and in this course I've found out about an amazing tool called OEIS. OEIS stands for <span class="module__title__link">On-Line Encyclopedia of Integer Sequences. </span></p><p><span class="module__title__link">Basically it's an extensive list of interesting sequences. If you come across any sequence in your studies, you don't have to hit your head against a wall hoping to figure out the pattern. You just go to <a href="https://oeis.org/" target="_blank">here</a> and type it. If there exists a pattern in that sequence this site will probably tell you. For any sequence you type, you can find previous work done on that sequence.</span></p><p><span class="module__title__link">I cannot express how excited I am to have met this tool. A big part of my time this week was spent trying to find new patterns or looking up already existing sequences and reading about their other properties.</span></p><p><span class="module__title__link">Here are some interesting sequences:</span></p><p><span class="module__title__link"> 1, 101, 1001, 10001, 100001, 112233, 10000001, 100122, 1000011...</span></p><p><span class="module__title__link">Can you see the pattern? If not, worry not, just type it into OEIS.</span></p><p><span class="module__title__link">This is the sequence of smallest number whose digits can be permuted to get exactly n distinct palindromes.</span></p><p><span class="module__title__link"><span> </span>1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 2, 0, 1, 1, 3, 0, 2, 0, 2, 1, 1, 0, 4, 1, 1, 1, 2, 0, 3, 0, 3, 1, 1, 1, 5, 0, 1, 1, 4...</span></p><p><span class="module__title__link">Does this even have a pattern? Well yes it does, it is the number of even length factorizations of n into factors greater than one.</span></p><p><span class="module__title__link"><span> </span>7, 13, 19, 23, 31, 79, 97, 103, 109, 139, 167, 193, 239</span></p><p><span class="module__title__link">Well these are clearly prime but what kind of prime? They are happy </span><span class="module__title__link"><span class="module__title__link">:)</span> primes! Happy prime is a prime that eventually reaches 1 under </span>iteration of "x -> sum of squares of digits of x".</p><p></p><p></p><p></p><p></p><p><span class="module__title__link">You get the point. This is an extremely strong tool for those who like to mess around with numbers. The thing I messed around with most this week was partitions.</span></p><h4 style="text-align: left;"><span class="module__title__link">Integer Partitions</span></h4><p style="text-align: left;"><span class="module__title__link"> Partition is a collection of ways to sum positive numbers to get n. For example the partitions of 4 are:</span></p><p style="text-align: center;"><span class="module__title__link">4=4<span> </span>4=3+1<span> </span>4=2+2<span> </span>4=2+1+1<span> </span>4=1+1+1+1</span></p><p style="text-align: left;"><span class="module__title__link">Can you think of a function that gives the numbers of partitions of n? Here are the first 15 integers:<br /></span></p><p style="text-align: left;"></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEg77nT08p4I4D0rz7ZFtWRB1OpuXhbyH-5sw8xh8ajNRaYQzOn41SYs9RZarXBZNKr1una3vsVxynu3NRMFJkrG4vVcIJ6CcDW5G0TtYmuO9NPxlp9m5_aYNZU2P1vTd7ndcRg2hm81P1I2L5ZLFDBEXjdIfEQaWI3YtDd-5CoP0qdX-bT20ezKKe3G9Q=s443" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="443" data-original-width="108" height="320" src="https://blogger.googleusercontent.com/img/a/AVvXsEg77nT08p4I4D0rz7ZFtWRB1OpuXhbyH-5sw8xh8ajNRaYQzOn41SYs9RZarXBZNKr1una3vsVxynu3NRMFJkrG4vVcIJ6CcDW5G0TtYmuO9NPxlp9m5_aYNZU2P1vTd7ndcRg2hm81P1I2L5ZLFDBEXjdIfEQaWI3YtDd-5CoP0qdX-bT20ezKKe3G9Q=s320" width="78" /></a></div><br /><p><span class="module__title__link">My initial instinct to approach this problem was incorrect. I had thought that </span></p></div><div><span class="module__title__link">$f_1$(n)=[ </span><span class="module__title__link"><span class="module__title__link">$f_1$</span>(n-1) </span><span class="module__title__link"><span class="module__title__link">$f_1$</span>(1) + </span><span class="module__title__link"><span class="module__title__link">$f_1$</span>(n-2) </span><span class="module__title__link"><span class="module__title__link">$f_1$</span>(2) +...+ </span><span class="module__title__link"><span class="module__title__link">$f_1$</span>(1) </span><span class="module__title__link">$f_1$</span><span class="module__title__link">(n-1) ] / 2</span></div><div style="text-align: left;"><p><span class="module__title__link">This idea stemmed from the fact that a partition consisted of smaller partitions. But as you can clearly see you were counting some partitions way too many times. Plus, sometimes in even numbers you would get non-integer results.</span></p></div><div style="text-align: left;"><p><span class="module__title__link">During the lesson, we learned how to approach this kinda problem. If you are curious you can check it out <a href="https://en.wikipedia.org/wiki/Partition_function_(number_theory)">here</a>. But my mind got stuck on a question "Can I just substract some function from $f_1$ in order to get the result I want?" How many times am I counting the extra partitions? I changed the function a bit in order fix the even/odd problem. Then, I looked at the difference between the actual numbers of partitions vs $f_1$:</span></p><p><span class="module__title__link"></span></p><div class="separator" style="clear: both; text-align: center;"><span class="module__title__link"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjRK7ujfOu2DnvMBWr7dL9vSt2i1w4tZKd6lowNdYor4E3aCWI0oYNQKN5r0Gxdg7pQNcly5Nvg4vtHV_-6UvuTTgoStZOcpoh46gGTjvR8Le7UA2rGOjX9vmofqhVtYzLV40jtPsJ-BYr2x97O4gxMmrcPJwb1eolsnyJlgUxW43PKdI0yJDmPCFd7cA=s625" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="458" data-original-width="625" height="253" src="https://blogger.googleusercontent.com/img/a/AVvXsEjRK7ujfOu2DnvMBWr7dL9vSt2i1w4tZKd6lowNdYor4E3aCWI0oYNQKN5r0Gxdg7pQNcly5Nvg4vtHV_-6UvuTTgoStZOcpoh46gGTjvR8Le7UA2rGOjX9vmofqhVtYzLV40jtPsJ-BYr2x97O4gxMmrcPJwb1eolsnyJlgUxW43PKdI0yJDmPCFd7cA=w346-h253" width="346" /></a></span></div><span class="module__title__link"><br /> It looked proportional to the true partition function. So maybe I could get an answer from here. $f_1$'s result were:</span><p></p><p style="text-align: center;"><span class="module__title__link">[1, 2, 7, 11, 26, 40, 83, 120, 223, 320, 566, 784, 1310, 1802, 2922]</span></p><p style="text-align: left;"><span class="module__title__link">while the true results were: <br /></span></p><p style="text-align: center;"><span class="module__title__link">[2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176]</span></p><p style="text-align: left;"><span class="module__title__link"> I've searched OEIS for "</span><span class="module__title__link"><span class="module__title__link">1, 2, 7, 11, 26, 40, 83, 120, 223, 320, 566</span>" but unfortunately there wasn't a previously worked on pattern. </span></p><p style="text-align: left;"><span class="module__title__link">Then what happened was me trying many different ways to calculate what to substract. In the end I failed. I couldn't find a proper function to substract. Well that's just mathematics, you can't solve everything yourself. Maybe I'll be able to solve it in a few years, maybe not. </span></p><p style="text-align: left;"><span class="module__title__link">If you have any idea on how to solve this problem please mail me. I would be extremely happy.<br /></span></p></div></div>Suhttp://www.blogger.com/profile/02056139727550558490noreply@blogger.com0tag:blogger.com,1999:blog-4397159362395840198.post-7655393836075554562022-02-19T08:57:00.004-08:002022-02-19T10:34:56.359-08:00Farkle Kingdom Come Deliverance Best Strategy (Dice Games Chapter 2)<div><div><script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js" type="text/javascript">
MathJax.Hub.Config({
extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
},
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script>
<p>Farkle is a simple dice game in the video game Kingdom Come Deliverance. The aim is to reach 4000 points and the gameplay is kinda similar to <a href="https://www.mymath-diary.com/2022/02/blackjack-using-dices-dice-games.html">dice blackjack</a>. You start with 6 dice and you throw them. Certain dice have scoring value so you can put them aside and throw the rest of the dice again in hopes of scoring more points but if you don't get any scoring dice, you bust, i.e. "farkle". So it is smart to bank your points when you have too few dice left. Since farkle is an old game the scoring varies a lot. I decided to use the rules from the game Kingdom Come Deliverance. Here is the scoring:</p><p><i>-a single <b>1</b>: 100 points</i></p><p><i>-a single <b>5</b>: 50 points</i></p><p><i>-<b>three of a kind</b>: 100 points multiplied by the given number</i></p><p><i>-<b>three 1's</b>: 1000 points</i></p><p><i>-<b>four or more of a kind</b>: Double the points of three of a kind</i></p><p><i>-full straight<b> 1 to 6</b>: 1500 points</i></p><p><i>-partial straight <b>1 to 5</b>: 500 points</i></p><p><i>-partial straight <b>2 to 6</b>: 750 points</i></p><p>You can combine these scorings. So for example, if you were to get {1,1,2,2,2,4}, the two 1's would be worth $100+100=200$ points and three of a kind 2's would be worth $2 \times 100=200$ points. Then when you set aside the scoring dice, only one die is left. You can either choose to bank the 400 points or roll again with only one die. Let's say we were to roll it again. If that die was a <b>1</b> or a <b>5</b>, i.e. a scoring die, when we set it aside we would get all the 6 dice back since there were no dice left. So we would roll again until we bank or farkle.<br /></p><h3 style="text-align: left;">My Solution<br /></h3><p>Now that we've learned about the game, it's time to find the best strategy and then test it. But since some parts of the game are too complex, I decided to make life easy for myself. You are always welcome to build upon my calculations. Maybe I'll make another post considering what I've left behind.<br /></p><p>First of all, the strategy doesn't count in what the opponent's score is. Of course it makes more sense to roll once again when the opponent is 50 points away from winning. In my game the only aim is to get to 4000 in the least amount of turns. I don't think that this is that big of a sacrifice and can easily be adjusted after I calculate the best strategy.<br /></p><p>Here is the biggest compromise I had to make in order to solve the problem: In the real game you can pick which scoring dice you will set aside but in my game you have to set aside all the scoring dice. If your first throw were {1,5,2,2,3,3} you cannot just set aside the 1 and throw remaining five dice, you have to set aside 1 and 5, then throw the remaining four dice. After all I am not trying to create an unbeatable AI, I am just trying to find a strategy that can guide people while playing the game. </p><h4 style="text-align: left;">This seems easy enough</h4><p style="text-align: left;">My first instinct was to just calculate the expected value for a $n$ dice throw like I did in my blackjack game. Expected value, intuitively, is the average score you get when you play the game infinitely many times. The formal definition is:<br /></p><p style="text-align: left;">Let
$X$ be the finite list of all possible outcomes $\{x_1, x_2,...,x_n\}$
where all outcomes respectively have the probability $\{p_1,
p_2,...,p_n\}$. Then the expected value is defined as </p><p style="text-align: left;">\[E[X]=x_1 p_1 + x_2 p_2 + ... + x_n p_n\]</p><p style="text-align: left;">If you want more more information on the expected value <a href="https://www.mymath-diary.com/2022/02/blackjack-using-dices-dice-games.html">click here</a> or <a href="https://www.youtube.com/watch?v=KLs_7b7SKi4">here</a>. </p><p style="text-align: left;">It was impossible for me to calculate the expected value given a dice throw by hand since there were so many possibilities. So I wrote a small program which calculated it for me. Basically a function took the average of all possible points for an $n$ dice throw. Here are the results:</p><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEj9git-I10cxdtuRXbAcL4NsW2EZCo4QRHxIwOPlO1reu8HhqXhLpQuIziSd3V7GX1fEdXZE0WaKQJVaJfxClIhsoXL67fN5awW1YapNkVH-BmYuK5CpnTKMEArv33V4Abty5ZoIWG2_7VCtJPk5_YaA0BvUYbrJbR7no9CvYs3vn1GcwW_98_brB66TQ=s1904" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="903" data-original-width="1904" height="250" src="https://blogger.googleusercontent.com/img/a/AVvXsEj9git-I10cxdtuRXbAcL4NsW2EZCo4QRHxIwOPlO1reu8HhqXhLpQuIziSd3V7GX1fEdXZE0WaKQJVaJfxClIhsoXL67fN5awW1YapNkVH-BmYuK5CpnTKMEArv33V4Abty5ZoIWG2_7VCtJPk5_YaA0BvUYbrJbR7no9CvYs3vn1GcwW_98_brB66TQ=w528-h250" width="528" /></a></div><span></span></div></div><div style="text-align: center;">Expected value of an $n$ Dice Throw<br /></div><br /><div><div><p style="text-align: left;">So for example if you were to throw three dice over and over again the average score you got on your throw would be approximately 93.75. Then I, and by "I" I mean the computer, calculated the possibility of a bust given a dice throw. Here are the results:</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjYbUf409mJdJSPx2nF-Rq1E86SUSwde6Bdd3jWpmGuqmCgJp3pNKWQ3e9OuDw6_EeDfqP7pa1REUX-9gMSvPIhZ7lbfFO8pAZcPAO6NsGUYXQ6JJngmn9xpMnrHxYtgWVhASKon1x7wx9U9D7lM6Al0yof79YyMIIFFyQcnShfB03fiQhYL9tmbxIhcw=s1904" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="903" data-original-width="1904" height="261" src="https://blogger.googleusercontent.com/img/a/AVvXsEjYbUf409mJdJSPx2nF-Rq1E86SUSwde6Bdd3jWpmGuqmCgJp3pNKWQ3e9OuDw6_EeDfqP7pa1REUX-9gMSvPIhZ7lbfFO8pAZcPAO6NsGUYXQ6JJngmn9xpMnrHxYtgWVhASKon1x7wx9U9D7lM6Al0yof79YyMIIFFyQcnShfB03fiQhYL9tmbxIhcw=w549-h261" width="549" /></a></div></div><div style="text-align: center;">Probability of a Bust of an $n$ Dice Throw<br /></div><div><p style="text-align: left;">After these findings my strategy was ready: Let's say you want to decide whether to bank your accumulated points or roll $n$ dice. If your points are more than what we expect to gain from the throw, then we should bank; roll otherwise. Let $P$ denote our points, $B$ our bust possibility and naturally $1-B$ our non bust possibility. Here is how we calculate when to throw:</p><p style="text-align: left;">\[P< (P+E) \times (1-B) + 0 \times B \]</p><p style="text-align: left;">\[P< P + E -BP -EB\]</p><p style="text-align: left;">\[BP< E \times (1-B)\]</p><p style="text-align: left;">\[P< \frac{E \times (1-B)}{B} \]</p><p style="text-align: left;">Then we got this graph:</p><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhPscWM2W48fUWrbnCn-ADFPkcENKuH_pk8976adDm8VMEfupU1CQ7CfzP1QCM7MnfXWcgOBzpRqTwUHokjXMqJToltD-SdqL9fjjrhvsVXz1Qf3EcjgnGvwU6APysAnaK43Z4NjnQiTFsHu6Gd5oTrC8PiTFZrpV0sC6dBv81joF6g5on4JkIEIgzSrw=s865" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="804" data-original-width="865" height="297" src="https://blogger.googleusercontent.com/img/a/AVvXsEhPscWM2W48fUWrbnCn-ADFPkcENKuH_pk8976adDm8VMEfupU1CQ7CfzP1QCM7MnfXWcgOBzpRqTwUHokjXMqJToltD-SdqL9fjjrhvsVXz1Qf3EcjgnGvwU6APysAnaK43Z4NjnQiTFsHu6Gd5oTrC8PiTFZrpV0sC6dBv81joF6g5on4JkIEIgzSrw=s320" width="320" /></a></div><p style="text-align: center;">WRONG Strategy <br /></p><p style="text-align: left;">Can you see where I went wrong? When I looked at this graph, I felt confused. It was clearly wrong. Then it hit me. </p><p style="text-align: left;">My expected values were wrong. Your 1 die throw's expected value has to be higher than 25 since if you roll a 5 or 1, you'll get back your 6 dice (and with those 6 dice the expected value is at least 487.). But the framework was ready, all I had to do was to just calculate the true expected values, right?</p><h4 style="text-align: left;">Okay maybe this is difficult.<br /></h4><p style="text-align: left;">I started to see everything difficult about calculating the expected value. The amount of remaining dice changed so I couldn't just multiply everything with a non-bust probability. Worst of all it was recursive. I had to know the expected value of 6 in order to calculate the expected value of 1 and in order the calculate the expected value of 6 I had to know the expected value of 1! The game had the potential to take an almost infinitely long time. If this game had less amount of possibilities I probably would be able to calculate it with pen and paper but there were just too many possibilities. I was about to give up, it was clear that I didn't know enough probability to solve this question. </p><p style="text-align: left;">Then I had a second revelation. I didn't have to be exact. I just wanted to create a chart that people could look at in order to decide whether to roll or not. Do you remember the intuitive definition of an expected value? I was just going to simulate the game 1,000,000 times with different amount of dice in order to calculate the approximate expected values. Thank god for computers, coming to my rescue when I can't solve a question on my own. Here are the approximate expected values:</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgVF8klvrzGCFIALfR4hvWGeOa7o9Qk_3sacXhe6VkhJVj3-zl_U_X402OFmW4RAVGAceYduSN0hg0ODDUbBHbFR7DUcIm-_tYjvVACaYlnU_ZJaeyz69Pa5KjNFE2J2wiaL6ZAEnE5JmZdR6zM3T7NjsJqcuVCY90yzQ8sT0eIhZDwHm-eEp_8sMnykA=s1904" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="903" data-original-width="1904" height="206" src="https://blogger.googleusercontent.com/img/a/AVvXsEgVF8klvrzGCFIALfR4hvWGeOa7o9Qk_3sacXhe6VkhJVj3-zl_U_X402OFmW4RAVGAceYduSN0hg0ODDUbBHbFR7DUcIm-_tYjvVACaYlnU_ZJaeyz69Pa5KjNFE2J2wiaL6ZAEnE5JmZdR6zM3T7NjsJqcuVCY90yzQ8sT0eIhZDwHm-eEp_8sMnykA=w434-h206" width="434" /></a></div></div><div style="text-align: center;">Approximate Expected Values<br /></div><div><p style="text-align: left;">So here is your cheat sheet while playing the game Farkle in Kingdom Come Deliverance:</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjl36ZEK_vUk2GPaNAWAv6TXOn745S1CnX48pjTJYylPJKie7MTXsC3WMnOnqZQvE5xzjOc5zdSYxWU4MkFc7piVxzloNBL_Hcwl6DLr0ANR3WlC-iFB3f1hs6FLGT34UrepdBMPsk0jzP8Z-lvIj__8QVpppI5XbIn-ZQwwnrOWnxdUsUPtIZwc7EZUQ=s909" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="780" data-original-width="909" height="321" src="https://blogger.googleusercontent.com/img/a/AVvXsEjl36ZEK_vUk2GPaNAWAv6TXOn745S1CnX48pjTJYylPJKie7MTXsC3WMnOnqZQvE5xzjOc5zdSYxWU4MkFc7piVxzloNBL_Hcwl6DLr0ANR3WlC-iFB3f1hs6FLGT34UrepdBMPsk0jzP8Z-lvIj__8QVpppI5XbIn-ZQwwnrOWnxdUsUPtIZwc7EZUQ=w374-h321" width="374" /></a></div></div><div style="text-align: center;">The Correct Strategy<br /></div><div><p style="text-align: left;">Of course this game is much more than this. I just tried to make a simple mathematical guide. After I take a probability course, I'll probably try to calculate the real expected value but for now this is good enough. Have fun playing.<br /></p><p style="text-align: left;"><br /></p></div></div>Suhttp://www.blogger.com/profile/02056139727550558490noreply@blogger.com1tag:blogger.com,1999:blog-4397159362395840198.post-71631951647680699502022-02-11T04:38:00.003-08:002022-02-12T01:54:06.098-08:00Blackjack Using Dice (Dice Games Chapter 1)<p>I'm starting a new series called "Dice Games". In this series, I'll make up a bunch of dice games/experiments. Then I'll try to calculate what'll happen using probability. In the end Monte Carlo method will decide if I was correct or not. If you don't know what Monte Carlo method is, it's basically a computer simulating the experiments using random inputs many times. </p><p>Let's start with the first game: <br></p><h2 style="text-align: left;">BLACKJACK USING DICE</h2><p style="text-align: left;">The objective of this game is simple, get as close to 21 as you can but don't surpass it. You'll start with a random 2 dice roll, then you can hit (roll a die and add it to your score) or pass (keep your score). To make it simple, I will ignore the dealer aspect of this game for now. I'm just trying to find the best winning strategy. Where should you stop? Any guesses?<br></p><h3 style="text-align: left;">My Solution</h3><p style="text-align: left;">Expected value is the average outcome if you were to roll a die a gazillion times. And it's defined as: </p><p style="text-align: left;">Let $X$ be the finite list of all possible outcomes $\{x_1, x_2,...,x_n\}$ where all outcomes respectively have the probability $\{p_1, p_2,...,p_n\}$. Then the expected value is defined as </p><p style="text-align: left;">\[E[X]=x_1 p_1 + x_2 p_2 + ... + x_n p_n\]</p><p style="text-align: left;">So for example let's calculate the expected value of a die. The list of all outcomes is $\{1,2,3,4,5,6\}$ with each of them having a probability of $\frac{1}{6}$. Then the expected value is </p><p>\[E[\textrm{dice}]= 1 \times \frac{1}{6}+2 \times \frac{1}{6}+3 \times \frac{1}{6}+4 \times \frac{1}{6}+5 \times \frac{1}{6}+6 \times \frac{1}{6} = \frac{7}{2}=3.5 \]</p><p>This means that if you had infinite time to roll a die and to write the outcome onto a paper, the average of your results be $3.5$. This makes sense right? So my winning strategy is:<i> </i></p><p><i>Hit if your score is less than $17.5$, pass otherwise.</i></p><p><i> </i>To see if this is a valid strategy I'll make my strategy play against these strategies:</p><p><i>1-</i><i>Hit if your score is less than $15.5$, pass otherwise.</i></p><p><i>2-</i><i>Hit if your score is less than $16.5$, pass otherwise.</i></p><p><i>3-</i><i>Hit if your score is less than $18.5$, pass otherwise.</i></p><p><i>4-</i><i>Hit if your score is less than $19.5$, pass otherwise.</i></p><p><i>5- </i><i>Hit if your score is less than $20.5$, pass otherwise.</i></p><h3 style="text-align: left;">Let's Simulate it<i> <br></i></h3><p>The ones with the biggest score less than 21 gets +1 point. They all get the same dice rolls so I think it's a fair game. Here are the results over 100,000 games:</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEioNu3fUFHBvlIgTQLOfkpKkrbCONn3HLTq7jHsAN6W6O-caT2ZHE_kCObPLjrxS5-tm6SOPrqKeyun7fww05plZlpwazAcmgK3yzVyZAo-tocJc8ZO5ejW-ruhzZ7hMj3Z4rKc8HRSRqwgxhAd5i6Wk8hWI4zgrQg6DGWCi-sIYY7Sc-wosF3uRXNkWw=s942" style="margin-left: 1em; margin-right: 1em;"></a><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEh-oQbHdKsxc9vLv7QhBNRCqYlig17aBBjMtPFBySTp0wkzjyGL7AqdASE8IwjHBStlB4r7xCQyC8JRFO4wl2j1CRHIyDw2FEgt6x1sEZWZwEpIcbPmNLepsP7a4WBza6ENe7AC6xDEBXmM-hawNHDSxLFzBAXI2r6hJYZzWx-Yx3SgMhO2uhSp0bOIdg=s1904" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="911" data-original-width="1904" height="194" src="https://blogger.googleusercontent.com/img/a/AVvXsEh-oQbHdKsxc9vLv7QhBNRCqYlig17aBBjMtPFBySTp0wkzjyGL7AqdASE8IwjHBStlB4r7xCQyC8JRFO4wl2j1CRHIyDw2FEgt6x1sEZWZwEpIcbPmNLepsP7a4WBza6ENe7AC6xDEBXmM-hawNHDSxLFzBAXI2r6hJYZzWx-Yx3SgMhO2uhSp0bOIdg=w408-h194" width="408"></a></div><br></div><br><p>As you can see $17.5$ was indeed the correct strategy with $18.5$ coming close. I've also included their average winning scores and average overall scores for those who like looking at data:</p><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgFV5tydO926n6MXqBrhtH6VW7CSK0iseHPZ-JrnLzoJLKDbqTzLuzW6ZvuquGrRYVtszje8BAQSWDwFAyGsjixBRPDhizD58DfowPkNvXrD-dWhoJE0s6keaDwk3ShEgMQ0GLBjSPumMyGyf-Y24B3d3hvbNHWWqJo0Q0WRi-drSM-5AbQpir4SATO2A=s1904" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="911" data-original-width="1904" height="202" src="https://blogger.googleusercontent.com/img/a/AVvXsEgFV5tydO926n6MXqBrhtH6VW7CSK0iseHPZ-JrnLzoJLKDbqTzLuzW6ZvuquGrRYVtszje8BAQSWDwFAyGsjixBRPDhizD58DfowPkNvXrD-dWhoJE0s6keaDwk3ShEgMQ0GLBjSPumMyGyf-Y24B3d3hvbNHWWqJo0Q0WRi-drSM-5AbQpir4SATO2A=w424-h202" width="424"></a></div></div><p></p><p style="text-align: center;">Blue is the average winning score, red is the average score throughout the games.</p><p style="text-align: left;"> Also here are how many times each strategy has busted:</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhsYOPN1Vmcp1YQiMXJUEsMT9fFU4u5F_f5oAwBZdRh9c1krRjwk-aR5-XnhCsyjVZjzOYfDqwXF_4prh70vh7J4OlQ1XBK46ez39zIypJaXKl_NDXs-D0Z0GFs-gMw6Wte5_TisoKaU4DFH7McSk_39aWiqGhmDNekdqG6NSGBGYbqt2BCyzLMnwjOeA=s1904" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="911" data-original-width="1904" height="230" src="https://blogger.googleusercontent.com/img/a/AVvXsEhsYOPN1Vmcp1YQiMXJUEsMT9fFU4u5F_f5oAwBZdRh9c1krRjwk-aR5-XnhCsyjVZjzOYfDqwXF_4prh70vh7J4OlQ1XBK46ez39zIypJaXKl_NDXs-D0Z0GFs-gMw6Wte5_TisoKaU4DFH7McSk_39aWiqGhmDNekdqG6NSGBGYbqt2BCyzLMnwjOeA=w481-h230" width="481"></a></div><br><p style="text-align: left;"><br></p><p style="text-align: left;"> So if we were to implement <i>"blackjack using dice</i>" game to a casino, we know what our strategy should be. But what if a dealer was involved? So you would win money if the dealer was bust but we wouldn't know what their first card was while hitting. Also, other player's scores wouldn't affect us. In blackjack the dealer has 16.5 as their stopping point (so 17 and higher means stop). But this is not really realistic since it means that the dealer can almost never bust (only possibility is 16+6). So in order to make our game more like blackjack, where should the dealer stop?</p><p style="text-align: left;">I will explore these questions in the upcoming weeks when I have time.<br></p><p><br></p><p><br></p><p>Edit: Thanks to reddit user u/PrestigiousCoach4479 I saw a mistake that I've made. The fact that my strategy won while competing with those 5 strategies didn't mean that it would beat each strategy in 1v1. It wasn't transitive. As the user put it: "Your method for evaluating strategies is intransitive in general. You
might have A beat B which beats C which beats A heads-up, and in a field
of 4 strategies, D which loses to the first three heads-up might be
first out of 4. Including a strategy that loses to the other strategies,
and comes in last, might change which strategy wins." </p><p>So let's test that. Thankfully my code was clean so it took only two minutes to configure it. Here are the results! </p><p>Note: Since 17.5's and 18.5's scores were very close, I made them play 50000000 games instead of 100000 games. They were still very close! <br></p><p><script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js" type="text/javascript">
MathJax.Hub.Config({
extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
},
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhM0oKvcMgKcGLtUvkzHdGuIgh6_LEdX6LD0QiVqhUtNLp6gk0iqMWAwkwQorNQqONsSzuLMhhNa6Sdu6pW9YV7vkwn5UJ7dX5Azf8fkg1urys8bFifeF_YjwfCCkRHE5C4hm4s7PwhQd2zU4v2u3FT7Hu4XOmoI2leoZDrccs35FVNL30tP9EudexAsA=s2000" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="2000" data-original-width="2000" height="336" src="https://blogger.googleusercontent.com/img/a/AVvXsEhM0oKvcMgKcGLtUvkzHdGuIgh6_LEdX6LD0QiVqhUtNLp6gk0iqMWAwkwQorNQqONsSzuLMhhNa6Sdu6pW9YV7vkwn5UJ7dX5Azf8fkg1urys8bFifeF_YjwfCCkRHE5C4hm4s7PwhQd2zU4v2u3FT7Hu4XOmoI2leoZDrccs35FVNL30tP9EudexAsA=w336-h336" width="336"></a><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiUxq5X4bfixoGmVaE-UE9ImrGOCQBp0dyLFOpLESx2lro88q1y0upjfPNFjlkKIs_wXpujlzr6AULOMM4ogF8JIopIVAKAnpa-v9hYTv-2njg5yKdgAe6CpJ6hWjY_jRrq7h3w6Y22-cTXw268X82mHTGFsNDBbyyz2NosZ_u0BpomfzoblGePRuEUAg=s942" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="910" data-original-width="942" height="309" src="https://blogger.googleusercontent.com/img/a/AVvXsEiUxq5X4bfixoGmVaE-UE9ImrGOCQBp0dyLFOpLESx2lro88q1y0upjfPNFjlkKIs_wXpujlzr6AULOMM4ogF8JIopIVAKAnpa-v9hYTv-2njg5yKdgAe6CpJ6hWjY_jRrq7h3w6Y22-cTXw268X82mHTGFsNDBbyyz2NosZ_u0BpomfzoblGePRuEUAg=s320" width="320"></a></div><br></div>Alas 17.5 still won...Suhttp://www.blogger.com/profile/02056139727550558490noreply@blogger.com0tag:blogger.com,1999:blog-4397159362395840198.post-87828923824424013052022-02-03T06:40:00.024-08:002022-02-03T07:06:35.000-08:00Proving the Perimeter of a Circle <script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js" type="text/javascript">
MathJax.Hub.Config({
extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
},
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script>
<p> </p><div dir="auto">What is the perimeter of a circle? This is a very easy question right? $2 \pi r$ of course. Well why? This was the simple question that bothered my mind last weekend. I thought of some proofs myself and made many mistakes along the way.<div dir="auto"><br /></div><div dir="auto">It seemed like a simple integral: $ \int_0^{2 \pi} \! r \, \mathrm{d} \theta $. Since $d \theta \times r$ gives us the arc length, taking the integral from $0$ to $2 \pi$ (basically making a full turn) gave us the perimeter. The problem with this solution was that it felt like cheating! How did I even know the arc length? </div><div dir="auto"><br /></div><div dir="auto">My next idea was pretty straight forward as well. Firstly I defined a simple sequence: let $x_n$ be the perimeter of an n-sided regular convex shape circumscribed in a circle of radius $r$. So for example:</div><div dir="auto"> </div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiamT65DOL8z65BqYga2W5lAkur3tSPUhpsSbVCsAQVM_wH7-j835Iypcpzu1w9AkbE6JX9CR03jDdt-nhT_E0d6QAJfqDKsieiT2SlTfGZzl_ke2YheIkBMcMuYNm2gg1nTGsxXaLcTZBGTbksdfJyOAb2BY8kcNXGT9eEpNswRTPGZzxHtXAdEc7KsQ=s2397" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="658" data-original-width="2397" height="156" src="https://blogger.googleusercontent.com/img/a/AVvXsEiamT65DOL8z65BqYga2W5lAkur3tSPUhpsSbVCsAQVM_wH7-j835Iypcpzu1w9AkbE6JX9CR03jDdt-nhT_E0d6QAJfqDKsieiT2SlTfGZzl_ke2YheIkBMcMuYNm2gg1nTGsxXaLcTZBGTbksdfJyOAb2BY8kcNXGT9eEpNswRTPGZzxHtXAdEc7KsQ=w569-h156" width="569" /> </a></div><div dir="auto"></div><div dir="auto"></div><div dir="auto"></div><div dir="auto"></div><div dir="auto"> </div><div dir="auto">Then clearly as n goes to infinity, we would get the perimeter of the circle. So all that was left to do was to find the formula and take the limit. </div><div dir="auto"></div><div dir="auto"></div><div dir="auto"></div><div dir="auto"></div><br /><div dir="auto"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjpoVtFqbXNVSmYd2G9w60w5uOGROUGbJna2tsYPB2uDCygn5MU-oWF712_IWCX9_OdqaTFp1isdRkiayLs9ClX0LRjGiVmP-lWPuI3id_DgR3X7qc7B_fbihSZfwJHTdSxykACdGRUbWci5manXASC815HZRd4QdF-OA09xWG34XPozKKW9VLtpM7R_Q=s1488" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="935" data-original-width="1488" height="201" src="https://blogger.googleusercontent.com/img/a/AVvXsEjpoVtFqbXNVSmYd2G9w60w5uOGROUGbJna2tsYPB2uDCygn5MU-oWF712_IWCX9_OdqaTFp1isdRkiayLs9ClX0LRjGiVmP-lWPuI3id_DgR3X7qc7B_fbihSZfwJHTdSxykACdGRUbWci5manXASC815HZRd4QdF-OA09xWG34XPozKKW9VLtpM7R_Q=s320" width="320" /></a></div><br />Since the sum of all outer angles in a convex shape equals $2 \pi$ and since this shape is regular, $2 \theta= \pi - \frac{2 \pi}{n}$. Then one side of the polygon is $2 \times r \times cos(\theta)$.</div><div dir="auto">Thus, the perimeter of $x_n$ circumscribed in a circle is: </div><div dir="auto">\[x_n = n \times 2 \times r \times cos(\theta)\]</div><div dir="auto">\[ x_n = n \times 2 \times r \times cos(\frac{ \pi - \frac{2 \pi}{n}}{2}) \] <br /></div><div dir="auto"> </div><div dir="auto"> <br /></div><div dir="auto">\[\lim_{n \to \infty} x_n = \lim_{n \to \infty} \left[ n \times 2 \times r \times cos(\frac{ \pi - \frac{2 \pi}{n}}{2}) \right] \]<br /></div><div dir="auto">\[ \lim_{n \to \infty} x_n= 2 \times r \times \lim_{n \to \infty} \left[ n \times cos(\frac{ \pi - \frac{2 \pi}{n}}{2}) \right] \]<br />Let's solve the limit:<br />\[\lim_{n \to \infty} \left[ n \times cos(\frac{ \pi - \frac{2 \pi}{n}}{2}) \right] = \lim_{n \to \infty} \left[ n \times cos(\frac{\pi}{2} - \frac{\pi}{n}) \right] \]</div><div dir="auto">\[= \lim_{n \to \infty} \left[ n \times sin(\frac{\pi}{n}) \right]= \lim_{n \to \infty} \left[ \frac{sin(\frac{\pi}{n})}{\frac{1}{n}} \right] \]<br />\[\stackrel{L'H}{=}\lim_{n \to \infty} \left[ \frac{cos(\frac{\pi}{n})\times (-\frac{\pi}{n^2})}{-\frac{1}{n^2}} \right] = \pi \times \lim_{x \to \infty} cos(\frac{\pi}{n})= \pi\]</div><div dir="auto">Then finally we find the perimeter of a circle: $2 \pi r$. We could have proved the perimeter of a circle in a similar manner, this time defining $x_n$ as the perimeter of an n-sided regular convex shape inscribed in a circle of radius $r$.</div><div dir="auto"> <br /></div><div dir="auto"></div><div dir="auto"></div><div dir="auto">This proof didn't satisfy me as well but I didn't exactly know why. Using trigonometric functions felt like cheating, since, their intuition came to me from a circle. These trigonometric functions probably already used the perimeter formula in some way. I was using the thing that I wanted to prove as an hypothesis. </div><div dir="auto"> </div><div dir="auto">I got annoyed. The perimeter formula had $\pi$ in it! How was I supposed to find $\pi$ without using trigonometric functions or radians (which were already based on the perimeter of a circle)? Then it suddenly hit me! I had forgotten one of the sacred rules of mathematics, I had ignored the definitions.My stupid mistake hit me in the face:</div><div dir="auto"> </div><div dir="auto">\[ \pi = \frac{\textrm{perimeter}}{\textrm{diameter}}\]</div><div dir="auto"> </div><div dir="auto">OF COURSE THE PERIMETER WAS $2 \pi r$! It was in the definition. There was nothing to prove. </div><div dir="auto"> </div><div dir="auto">But I didn't want to come out with my hands empty. Since $\pi$ was just a ratio, I wanted to prove that this ratio was constant and didn't depend on the radius. This is where my sequence came in handy! If we have two different circles, their $x_n$ ratios will equal to their radius ratios. In other words, the ratio of their perimeters will equal the ratio of their radiuses. Thus there really is a fixed ratio between the perimeter and the diameter, independent of the length of the radius. </div><div dir="auto"> </div><div dir="auto"><b>And we call this ratio $\pi$!</b></div><div dir="auto"><b> </b></div><div dir="auto"><i>PS. I'm guessing that cosine function kind of depends on this ratio being fixed so I am probably just repeating my mistake. This problem will stay in my mind and you can expect to see a new blog posts when I have some answers.</i><b><br /></b></div><div dir="auto"><br /></div><div dir="auto"><br /></div><div dir="auto"></div><div dir="auto"></div><div dir="auto"></div><div dir="auto"></div><div dir="auto"></div><div dir="auto"></div><div dir="auto"></div><div dir="auto"></div><div dir="auto"> <span> </span><span> </span><span><br /></span></div></div>Suhttp://www.blogger.com/profile/02056139727550558490noreply@blogger.com2tag:blogger.com,1999:blog-4397159362395840198.post-1340808252565390442022-01-25T13:32:00.004-08:002022-01-25T15:05:16.034-08:00Differences between sup / inf and lim sup / lim inf<p>Students who took the Calculus class like me will learn about two very similar concepts: the sup / inf of a sequence and the lim sup / lim inf of a sequence. While these two terms are very similar there are some fundamental differences between them. My friend asked my why they are not equal so I decided to write this blog post. Let's start by giving the formal definitions, then I will try to give an intuitive explanation as to why they are different.</p><p> </p><p>The definitions for the supremum and the infimum use the terms upper bound and lower bound. Let S be a nonempty subset of $\mathbb{R}$, </p><p>$u$ is called an upper bound of S if $ \forall x \in S $ $ u \ge x $. </p><p>The set of all upper bounds is denoted by $ U_S $. And similarly, </p><p>$l$ is called an lower bound of S if $ \forall x \in S $ $ l \le x $. </p><p>The set of all lower bounds is denoted by $ L_S $.</p><p>For example if you have the set <i>[0,1]</i> then 10 is an upper bound since 10 is bigger than any number between 0 and 1. 1 is also an upper bound since it is bigger or equal to any number between 0 and 1.</p><p> </p><p>A real number M is called the least upper bound of S or the supremum of S or just simply sup S if:</p><p>$M \in U_S$ and $\forall u \in U_S$ $M \le u$</p><p>A real number m is called the greatest lower bound of S or the infimum of S or just simply inf S if:</p><p>$m \in L_S$ and $\forall l \in L_S$ $m \ge l$ </p><p>Like in the above example both 10 and 1 are upper bounds, but only 1 is the supremum since it is the smallest upper bound. </p><p><br /></p><p>Let ${x_n}$ be a sequence in $\mathbb{R}$. We define,</p><p> \[ \text{lim sup }x_n := lim_{N \rightarrow \infty} sup\{x_n : n>N\} \]</p><p> \[ \text{lim inf }x_n := lim_{N \rightarrow \infty} inf\{x_n : n>N\} \]</p><p>Intuitively you can think this as dismissing the first terms of the sequence and just looking at the supremum in the most right side of the graph. The difference between them is that lim sup $x_n$ can be smaller than the supremum. The best example that I can give to this is:</p><p>\[ x_n := \begin{cases} 100 & n=1 \\ 1 & n \ne 1 \end{cases} \]</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhUijO_kzso8hxc3qyIQUAexJKca5nWiqJQ0MflILDXtn04-WRBZktsR_CXX1MHFvFVaXAbAE4i8Y5sXxo0qPH1IeWg8B4OgQH9cY0ieoGS1xov8jY3eVOa_OTH5a6RsOb5WY_Aanrcx1bKiwKlSoitX5wJmcAGTsylZj6ZPSbNkTSy2e0S8C32YQ3ZhA=s2187" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1008" data-original-width="2187" height="147" src="https://blogger.googleusercontent.com/img/a/AVvXsEhUijO_kzso8hxc3qyIQUAexJKca5nWiqJQ0MflILDXtn04-WRBZktsR_CXX1MHFvFVaXAbAE4i8Y5sXxo0qPH1IeWg8B4OgQH9cY0ieoGS1xov8jY3eVOa_OTH5a6RsOb5WY_Aanrcx1bKiwKlSoitX5wJmcAGTsylZj6ZPSbNkTSy2e0S8C32YQ3ZhA=s320" width="320" /></a></div><br /> <p></p><p>sup $x_n=100$ while lim sup $x_n$=1 </p><p><br /></p><p>Another difference between them is that if $x_n$ converges, then lim sup $x_n$ = lim inf $x_n$. Of course we can prove this formally but that proof already exists in textbooks. I want to give an intuitive reason why for this. Think of</p><p>\[ y_n := \begin{cases} \frac{1}{n} & n \text{ is even} \\ -\frac{1}{n} & n \text{ is odd} \end{cases} \]</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEg3GDO7DMuMl9WlElM5HqrTSOqnckqaZpBGE5P1P_CRQ7jyFh4KkP9hiaa8eZH931IzNmL34vHm40uqIYDxop0kShPWl393LNX7zop1pfxPf2dR6TjDlxasmSP4X8R1BaaLxGNHIOSzViUb-XrqDXpYvKvM45sGYna8d_F7fnBfNPL9CoZtPNt0eUnbTw=s2204" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1148" data-original-width="2204" height="167" src="https://blogger.googleusercontent.com/img/a/AVvXsEg3GDO7DMuMl9WlElM5HqrTSOqnckqaZpBGE5P1P_CRQ7jyFh4KkP9hiaa8eZH931IzNmL34vHm40uqIYDxop0kShPWl393LNX7zop1pfxPf2dR6TjDlxasmSP4X8R1BaaLxGNHIOSzViUb-XrqDXpYvKvM45sGYna8d_F7fnBfNPL9CoZtPNt0eUnbTw=s320" width="320" /></a></div><br /> <p></p><p>sup $y_n=1$, inf $y_n=-1$ but lim sup $x_n$ = lim inf $x_n$= lim $x_n$ =0. As you can see from the graph, when we look at the right side, all of the values get invisibly close to zero, so among these numbers the supremum and infimum is zero.</p><p><br /></p><p>Of course my intuitive explanation might make mathematicians want to pull their hair out but in my opinion even if they help one person, it is good to have explanations like these.</p><p><br /></p><p>Note: The graphs were drawn by me so they are not precise. You get the point. If this post helped you understand something feel free to comment, it would certainly make my day.<br /></p><p><br /></p><p> </p><p> </p><p><script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js" type="text/javascript">
MathJax.Hub.Config({
extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
},
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script> </p>Suhttp://www.blogger.com/profile/02056139727550558490noreply@blogger.com0