{"id":2563,"date":"2018-12-01T13:25:48","date_gmt":"2018-12-01T19:25:48","guid":{"rendered":"https:\/\/laurentlessard.com\/bookproofs\/?p=2563"},"modified":"2019-10-02T17:41:49","modified_gmt":"2019-10-02T22:41:49","slug":"alice-and-bob-fall-in-love","status":"publish","type":"post","link":"https:\/\/laurentlessard.com\/bookproofs\/alice-and-bob-fall-in-love\/","title":{"rendered":"Alice and Bob fall in love"},"content":{"rendered":"<p>In this interesting <a href=\"https:\/\/fivethirtyeight.com\/features\/alice-and-bob-fall-in-love\/\">Riddler problem<\/a>, we&#8217;re dealing with a possibly unbounded sequence of&#8230; children? Here it goes:<\/p>\n<blockquote><p>\nAs you may know, having one child, let alone many, is a lot of work. But Alice and Bob realized children require less of their parents\u2019 time as they grow older. They figured out that the work involved in having a child equals one divided by the age of the child in years. (Yes, that means the work is infinite for a child right after they are born. That may be true.)<\/p>\n<p>Anyhow, since having a new child is a lot of work, Alice and Bob don\u2019t want to have another child until the total work required by all their other children is 1 or less. Suppose they have their first child at time T=0. When T=1, their only child is turns 1, so the work involved is 1, and so they have their second child. After roughly another 1.61 years, their children are roughly 1.61 and 2.61, the work required has dropped back down to 1, and so they have their third child. And so on.<\/p>\n<p>(Feel free to ignore twins, deaths, the real-world inability to decide exactly when you have a child, and so on.)<\/p>\n<p>Five questions: Does it make sense for Alice and Bob to have an infinite number of children? Does the time between kids increase as they have more and more kids? What can we say about when they have their Nth child \u2014 can we predict it with a formula? Does the size of their brood over time show asymptotic behavior? If so, what are its bounds?\n<\/p><\/blockquote>\n<p>Here is an explanation of my derivation:<br \/>\n<a href=\"javascript:Solution('soln_alicebobkids','toggle_alicebobkids')\" id=\"toggle_alicebobkids\">[Show Solution]<\/a><\/p>\n<div id=\"soln_alicebobkids\" style=\"display: none\">\n<p>Let&#8217;s call $t_k$ the time at which Alice and Bob have their $k^\\text{th}$ child. The first child is born at time zero, so $t_1 = 0$. Since the work due to a child is one divided by their age, the work due to child $k$ at time $t$ is given by:<br \/>\n\\[<br \/>\n\\text{work at time }t = \\begin{cases}<br \/>\n\\frac{1}{t-t_k} &#038; \\text{if }t > t_k \\\\<br \/>\n0 &#038; \\text{otherwise}<br \/>\n\\end{cases}<br \/>\n\\]We also know that each new child is born once the total work due to all previous children equals $1$. Therefore, we have the following equations:<br \/>\n\\begin{align}<br \/>\nt_2\\text{ satsifies:} &#038;&#038; \\frac{1}{t_2-t_1} &#038;= 1 \\\\<br \/>\nt_3\\text{ satisfies:} &#038;&#038; \\frac{1}{t_3-t_2} + \\frac{1}{t_3-t_1} &#038;= 1 \\\\<br \/>\nt_4\\text{ satisfies:} &#038;&#038; \\frac{1}{t_4-t_3} + \\frac{1}{t_4-t_2} + \\frac{1}{t_4-t_1} &#038;= 1 \\\\<br \/>\n\\cdots\\qquad \\\\<br \/>\nt_k\\text{ satisfies:} &#038;&#038; \\sum_{i=1}^{k-1} \\frac{1}{t_k-t_i} &#038;= 1<br \/>\n\\end{align}and so on. We also know that $t_1 \\lt t_2 \\lt t_3 \\lt \\ldots$ since the children are born sequentially. The nice thing about these equation is that they can be solved sequentially. We know that $t_1=0$. Substituting this into the first equation yields $t_2=1$. Substituting these values into the second equation yields:<br \/>\n\\[<br \/>\n\\frac{1}{t_3-1}+\\frac{1}{t_3} = 1<br \/>\n\\]Rearranging yields $t_3^2-3t_3+1=0$. This equation has two solutions, but we take the one that satisfies $t_3 \\gt t_2$, and we obtain $t_3=\\tfrac{3+\\sqrt{5}}{2} \\approx 2.618$. We can continue in this fashion, solving each subsequent equation by substituting the previous values&#8230; but things get complicated in a hurry. The next equation becomes:<br \/>\n\\[<br \/>\nt_4^3-\\left(\\tfrac{11+\\sqrt{5}}{2}\\right)t_4^2+\\left(\\tfrac{13+3\\sqrt{5}}{2}\\right)t_4-\\left(\\tfrac{3+\\sqrt{5}}{2}\\right)=0<br \/>\n\\]Once again, we find that there is a unique solution that satisfies $t_4 \\gt t_3$. This solution is approximately $t_4\\approx 4.5993$. There doesn&#8217;t appear to be any automatic way to continue this process. Every time we try to compute the next $t_k$, we have to find the root of an even more complicated polynomial!<\/p>\n<p>We&#8217;ll take a numerical approach, but let me first address one issue: how can we be sure that these ever-more-complicated polynomials always have a root that satisfies our constraints? For example, what if the polynomial for $t_4$ had no roots larger than $t_3$? What if it had many such roots? Thankfully, there is a simple way we can guarantee that there is always exactly one admissible root to each polynomial by leveraging the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Intermediate_value_theorem\">intermediate value theorem<\/a>. Specifically, the function<br \/>\n\\[<br \/>\nf_k(t) = \\frac{1}{t-t_1} + \\frac{1}{t-t_2} + \\cdots + \\frac{1}{t-t_{k-1}}<br \/>\n\\]with $t \\gt t_{k-1} \\gt \\ldots \\gt t_1$ is a continuous and strictly decreasing function. Moreover, $\\lim_{t\\to {t_{k-1}}^+}f_k(t) = +\\infty$ and $\\lim_{t\\to\\infty} f_k(t) = 0$. Therefore, by the intermediate value theorem, there must be some point $t_k \\in (t_{k-1},\\infty)$ such that $f_k(t_k)=1$. The strict monoticity of $f_k$ ($f_k$ is strictly decreasing) implies that this $t_k$ must be unique.<\/p>\n<p>The root may be unique, but how can we find it efficiently? Here, we can leverage a further property of $f_k$; namely <a href=\"https:\/\/en.wikipedia.org\/wiki\/Convex_function\">convexity<\/a>. The fact that $f_k$ is convex (and smooth) means that we can leverage some efficient methods from convex analysis that make use of derivative information. There are many ways to get the answer from here&#8230; What I ended up doing was to use the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Limited-memory_BFGS\">L-BFGS algorithm<\/a> on the objective $(f_k(t)-1)^2$. My implementation in <a href=\"https:\/\/julialang.org\/\">Julia<\/a> using the <a href=\"https:\/\/julianlsolvers.github.io\/Optim.jl\/stable\/\">Optim.jl<\/a> package took about 40 seconds to evaluate birth dates of the first 1,000 children.<\/p>\n<p><strong>Note:<\/strong> there are many ways to formulate this as an optimization problem. One way is to note that solving $f_k(t)=1$ is equivalent to extremizing the antiderivative of $f_k(t)-1$. In other words, we could solve:<br \/>\n\\[<br \/>\nt_k = \\underset{t \\gt t_{k-1}}{\\text{arg min}} \\left( t-\\sum_{i=1}^{k-1}\\log(t-t_i) \\right)<br \/>\n= \\underset{t \\gt t_{k-1}}{\\text{arg max}}\\,\\, e^{-t}\\prod_{i=1}^{k-1}(t-t_i)<br \/>\n\\]Incidentally, this last expression for $t_k$ makes it clear that there should be a unique $t_k$. When $t\\gt t_{k-1}$, the product is a polynomial that is strictly increasing, and it&#8217;s multiplied by $e^{-t}$, which will drive it to zero eventually. There must therefore be a unique maximizer. I tried implementing both of these approaches and both turned out to be slower than directly minimizing $(f_k(t)-1)^2$.\n<\/div>\n<p>If you&#8217;re just interested in the answers to the questions, here they are:<br \/>\n<a href=\"javascript:Solution('soln_alicebobkidsb','toggle_alicebobkidsb')\" id=\"toggle_alicebobkidsb\">[Show Solution]<\/a><\/p>\n<div id=\"soln_alicebobkidsb\" style=\"display: none\">\n<ul>\n<li> Does it make sense for Alice and Bob to have an infinite number of children? Biological limitations aside, yes! We proved that for each $t_k$, there exists a unique $t_{k+1} \\gt t_k$ that satisfies the constraints of the problem. So by <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mathematical_induction\">induction<\/a>, Alice and Bob can have as many children as they like.\n<li> Does the time between kids increase as they have more and more kids? The answer is yes, and I will provide a &#8220;proof by picture&#8221;. After finding $t_k$ for $k=1,2,\\dots$, we know the birth dates of each child. Then it remains to compute $(t_{k+1}-t_k)$ for each $k$ (the time between births). Here is the plot\n<\/p>\n<p><a href=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2018\/12\/alicebob_yrs_btwn_births.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2018\/12\/alicebob_yrs_btwn_births.png\" alt=\"\" width=\"600\" height=\"400\" class=\"aligncenter size-full wp-image-2569\" srcset=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2018\/12\/alicebob_yrs_btwn_births.png 600w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2018\/12\/alicebob_yrs_btwn_births-300x200.png 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><\/p>\n<p>The first point on the left says that we wait $1$ year after child $1$ is born, we wait about $1.6$ years after child $2$ is born, and so on. Plotted on a log scale as above, we see the curve is almost a perfect straight line. Here is a formula we can use to approximate the number of years to wait:<\/p>\n<p style=\"text-align: center;\"><span style=\"background-color: #AFC8E6; padding: 25px 10px 25px 10px;\">$\\displaystyle<br \/>\n\\text{years to wait after child }k\\text{ is born} \\,\\approx\\, 1 + 2.19\\cdot \\log_{10} k<br \/>\n$<\/span><\/p>\n<p>So yes, the time between children increases (without bound), but it does so slowly. By the time Alice and Bob have their 1,000th child, they will be waiting approximately 7.5 years between kids.<\/p>\n<li> What can we say about when they have their $N^\\text{th}$ child? Is there a formula we can write down? I couldn&#8217;t find an analytic expression, but I did find a pretty good approximation. First, let&#8217;s make a plot to see what we&#8217;re working with. Here is what the birth years is like for the first 19 children\n<\/p>\n<p><a href=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2018\/12\/alicebob_year_child1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2018\/12\/alicebob_year_child1.png\" alt=\"\" width=\"600\" height=\"400\" class=\"aligncenter size-full wp-image-2575\" srcset=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2018\/12\/alicebob_year_child1.png 600w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2018\/12\/alicebob_year_child1-300x200.png 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><\/p>\n<p>We can see here that the growth rate is slightly faster than linear. Since the time between children fit so well to a curve of the form $a+b\\log x$, it makes sense to fit the birth dates themselves to the integral of this form. In an effort to fit the simplest possible curve, I did a bit of experimenting and found that the form $a x + x \\log x$ does a really good job. I found the equation of best fit using <a href=\"https:\/\/en.wikipedia.org\/wiki\/Linear_regression\">linear regression<\/a> and put the equation in the plot above. If we extend the time horizon, we get a similar result:<\/p>\n<p><a href=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2018\/12\/alicebob_year_child2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2018\/12\/alicebob_year_child2.png\" alt=\"\" width=\"600\" height=\"400\" class=\"aligncenter size-full wp-image-2574\" srcset=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2018\/12\/alicebob_year_child2.png 600w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2018\/12\/alicebob_year_child2-300x200.png 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><\/p>\n<p>This is a pretty good fit; the plot actually depicts the true data with the fit overlaid on top. The fit is so good that you can&#8217;t even see the data underneath! So for large $N$, a good approximation is:<\/p>\n<p style=\"text-align: center;\"><span style=\"background-color: #AFC8E6; padding: 25px 10px 25px 10px;\">$\\displaystyle<br \/>\n\\text{year when child }N\\text{ is born} \\,\\approx\\,-0.315N + N\\log N<br \/>\n$<\/span><\/p>\n<li> The final question is whether the size of the brood over time shows asymptotic behavior. We already plotted the time of birth vs child number, and found the relationship to be approximately: $y \\approx -0.315 N + N\\log N$. So here, we need to look at the inverse relationship and ask what $N$ does as a function of $y$. Since $y$ grows a little faster than linearly, this means $N$ will grow a little more slowly than linearly.\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this interesting Riddler problem, we&#8217;re dealing with a possibly unbounded sequence of&#8230; children? Here it goes: As you may know, having one child, let alone many, is a lot of work. But Alice and Bob realized children require less of their parents\u2019 time as they grow older. They figured out that the work involved &hellip; <a href=\"https:\/\/laurentlessard.com\/bookproofs\/alice-and-bob-fall-in-love\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Alice and Bob fall in love&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":2575,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[7],"tags":[28,31,26,2],"class_list":["post-2563","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-riddler","tag-calculus","tag-modeling","tag-optimization","tag-riddler"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/posts\/2563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/comments?post=2563"}],"version-history":[{"count":11,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/posts\/2563\/revisions"}],"predecessor-version":[{"id":2700,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/posts\/2563\/revisions\/2700"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/media\/2575"}],"wp:attachment":[{"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/media?parent=2563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/categories?post=2563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/tags?post=2563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}