<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Long Luo&#39;s Life Notes</title>
  <icon>https://www.longluo.me/icon.png</icon>
  <subtitle>每一天都是奇迹</subtitle>
  <link href="https://www.longluo.me/atom.xml" rel="self"/>
  
  <link href="https://www.longluo.me/"/>
  <updated>2026-04-07T14:22:57.943Z</updated>
  <id>https://www.longluo.me/</id>
  
  <author>
    <name>Long Luo</name>
    
  </author>
  
  <generator uri="https://hexo.io/">Hexo</generator>
  
  <entry>
    <title>一道初中数学极值题的多种解法：柯西不等式、几何法、函数法详解</title>
    <link href="https://www.longluo.me/blog/junior-high-math-inequality-maximum/"/>
    <id>https://www.longluo.me/blog/junior-high-math-inequality-maximum/</id>
    <published>2026-02-01T14:55:35.000Z</published>
    <updated>2026-04-07T14:22:57.943Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;最近在短视频 App
里刷到不少中学数学题讲解，才发现现在的初中数学题，很多已经不只是“会算”这么简单了，背后往往还藏着不等式、函数、几何直觉等不同层面的思维训练。&lt;/p&gt;
&lt;p&gt;当然，这也不算奇怪，几十年前的 IMO
试题放现在也就普通题。很多经典数学竞赛题，随着时间推移和教学资源普及，早已从高阶技巧逐渐变成了基础训练的一部分。&lt;/p&gt;
&lt;p&gt;前几天我就反复刷到一道“求极值”的题，看起来不难，但这道题其实非常适合拿来练习数学直觉。&lt;/p&gt;
&lt;div class=&quot;note info&quot;&gt;&lt;p&gt;已知 &lt;span class=&quot;math inline&quot;&gt;&#92;(x + y = 5&#92;)&lt;/span&gt; ，求 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;sqrt {x + 1} + &#92;sqrt {y + 3}&#92;)&lt;/span&gt;
的最大值。&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;看到这道题，首先想到的几何意义其实是将军饮马模型，但将军饮马问题求得是最小值问题。那最大值该怎么求呢？最大值的几何意义是什么呢？&lt;/p&gt;
&lt;p&gt;这道题的有趣之处在于可以用很多完全不同的思路来解决，有的解法只需要代数变形和基本不等式，也可以使用几何视角、函数思想。&lt;/p&gt;
&lt;p&gt;下面就道题为例，把几种典型解法都梳理一遍，也顺便重新锻炼一下自己的数学思维。&lt;/p&gt;
&lt;h2 id=&quot;解法一常规解法&quot;&gt;解法一：常规解法&lt;/h2&gt;
&lt;p&gt;由 &lt;span class=&quot;math inline&quot;&gt;&#92;(y = 5 - x&#92;)&lt;/span&gt; ，原式变成 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;sqrt {x + 1} + &#92;sqrt {8 - x}&#92;)&lt;/span&gt;
，要保证根号有意义，所以 &lt;span class=&quot;math inline&quot;&gt;&#92;(−1 &#92;le x &#92;le
8&#92;)&lt;/span&gt; 。&lt;/p&gt;
&lt;p&gt;设 &lt;span class=&quot;math inline&quot;&gt;&#92;(S = &#92;sqrt {x + 1} + &#92;sqrt {8 -
x}&#92;)&lt;/span&gt; ，两边平方得 &lt;span class=&quot;math inline&quot;&gt;&#92;(S^2 = (&#92;sqrt{x + 1}
+ &#92;sqrt{8 - x})^2&#92;)&lt;/span&gt; 。&lt;/p&gt;
&lt;p&gt;展开可得：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
&#92;begin{aligned}
S^2 &amp;amp; = (x + 1) + (8 - x) + 2 &#92;sqrt {(x + 1)(8 - x)} &#92;&#92;
&amp;amp; = 9 + 2 &#92;sqrt {(x + 1)(8 - x)} &#92;&#92;
&amp;amp; = 9 + 2 &#92;sqrt {-x^2 + 7x + 8} &#92;&#92;
&amp;amp; = 9 + 2 &#92;sqrt {-(x - &#92;frac {7}{2})^2 + &#92;frac {81}{4}}
&#92;end{aligned}
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;因此 &lt;span class=&quot;math inline&quot;&gt;&#92;(S^2 &#92;le 9 + 2 &#92;times &#92;dfrac {9}{2} =
18&#92;)&lt;/span&gt; ，于是 &lt;span class=&quot;math inline&quot;&gt;&#92;(S &#92;le 3 &#92;sqrt 2&#92;)&lt;/span&gt;
当且仅当 &lt;span class=&quot;math inline&quot;&gt;&#92;(x = &#92;dfrac {7}{2}&#92;)&lt;/span&gt;
时取等号。&lt;/p&gt;
&lt;p&gt;故最大值为 &lt;span class=&quot;math inline&quot;&gt;&#92;(3&#92;sqrt2&#92;)&lt;/span&gt; 。&lt;/p&gt;</summary>
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Geometry" scheme="https://www.longluo.me/tags/Geometry/"/>
    
    <category term="Inequality" scheme="https://www.longluo.me/tags/Inequality/"/>
    
    <category term="Function" scheme="https://www.longluo.me/tags/Function/"/>
    
  </entry>
  
  <entry>
    <title>扔几个骰子，怎么算出期望？——拼多多校招笔试算法题的数学故事</title>
    <link href="https://www.longluo.me/blog/pinduoduo-2020-campus-recruitment-coding-problems-expected-value-of-dice/"/>
    <id>https://www.longluo.me/blog/pinduoduo-2020-campus-recruitment-coding-problems-expected-value-of-dice/</id>
    <published>2025-02-01T02:12:03.000Z</published>
    <updated>2025-10-22T11:11:47.703Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;在上一篇文章我们剖析了 &lt;a href=&quot;https://www.longluo.me/blog/pinduoduo-2020-campus-recruitment-coding-problems-magic-boxes/&quot;&gt;拼多多
2020 年校招笔试算法题中第一题: 多多的魔术盒子&lt;/a&gt; ，今天来挑战下其中的第
4 题：骰子期望 &lt;a href=&quot;#fn1&quot; class=&quot;footnote-ref&quot; id=&quot;fnref1&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt; ，题目如下：&lt;/p&gt;
&lt;div class=&quot;note info&quot;&gt;&lt;h2 id=&quot;骰子期望&quot;&gt;骰子期望&lt;/h2&gt;
&lt;p&gt;扔 &lt;span class=&quot;math inline&quot;&gt;&#92;(n&#92;)&lt;/span&gt; 个骰子，第 &lt;span class=&quot;math inline&quot;&gt;&#92;(i&#92;)&lt;/span&gt; 个骰子有可能投掷出 &lt;span class=&quot;math inline&quot;&gt;&#92;(X_i&#92;)&lt;/span&gt; 种等概率的不同的结果，数字从 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; 到 &lt;span class=&quot;math inline&quot;&gt;&#92;(X_i&#92;)&lt;/span&gt;
。所有骰子的结果的最大值将作为最终结果。求最终结果的期望。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;输入描述:
&lt;ul&gt;
&lt;li&gt;第一行一个整数 &lt;span class=&quot;math inline&quot;&gt;&#92;(n&#92;)&lt;/span&gt; ，表示有 &lt;span class=&quot;math inline&quot;&gt;&#92;(n&#92;)&lt;/span&gt; 个骰子。( &lt;span class=&quot;math inline&quot;&gt;&#92;(1
&#92;le n &#92;le 50&#92;)&lt;/span&gt; )&lt;/li&gt;
&lt;li&gt;第二行 &lt;span class=&quot;math inline&quot;&gt;&#92;(n&#92;)&lt;/span&gt;
个整数，表示每个骰子的结果数 &lt;span class=&quot;math inline&quot;&gt;&#92;(X_i&#92;)&lt;/span&gt;
。( &lt;span class=&quot;math inline&quot;&gt;&#92;(2 &#92;le X_i &#92;le 50&#92;)&lt;/span&gt; )&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;输出描述:
&lt;ul&gt;
&lt;li&gt;输出最终结果的期望，保留两位小数。&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;输入例子 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; :
&lt;ul&gt;
&lt;li&gt;2&lt;/li&gt;
&lt;li&gt;2 2&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;输出例子 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; :
&lt;ul&gt;
&lt;li&gt;1.75&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;p&gt;要解答这道题，我们需要先从脑海里把中学数学知识捡起来，弄清楚什么是&lt;strong&gt;期望&lt;/strong&gt;
&lt;a href=&quot;#fn2&quot; class=&quot;footnote-ref&quot; id=&quot;fnref2&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;？&lt;/p&gt;
&lt;p&gt;在概率论和统计学中，一个离散性随机变量的数学期望是试验中每次可能的结果乘以其结果概率的总和：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
&#92;operatorname {E} [X] = &#92;sum _{i=1}^{&#92;infty
}x_{i}&#92;,p_{i}                       &#92;tag{1} &#92;label{1}
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;具体到这道题示例 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; ，很明显
&lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 个骰子只能取到 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; 或者 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 个值：&lt;/p&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;&lt;p&gt;假设这 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt;
个骰子取到的最大值为 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; ，那么这
&lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 个骰子都只能选择 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; ，概率为： &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;dfrac {1}{2} &#92;times &#92;dfrac {1}{2} = &#92;dfrac
{1}{4}&#92;)&lt;/span&gt; ；&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;假设这 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt;
个骰子取到的最大值为 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; ，那么存在
&lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 种可能，要么都取 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 或者 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 个骰子中有一个骰子投出了 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; ，其概率为： &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;dfrac {1}{2} &#92;times &#92;dfrac {1}{2} + &#92;dfrac {1}{2}
&#92;times 1 = &#92;dfrac {3}{4}&#92;)&lt;/span&gt; 。&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;那么期望为： &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;dfrac {1}{4} &#92;times 1 +
&#92;dfrac {3}{4} &#92;times 2 = 1.75&#92;)&lt;/span&gt; 。&lt;/p&gt;
&lt;p&gt;对于骰子数少的时候还可以枚举，如果骰子数量很多呢？用上述方法就会遇到困难，比如有
&lt;span class=&quot;math inline&quot;&gt;&#92;(N&#92;)&lt;/span&gt; 个骰子，最大值为 &lt;span class=&quot;math inline&quot;&gt;&#92;(M&#92;)&lt;/span&gt; ，那么骰子结果为 &lt;span class=&quot;math inline&quot;&gt;&#92;([1, 2, &#92;dots, M]&#92;)&lt;/span&gt;
，如何计算每个结果的概率值呢？&lt;/p&gt;
&lt;p&gt;直接算当然是可行的，但是如果骰子数量很多的话，计算会非常繁琐，所以有没有更简单的方法呢？&lt;/p&gt;</summary>
    
    
    
    <category term="Data Structures and Algorithms" scheme="https://www.longluo.me/categories/Data-Structures-and-Algorithms/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Probability" scheme="https://www.longluo.me/tags/Probability/"/>
    
    <category term="Algorithm" scheme="https://www.longluo.me/tags/Algorithm/"/>
    
    <category term="Interview" scheme="https://www.longluo.me/tags/Interview/"/>
    
  </entry>
  
  <entry>
    <title>拼多多校招笔试算法题：一行公式搞定“多多的魔术盒子”</title>
    <link href="https://www.longluo.me/blog/pinduoduo-2020-campus-recruitment-coding-problems-magic-boxes/"/>
    <id>https://www.longluo.me/blog/pinduoduo-2020-campus-recruitment-coding-problems-magic-boxes/</id>
    <published>2025-01-26T09:15:23.000Z</published>
    <updated>2025-10-15T15:54:26.665Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;众多IT大厂中拼多多虽然工作强度很大，但在给钱方面非常大方。大厂给的钱多，但要求也高。下面就来挑战拼多多
2020 年校招笔试算法题 &lt;a href=&quot;#fn1&quot; class=&quot;footnote-ref&quot; id=&quot;fnref1&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt; 中第一题：多多的魔术盒子 &lt;a href=&quot;#fn2&quot; class=&quot;footnote-ref&quot; id=&quot;fnref2&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt; ，看看难度如何。&lt;/p&gt;
&lt;div class=&quot;note info&quot;&gt;&lt;h2 id=&quot;多多的魔术盒子&quot;&gt;多多的魔术盒子&lt;/h2&gt;
&lt;p&gt;多多鸡有 &lt;span class=&quot;math inline&quot;&gt;&#92;(N&#92;)&lt;/span&gt; 个魔术盒子(编号 &lt;span class=&quot;math inline&quot;&gt;&#92;(1 &#92;sim N&#92;)&lt;/span&gt; )，其中编号为 &lt;span class=&quot;math inline&quot;&gt;&#92;(i&#92;)&lt;/span&gt; 的盒子里有 &lt;span class=&quot;math inline&quot;&gt;&#92;(i&#92;)&lt;/span&gt; 个球。多多鸡让皮皮虾每次选择一个数字
&lt;span class=&quot;math inline&quot;&gt;&#92;(X&#92;)&lt;/span&gt; ( &lt;span class=&quot;math inline&quot;&gt;&#92;(1
&#92;le X &#92;le N&#92;)&lt;/span&gt; )，多多鸡就会把球数量大于等于 &lt;span class=&quot;math inline&quot;&gt;&#92;(X&#92;)&lt;/span&gt; 个的盒子里的球减少 &lt;span class=&quot;math inline&quot;&gt;&#92;(X&#92;)&lt;/span&gt; 个。
通过观察，皮皮虾已经掌握了其中的奥秘，并且发现只要通过一定的操作顺序，可以用最少的次数将所有盒子里的球变没。&lt;/p&gt;
&lt;p&gt;那么请问聪明的你，是否已经知道了应该如何操作呢？&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;时间限制：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;C/C++ 1秒，其他语言 2 秒&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;空间限制：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;C/C++ 256M，其他语言 512M&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;输入描述:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;第一行，有 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; 个整数 &lt;span class=&quot;math inline&quot;&gt;&#92;(T&#92;)&lt;/span&gt; ，表示测试用例的组数。 ( &lt;span class=&quot;math inline&quot;&gt;&#92;(1 &#92;le T &#92;le 100&#92;)&lt;/span&gt; )&lt;/li&gt;
&lt;li&gt;接下来 &lt;span class=&quot;math inline&quot;&gt;&#92;(T&#92;)&lt;/span&gt; 行，每行 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; 个整数 &lt;span class=&quot;math inline&quot;&gt;&#92;(N&#92;)&lt;/span&gt; ，表示有 &lt;span class=&quot;math inline&quot;&gt;&#92;(N&#92;)&lt;/span&gt; 个魔术盒子。 ( &lt;span class=&quot;math inline&quot;&gt;&#92;(1 &#92;le N &#92;le 1,000,000,000&#92;)&lt;/span&gt; )&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;输出描述:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;共 &lt;span class=&quot;math inline&quot;&gt;&#92;(T&#92;)&lt;/span&gt; 行，每行 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt;
个整数，表示要将所有盒子的球变没，最少需要进行多少次操作。&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;输入例子 1 :&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;figure class=&quot;highlight txt&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line&quot;&gt;1&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;2&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;3&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;4&lt;/span&gt;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line&quot;&gt;3&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;1&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;2&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;5&lt;/span&gt;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/figure&gt;&lt;p&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;输出例子 1 :&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;figure class=&quot;highlight txt&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line&quot;&gt;1&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;2&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;3&lt;/span&gt;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line&quot;&gt;1&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;2&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;3&lt;/span&gt;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/figure&gt;&lt;p&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;h2 id=&quot;最少的操作次数该怎么做&quot;&gt;最少的操作次数该怎么做？&lt;/h2&gt;
&lt;p&gt;根据题意，我们关键是要找到&lt;strong&gt;最少次数&lt;/strong&gt;这个方法，那如何操作才能使用最少次数呢？&lt;/p&gt;
&lt;p&gt;当面对复杂问题时，我们需要从简单情况入手，分析其中规律，找到突破口。&lt;/p&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;&lt;span class=&quot;math inline&quot;&gt;&#92;(N = 1&#92;)&lt;/span&gt; 时，显然选择 &lt;span class=&quot;math inline&quot;&gt;&#92;(X = 1&#92;)&lt;/span&gt; ，需要 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; 次操作；&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;math inline&quot;&gt;&#92;(N = 2&#92;)&lt;/span&gt; 时，可以先选择 &lt;span class=&quot;math inline&quot;&gt;&#92;(X = 1&#92;)&lt;/span&gt; ，再选择 &lt;span class=&quot;math inline&quot;&gt;&#92;(X = 2&#92;)&lt;/span&gt; ，需要 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 次操作；&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;math inline&quot;&gt;&#92;(N = 3&#92;)&lt;/span&gt; 时，只有先选择 &lt;span class=&quot;math inline&quot;&gt;&#92;(X = 2&#92;)&lt;/span&gt; ，再选择 &lt;span class=&quot;math inline&quot;&gt;&#92;(X = 1&#92;)&lt;/span&gt; ，最少需要 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 次操作；&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;math inline&quot;&gt;&#92;(N = 4&#92;)&lt;/span&gt; 时，可以先选择 &lt;span class=&quot;math inline&quot;&gt;&#92;(X = 2&#92;)&lt;/span&gt; 或者 &lt;span class=&quot;math inline&quot;&gt;&#92;(X
= 3&#92;)&lt;/span&gt; ，最少需要 &lt;span class=&quot;math inline&quot;&gt;&#92;(3&#92;)&lt;/span&gt;
次操作；&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;通过分析发现，每次操作之后，球的数量都会动态变化。如果每次都选择&lt;strong&gt;中间&lt;/strong&gt;的数字，这样每次操作之后，如果
&lt;span class=&quot;math inline&quot;&gt;&#92;(N&#92;)&lt;/span&gt; 为奇数的话，可以变成 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 个对称相同的数组， &lt;span class=&quot;math inline&quot;&gt;&#92;(N&#92;)&lt;/span&gt; 为偶数的话，则 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 个数组中元素值会相差 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt;
，再选择元素值更多的数组进行消除，这样可以实现&lt;strong&gt;操作次数最少&lt;/strong&gt;。&lt;/p&gt;
&lt;p&gt;实现代码如下：&lt;/p&gt;
&lt;figure class=&quot;highlight java&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line&quot;&gt;1&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;2&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;3&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;4&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;5&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;6&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;7&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;8&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;9&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;10&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;11&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;12&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;13&lt;/span&gt;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;line&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;title function_&quot;&gt;leastTimes_power&lt;/span&gt;&lt;span class=&quot;params&quot;&gt;(&lt;span class=&quot;type&quot;&gt;int&lt;/span&gt; n)&lt;/span&gt; {&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;    &lt;span class=&quot;type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;variable&quot;&gt;ans&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;    &lt;span class=&quot;keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;; i &amp;lt;= Math.sqrt(n); i++) {&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;        &lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt; (Math.pow(&lt;span class=&quot;number&quot;&gt;2&lt;/span&gt;, i) &amp;lt;= n) {&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;            ans = i;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;        } &lt;span class=&quot;keyword&quot;&gt;else&lt;/span&gt; {&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;            &lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;        }&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;    }&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;    &lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; ans + &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;line&quot;&gt;}&lt;/span&gt;&lt;br&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/figure&gt;
&lt;p&gt;为什么每次选取中间的数字进行操作次数最少呢？下面我们就来严谨的证明下！&lt;/p&gt;</summary>
    
    
    
    <category term="Data Structures and Algorithms" scheme="https://www.longluo.me/categories/Data-Structures-and-Algorithms/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Algorithm" scheme="https://www.longluo.me/tags/Algorithm/"/>
    
    <category term="Interview" scheme="https://www.longluo.me/tags/Interview/"/>
    
  </entry>
  
  <entry>
    <title>斯特林公式(Stirling&#39;s Formula)：我一个阶乘表达式，怎么就和圆扯上关系了呢？</title>
    <link href="https://www.longluo.me/blog/stirlings-formula/"/>
    <id>https://www.longluo.me/blog/stirlings-formula/</id>
    <published>2025-01-18T07:57:08.000Z</published>
    <updated>2025-08-14T11:22:11.846Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;在科研和工程领域中，&lt;strong&gt;阶乘&lt;/strong&gt;( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;textit{Factorial}&#92;)&lt;/span&gt;
)有着广泛的应用。在概率论中，阶乘是计算排列( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;textit{Permutation}&#92;)&lt;/span&gt; )和组合( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;textit{Combination}&#92;)&lt;/span&gt;
)时不可或缺的；在物理中，计算粒子系统的状态数以及大型系统的统计分布都要用到阶乘；在计算机中，阶乘则用于图论和组合优化问题。&lt;/p&gt;
&lt;p&gt;大家都知道“指数爆炸”这个值，因为指数增长是非常迅猛的。其实阶乘增长要远远快于指数增长，如下图
1 所示为不同算法复杂度增长情况。随着 &lt;span class=&quot;math inline&quot;&gt;&#92;(n&#92;)&lt;/span&gt;
的增大，阶乘的计算复杂度迅速上升，当处理大 &lt;span class=&quot;math inline&quot;&gt;&#92;(n&#92;)&lt;/span&gt; 时，计算 &lt;span class=&quot;math inline&quot;&gt;&#92;(n!&#92;)&lt;/span&gt; 会变得极其复杂且耗时。例如 &lt;span class=&quot;math inline&quot;&gt;&#92;(5! = 120&#92;)&lt;/span&gt; ，而 &lt;span class=&quot;math inline&quot;&gt;&#92;(50! &#92;approx 3.04 &#92;times 10^{64}&#92;)&lt;/span&gt;
，这已经是一个非常庞大的数字！直接使用递归方法去求解 &lt;span class=&quot;math inline&quot;&gt;&#92;(n!&#92;)&lt;/span&gt; 的时间复杂度是 &lt;span class=&quot;math inline&quot;&gt;&#92;(O(n)&#92;)&lt;/span&gt; ，对于较大的 &lt;span class=&quot;math inline&quot;&gt;&#92;(n&#92;)&lt;/span&gt;
来说很容易栈溢出。在实际应用中，往往需要计算大数的阶乘，即使目前最先进的计算机去处理极大数的阶乘时，也会面临需要巨大的计算及存储资源消耗问题。&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/time-complexity/comparison-computational-complexity.svg&quot; title=&quot;Time Complexity Comparison&quot; alt=&quot;图1. 不同算法时间复杂度 Time Complexity Comparison&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图1. 不同算法时间复杂度 Time Complexity
Comparison&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;人们迫切需要找到一种可以快速计算阶乘的方法，在 18
世纪初期，苏格兰数学家詹姆斯·斯特林( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;textit{James Stirling}&#92;)&lt;/span&gt; )提出了斯特林公式
。斯特林公式( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;textit{Stirling&#39;s
Approximation}&#92;)&lt;/span&gt; )提供了一种近似计算阶乘的方法，特别适用于大
&lt;span class=&quot;math inline&quot;&gt;&#92;(n&#92;)&lt;/span&gt; 的情况，其标准形式为：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
n! &#92;approx {&#92;sqrt {2&#92;pi n}} &#92;,&#92;left( {&#92;frac {n}{e}} &#92;right
)^n    &#92;tag{1.1} &#92;label{1.1}
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;其对数形式为：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
&#92;ln (n!) &#92;approx n &#92;ln n - n
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;这个公式最早是亚伯拉罕·棣莫弗( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;textit{Abraham de Moivre}&#92;)&lt;/span&gt;
)在研究二项分布时，为了解决大数阶乘问题时发现的，其形式为：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
n! &#92;approx C n^{n + &#92;frac {1}{2}}e^{-n}    &#92;tag{1.2} &#92;label{1.2}
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;其中 &lt;span class=&quot;math inline&quot;&gt;&#92;(C&#92;)&lt;/span&gt;
为某个常量值，斯特林证明了公式中 &lt;span class=&quot;math inline&quot;&gt;&#92;(C = &#92;sqrt
{2 &#92;pi}&#92;)&lt;/span&gt; ，于是冠名权就给了斯特林。&lt;/p&gt;
&lt;p&gt;斯特林公式可以大大简化阶乘的计算，特别是当 &lt;span class=&quot;math inline&quot;&gt;&#92;(n&#92;)&lt;/span&gt;
很大时，它提供了一个非常精确的近似值。斯特林公式使得复杂的阶乘计算可以通过较为简单的幂函数、指数函数和根号运算来完成。相比于直接计算阶乘，它极大地减少了计算量，是大数问题中不可或缺的工具。&lt;/p&gt;
&lt;p&gt;斯特林公式中集合了圆周率 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;pi&#92;)&lt;/span&gt;
和自然常数 &lt;span class=&quot;math inline&quot;&gt;&#92;(e&#92;)&lt;/span&gt; ，这 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt;
个数学中最重要的常数，十分独特且具有美感。因为 &lt;span class=&quot;math inline&quot;&gt;&#92;(e&#92;)&lt;/span&gt;
意味着&lt;strong&gt;连续增长&lt;/strong&gt;，而阶乘就是连续自然数的相乘。而出现
&lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;pi&#92;)&lt;/span&gt; 的时候，就要问自己 “Where is
the circle?”，那么阶乘是如何和几何中的圆扯上关系了呢？&lt;/p&gt;
&lt;p&gt;关于斯特林公式的证明，常见的证明是对数形式的证明或者利用伽马函数(
&lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;textit{Gamma Function}&#92;)&lt;/span&gt;
)来证明，这里将介绍一种从零开始更易理解的推导方式。&lt;/p&gt;</summary>
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Proof" scheme="https://www.longluo.me/tags/Proof/"/>
    
    <category term="Analysis" scheme="https://www.longluo.me/tags/Analysis/"/>
    
    <category term="Circle" scheme="https://www.longluo.me/tags/Circle/"/>
    
    <category term="Asymptotics" scheme="https://www.longluo.me/tags/Asymptotics/"/>
    
    <category term="Factorial" scheme="https://www.longluo.me/tags/Factorial/"/>
    
    <category term="Stirling&#39;s Approximation" scheme="https://www.longluo.me/tags/Stirling-s-Approximation/"/>
    
  </entry>
  
  <entry>
    <title>我爱做题：2010年江西高考理科数学压轴题</title>
    <link href="https://www.longluo.me/blog/2010-jiangxi-gaokao-math-exam-final-question/"/>
    <id>https://www.longluo.me/blog/2010-jiangxi-gaokao-math-exam-final-question/</id>
    <published>2025-01-10T02:06:07.000Z</published>
    <updated>2025-07-04T16:00:16.967Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;知乎上有个问题是高考数学最后一题可以有多难？ &lt;a href=&quot;#fn1&quot; class=&quot;footnote-ref&quot; id=&quot;fnref1&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;，而公认史上最难高考数学题就是 2008
年江西高考理科数学压轴题。2005 - 2014
年是江西自主命题，而江西卷也以题难计算量大著称，尤其是数学和理综。&lt;a href=&quot;https://baike.baidu.com/item/%E9%99%B6%E5%B9%B3%E7%94%9F/3922596&quot;&gt;陶平生老师&lt;/a&gt;
是 2008 - 2011 年江西高考数学命题组长，参与了 2005 - 2011
年江西高考命题，他出江西数学卷时，是江西30多万学生被支配的恐惧！&lt;/p&gt;
&lt;p&gt;作为一名来自十八线农村做题家，高考时赶上了江西自主命题，在考场上也体会到了数学和理综卷题目居然没做完没思路的恐惧！中学时没能感受到数学的乐趣，最近几年看了一些数学书之后，重新拾起了数学的乐趣，经常找些数学题来训练下我的思维，今天就来挑战一下
2010 年江西高考理科数学压轴题：&lt;/p&gt;
&lt;div class=&quot;note primary&quot;&gt;&lt;ol start=&quot;22&quot; type=&quot;1&quot;&gt;
&lt;li&gt;（本小题满分14分） 证明以下命题：&lt;/li&gt;
&lt;/ol&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;对任意正整数 &lt;span class=&quot;math inline&quot;&gt;&#92;(a&#92;)&lt;/span&gt; ，都存在正整数
&lt;span class=&quot;math inline&quot;&gt;&#92;(b, c&#92;)&lt;/span&gt;（ &lt;span class=&quot;math inline&quot;&gt;&#92;(b &amp;lt; c&#92;)&lt;/span&gt; ）使得 &lt;span class=&quot;math inline&quot;&gt;&#92;(a^2, b^2, c^2&#92;)&lt;/span&gt; 为等差数列.&lt;/li&gt;
&lt;li&gt;存在无穷多互不相似的三角形 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;triangle_n&#92;)&lt;/span&gt; ，其边长 &lt;span class=&quot;math inline&quot;&gt;&#92;(a_n, b_n, c_n&#92;)&lt;/span&gt; 为正整数且 &lt;span class=&quot;math inline&quot;&gt;&#92;(a_n^2, b_n^2, c_n^2&#92;)&lt;/span&gt; 成等差数列.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;这道题其实是数论( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;textit{Number
theory}&#92;)&lt;/span&gt; ) &lt;a href=&quot;#fn2&quot; class=&quot;footnote-ref&quot; id=&quot;fnref2&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;
背景，除了搞竞赛的同学，谁学过数论呢？这种构造性( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;textit{Constructive proof}&#92;)&lt;/span&gt; ) &lt;a href=&quot;#fn3&quot; class=&quot;footnote-ref&quot; id=&quot;fnref3&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;
题目，没有接触过类似题目的话，根本不知道如何下手。要是我在考场上也会一脸懵圈，甚至在几年前我也是一筹莫展，不过现在倒是有勇气挑战这类题目了！网上关于这道题的参考答案太简略了，主要是如何找到答案的构造不清楚。这道题真是一道绝妙的题，我花了比较长时间来思考这道题，下面详细描述我的解题思路。&lt;/p&gt;
&lt;h2 id=&quot;第一问&quot;&gt;第一问&lt;/h2&gt;
&lt;p&gt;根据题意，正整数 &lt;span class=&quot;math inline&quot;&gt;&#92;(a, b, c&#92;)&lt;/span&gt; 且
&lt;span class=&quot;math inline&quot;&gt;&#92;(b &amp;lt; c&#92;)&lt;/span&gt; ，满足 &lt;span class=&quot;math inline&quot;&gt;&#92;(a^2, b^2, c^2&#92;)&lt;/span&gt; 为等差数列，即：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
b^2 - a^2 = c^2 - b^2 &#92;Rightarrow 2b^2 = a^2 + c^2
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;观察上式，我们可以得到 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt;
个推论：&lt;/p&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;&lt;span class=&quot;math inline&quot;&gt;&#92;(a &amp;lt; b &amp;lt; c&#92;)&lt;/span&gt; ；&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;math inline&quot;&gt;&#92;(a&#92;)&lt;/span&gt; 和 &lt;span class=&quot;math inline&quot;&gt;&#92;(c&#92;)&lt;/span&gt; 要么都是偶数，要么都是奇数。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;因为 &lt;span class=&quot;math inline&quot;&gt;&#92;(a&#92;)&lt;/span&gt;
为任意正整数，那么就&lt;strong&gt;从最简单的开始&lt;/strong&gt;，不妨设 &lt;span class=&quot;math inline&quot;&gt;&#92;(a = 1&#92;)&lt;/span&gt; ，则有：&lt;/p&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;令 &lt;span class=&quot;math inline&quot;&gt;&#92;(c = 1&#92;)&lt;/span&gt; , 得 &lt;span class=&quot;math inline&quot;&gt;&#92;(b = 1&#92;)&lt;/span&gt; ，与 &lt;span class=&quot;math inline&quot;&gt;&#92;(a
&amp;lt; b &amp;lt; c&#92;)&lt;/span&gt; 矛盾；&lt;/li&gt;
&lt;li&gt;令 &lt;span class=&quot;math inline&quot;&gt;&#92;(c = 3&#92;)&lt;/span&gt; , 得 &lt;span class=&quot;math inline&quot;&gt;&#92;(b = &#92;sqrt {5}&#92;)&lt;/span&gt; ，与 &lt;span class=&quot;math inline&quot;&gt;&#92;(b&#92;)&lt;/span&gt; 为正整数矛盾；&lt;/li&gt;
&lt;li&gt;令 &lt;span class=&quot;math inline&quot;&gt;&#92;(c = 5&#92;)&lt;/span&gt; , 得 &lt;span class=&quot;math inline&quot;&gt;&#92;(b = &#92;sqrt {13}&#92;)&lt;/span&gt; ，与 &lt;span class=&quot;math inline&quot;&gt;&#92;(b&#92;)&lt;/span&gt; 为正整数矛盾；&lt;/li&gt;
&lt;li&gt;令 &lt;span class=&quot;math inline&quot;&gt;&#92;(c = 7&#92;)&lt;/span&gt; , 得 &lt;span class=&quot;math inline&quot;&gt;&#92;(b = 5&#92;)&lt;/span&gt; ，满足条件。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;简单猜测实验得到一组要求的值： &lt;span class=&quot;math inline&quot;&gt;&#92;(a =
1&#92;)&lt;/span&gt; , &lt;span class=&quot;math inline&quot;&gt;&#92;(b = 5&#92;)&lt;/span&gt; , &lt;span class=&quot;math inline&quot;&gt;&#92;(c = 7&#92;)&lt;/span&gt; 。&lt;/p&gt;
&lt;p&gt;再设 &lt;span class=&quot;math inline&quot;&gt;&#92;(a = 2&#92;)&lt;/span&gt; ，同理有：&lt;/p&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;令 &lt;span class=&quot;math inline&quot;&gt;&#92;(c = 4&#92;)&lt;/span&gt; , 得 &lt;span class=&quot;math inline&quot;&gt;&#92;(b = &#92;sqrt {10}&#92;)&lt;/span&gt; ，与 &lt;span class=&quot;math inline&quot;&gt;&#92;(b&#92;)&lt;/span&gt; 为正整数矛盾；&lt;/li&gt;
&lt;li&gt;令 &lt;span class=&quot;math inline&quot;&gt;&#92;(c = 6&#92;)&lt;/span&gt; , 得 &lt;span class=&quot;math inline&quot;&gt;&#92;(b = 2 &#92;sqrt {5}&#92;)&lt;/span&gt; ，与 &lt;span class=&quot;math inline&quot;&gt;&#92;(b&#92;)&lt;/span&gt; 为正整数矛盾；&lt;/li&gt;
&lt;li&gt;令 &lt;span class=&quot;math inline&quot;&gt;&#92;(c = 8&#92;)&lt;/span&gt; , 得 &lt;span class=&quot;math inline&quot;&gt;&#92;(b = &#92;sqrt {34}&#92;)&lt;/span&gt; ，与 &lt;span class=&quot;math inline&quot;&gt;&#92;(b&#92;)&lt;/span&gt; 为正整数矛盾；&lt;/li&gt;
&lt;li&gt;令 &lt;span class=&quot;math inline&quot;&gt;&#92;(c = 10&#92;)&lt;/span&gt; , 得 &lt;span class=&quot;math inline&quot;&gt;&#92;(b = 2 &#92;sqrt {13}&#92;)&lt;/span&gt; ，与 &lt;span class=&quot;math inline&quot;&gt;&#92;(b&#92;)&lt;/span&gt; 为正整数矛盾；&lt;/li&gt;
&lt;li&gt;令 &lt;span class=&quot;math inline&quot;&gt;&#92;(c = 12&#92;)&lt;/span&gt; , 得 &lt;span class=&quot;math inline&quot;&gt;&#92;(b = &#92;sqrt {74}&#92;)&lt;/span&gt; ，与 &lt;span class=&quot;math inline&quot;&gt;&#92;(b&#92;)&lt;/span&gt; 为正整数矛盾；&lt;/li&gt;
&lt;li&gt;令 &lt;span class=&quot;math inline&quot;&gt;&#92;(c = 14&#92;)&lt;/span&gt; , 得 &lt;span class=&quot;math inline&quot;&gt;&#92;(b = 10&#92;)&lt;/span&gt; ，满足条件。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;通过实验又得到一组要求的值： &lt;span class=&quot;math inline&quot;&gt;&#92;(a =
2&#92;)&lt;/span&gt; , &lt;span class=&quot;math inline&quot;&gt;&#92;(b = 10&#92;)&lt;/span&gt; , &lt;span class=&quot;math inline&quot;&gt;&#92;(c = 14&#92;)&lt;/span&gt; 。&lt;/p&gt;
&lt;p&gt;综合 &lt;span class=&quot;math inline&quot;&gt;&#92;(a&#92;)&lt;/span&gt;
为奇数和偶数的情况，猜想：&lt;/p&gt;
&lt;p&gt;对于 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;forall a = n &#92;in
&#92;mathbb{N}^+&#92;)&lt;/span&gt; ，令 &lt;span class=&quot;math inline&quot;&gt;&#92;(b = 5a&#92;)&lt;/span&gt; ,
&lt;span class=&quot;math inline&quot;&gt;&#92;(c = 7a&#92;)&lt;/span&gt; ，易得：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
2 &#92;cdot (5n)^2 = n^2 + (7n)^2
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;故命题(1)得证。&lt;/p&gt;</summary>
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Gaokao" scheme="https://www.longluo.me/tags/Gaokao/"/>
    
    <category term="Examination" scheme="https://www.longluo.me/tags/Examination/"/>
    
    <category term="Number Theory" scheme="https://www.longluo.me/tags/Number-Theory/"/>
    
    <category term="Pythagorean Theorem" scheme="https://www.longluo.me/tags/Pythagorean-Theorem/"/>
    
    <category term="Pythagorean Triple" scheme="https://www.longluo.me/tags/Pythagorean-Triple/"/>
    
    <category term="Proof" scheme="https://www.longluo.me/tags/Proof/"/>
    
  </entry>
  
  <entry>
    <title>热机的效率上限在哪里？解析卡诺循环（Carnot Cycle）</title>
    <link href="https://www.longluo.me/blog/carnot-cycle/"/>
    <id>https://www.longluo.me/blog/carnot-cycle/</id>
    <published>2025-01-05T11:36:56.000Z</published>
    <updated>2025-05-02T03:38:43.582Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;无论是家中的冰箱和空调，还是天上的飞机、水中的轮船、路上的汽车，它们本质上都属于热机
&lt;a href=&quot;#fn1&quot; class=&quot;footnote-ref&quot; id=&quot;fnref1&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;。或许有人会疑惑：冰箱和空调明明是用电的，怎么能和烧油的归为一类呢？事实上，这些机器虽然形式各异，但原理上都涉及热能的转换。它们早已融入我们的日常生活，而对大多数人而言，知道它们是机器已经足够了。&lt;/p&gt;
&lt;p&gt;人类一直以来都在努力提高机器的效率，从而更好的为我们服务。以汽车为例，目前汽油发动机的热效率大约为
&lt;span class=&quot;math inline&quot;&gt;&#92;(30&#92;%&#92;)&lt;/span&gt; ，柴油机稍高一些，可达 &lt;span class=&quot;math inline&quot;&gt;&#92;(40&#92;%&#92;)&lt;/span&gt; ，而电动机的效率则高达 &lt;span class=&quot;math inline&quot;&gt;&#92;(90&#92;%&#92;)&lt;/span&gt; ，部分甚至可以达到 &lt;span class=&quot;math inline&quot;&gt;&#92;(95&#92;%&#92;)&lt;/span&gt;
。为什么燃油发动机的效率远远低于电动机呢？主要原因在于电动机可以直接将电能转换为机械能，结构简单，损耗极少。而燃油发动机则涉及多个能量转换环节，结构复杂，损耗较大。&lt;/p&gt;
&lt;p&gt;假如我们忽略燃油发动机的一切损耗，它的效率是否能达到 &lt;span class=&quot;math inline&quot;&gt;&#92;(100&#92;%&#92;)&lt;/span&gt;
呢？我曾一度认为可以，但后来发现并非如此。要解答这个问题，我们需要先从水流谈起。&lt;/p&gt;
&lt;h2 id=&quot;水轮机&quot;&gt;水轮机&lt;/h2&gt;
&lt;p&gt;把手放进流动的水中，我们可以明显感觉到水流的冲击力，水流越大越快，冲击力也就越大。人类很早就意识到了流水中蕴藏的能量，并用流水来驱动水车，用于灌溉、磨坊等，下图
1
所示为位于比利时一家磨坊的水车。水车虽好，但需要稳定的水流，旱季时水力不足，运转乏力甚至无法运行，如何才能一年四季不因雨量不同而影响水车运转呢？&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/turbine/waterwheel-braine-le-chateau.jpg&quot; alt=&quot;图1. 水车 Waterwheel&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图1. 水车 Waterwheel&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;答案很明显，修水坝，在雨季时把富余的水存储在高处，这样旱季时也能保证水车的正常运转。这一策略一直沿用了几千年，到现在无非就是大坝修得更高更好，水车换成了水轮机，驱动磨坊变成了发电而已。水在高处时，具有重力势能越大，但如果我们在高山湖泊中放置一台水车时，水车是不会转动的，因为湖泊中的水并不一定在流动，即使在流动，流速也很小，并不足以驱动水轮机。&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/turbine/vertical-waterwheel-simple.svg&quot; alt=&quot;图2. 水轮&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图2. 水轮&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;只有当水从高处流向低处时，势能才能转化为动能，推动水轮机从而进行机械作功，实现能量的转化与利用。&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/turbine/overshot-waterwheel-simple.svg&quot; alt=&quot;图3. 流动的水驱动水车&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图3. 流动的水驱动水车&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;从上图也可以看出，驱动水车的关键在于水的流动，而不在于水的多少。高山湖泊的水虽然重力势能很大，而且数量巨大，但是除非这些水从高处流下，否则并不能对外做功。&lt;/p&gt;</summary>
    
    
    
    <category term="Physics" scheme="https://www.longluo.me/categories/Physics/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Physics" scheme="https://www.longluo.me/tags/Physics/"/>
    
    <category term="Thermodynamics" scheme="https://www.longluo.me/tags/Thermodynamics/"/>
    
    <category term="Heat Engine" scheme="https://www.longluo.me/tags/Heat-Engine/"/>
    
    <category term="Carnot Cycle" scheme="https://www.longluo.me/tags/Carnot-Cycle/"/>
    
    <category term="Entropy" scheme="https://www.longluo.me/tags/Entropy/"/>
    
  </entry>
  
  <entry>
    <title>为什么 2024 年会有 366 天？</title>
    <link href="https://www.longluo.me/blog/leap-year/"/>
    <id>https://www.longluo.me/blog/leap-year/</id>
    <published>2024-12-21T13:28:05.000Z</published>
    <updated>2026-01-14T12:43:01.822Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;2024 年很快就要过去了，就在今天，我们脚下的地球已经以每秒约 30
公里的速度飞快越过了近日点，飞驰在围绕着太阳的椭圆轨道上。当 2025
年新年钟声敲响时，对于位于银河系第三旋臂边缘的这颗蓝色行星来说，不过是围绕着一颗黄矮星完成了一次再普通不过的公转，正如之前的
40
多亿次一样。而对于这颗行星上的碳基生物来说，不同的生物感受大不一样，这一刻却意味着对过去
366 个日夜 的告别与总结，也承载着对未来的期待与梦想。&lt;/p&gt;
&lt;p&gt;和 2023 年不一样的是，我们在 2024 年要经历 366 个日夜，因为 2024
年是&lt;strong&gt;闰年&lt;/strong&gt;。小学时，课本和老师都告诉我们一&lt;strong&gt;年&lt;/strong&gt;有
&lt;strong&gt;365&lt;/strong&gt; 天，但是闰年却是 &lt;strong&gt;366&lt;/strong&gt;
天，这多出来的一天就是 2 月 29 日，在英语中叫做 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;textit{Leap Day}&#92;)&lt;/span&gt;
。四年一闰，百年不闰，四百年再闰，这是闰年的规则。后来学习编程时，判断某一年是不是闰年也是常见的编程练习题。在学习之余，你有没有想过，为什么闰年的规则要这么奇怪呢？背后的原因是什么呢？&lt;/p&gt;
&lt;p&gt;小学读书时，就想 2 月份很委屈， 1 月 和 3 月都是 31 天，2 月却只有 28
或者 29 天，为什么 2 月这么特别呢？为什么有的月份是 31 天，有的月份是 30
天呢？但我的老师并没有讲清楚为什么，因为当时我的老师们也不清楚为什么，我也一直到大学里读了一本天文学书才知道了这个问题的答案。&lt;/p&gt;
&lt;p&gt;为什么 2024 年 2 月有 29
天？要回答这个问题，我们需要穿越历史的迷雾，回顾人类文明史，才能找到答案。&lt;/p&gt;
&lt;h2 id=&quot;逝者如斯夫不舍昼夜&quot;&gt;逝者如斯夫，不舍昼夜！&lt;/h2&gt;
&lt;p&gt;《鲁滨逊漂流记》中的鲁滨逊流落到荒岛之后第一时间就是竖起了一根大柱子，用刀子在立柱上刻上凹口当作日历。一方面是因为鲁滨逊是基督徒需要做礼拜，另外一方面也是为了记录时间。我们的现代生活是离不开钟表的，如果没有钟表来量化时间的话，我们的工作生活将失去秩序。当然鲁滨逊在荒岛上也只能过着“日出而作，日落而息”的农业社会生活，无法精确的安排工作和生活。&lt;/p&gt;
&lt;p&gt;“朝菌不知晦朔，蟪蛄不知春秋”，我们智人的寿命足够长，不像朝生暮死的蜉蝣，也不似春生夏死的寒蝉，可以目睹很多生命的诞生、成长以及消亡，感受时间的流逝。“逝者如斯夫，不舍昼夜！”，时间的洪流永远奔涌向前，然而虽然以我们生命的长度可以跨越四季与年轮，但是依然无法触及时间的尽头。&lt;/p&gt;
&lt;p&gt;寄蜉蝣于天地，渺沧海之一粟。哀吾生之须臾，羡长江之无穷。当然我们现在知道时间并不是均匀流逝的，也不能脱离物质而存在，但在足够宏大的尺度上，时间在均匀的流逝着。&lt;/p&gt;
&lt;p&gt;虽然你可能没有意识到，但是我们一直都在用着天然的时钟，它们就位于我们头顶的星空。这些时钟都足够精准，地球自转的每日误差在毫秒级别，月球公转和地球公转上百年也仅有几毫秒的差别。&lt;/p&gt;
&lt;p&gt;“日出东南隅，照我秦氏楼。”，新的一天又开始了；残月如弓，新月如眉，满月如镜，周而复始；“未觉池塘春草梦，阶前梧叶已秋声。”，四季轮回时，我们知道新的一年又来临了。&lt;/p&gt;</summary>
    
    
    
    <category term="Science" scheme="https://www.longluo.me/categories/Science/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Time" scheme="https://www.longluo.me/tags/Time/"/>
    
    <category term="Calendar" scheme="https://www.longluo.me/tags/Calendar/"/>
    
    <category term="Leap Year" scheme="https://www.longluo.me/tags/Leap-Year/"/>
    
    <category term="2024" scheme="https://www.longluo.me/tags/2024/"/>
    
  </entry>
  
  <entry>
    <title>数学之美：几何视角下的高斯积分(Gaussian Integral)</title>
    <link href="https://www.longluo.me/blog/gaussian-integral/"/>
    <id>https://www.longluo.me/blog/gaussian-integral/</id>
    <published>2024-05-11T07:34:38.000Z</published>
    <updated>2026-01-14T12:46:19.431Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;从之前的文章 &lt;a href=&quot;https://www.longluo.me/blog/normal-distribution/&quot;&gt;正态分布(Normal
Distribution)公式为什么长这样？&lt;/a&gt; 和 &lt;a href=&quot;https://www.longluo.me/blog/least-squares-and-normal-distribution/&quot;&gt;从最小二乘法到正态分布：高斯是如何找到失踪的谷神星的？&lt;/a&gt;
，我们使用了 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt;
种不同的方法最终得到了如下公式 &lt;span class=&quot;math inline&quot;&gt;&#92;((1)&#92;)&lt;/span&gt;
所示的误差的概率密度函数 ( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Probability
Density Function}&#92;)&lt;/span&gt; ) ：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
f(x) = &#92;mathrm{e}^{-cx^2}, &#92;, c &amp;gt; 0                 &#92;tag{1} &#92;label{1}
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;其函数图像如下图 1 所示的钟形曲线 ( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Bell Curve}&#92;)&lt;/span&gt; ) ：&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/normal-distribution/standard-deviation-diagram-micro.svg&quot; alt=&quot;图1. 钟形曲曲线&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图1. 钟形曲曲线&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;在概率论中，我们需要保证上图 1 中 &lt;span class=&quot;math inline&quot;&gt;&#92;(f(x)&#92;)&lt;/span&gt; 和 &lt;span class=&quot;math inline&quot;&gt;&#92;(x&#92;)&lt;/span&gt; 轴围成的面积是 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; , 即：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
&#92;int_{- &#92;infty}^{+ &#92;infty} f(x) &#92;mathrm{d}x = 1              &#92;tag{2}
&#92;label{2}
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;最终我们得到了正态分布 ( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Normal
Distribution}&#92;)&lt;/span&gt; ) 的公式如下所示：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
f(x) = {&#92;frac {1}{&#92;sigma {&#92;sqrt {2 &#92;pi }}}}&#92;;e^{-{&#92;frac {&#92;left(x - &#92;mu
&#92;right)^{2}}{2 &#92;sigma ^{2}}}}                &#92;tag{3} &#92;label{3}
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;上式中有一个 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;pi&#92;)&lt;/span&gt; ，用费曼( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Richard Feynman}&#92;)&lt;/span&gt;
)的话来说，当我们看到一个公式中存在 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;pi&#92;)&lt;/span&gt; 时，我们都要问自己“Where is the
cycle?”。我们知道公式 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;eqref{3}&#92;)&lt;/span&gt;
中的归一化系数 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;dfrac {1}{&#92;sigma {&#92;sqrt {2
&#92;pi }}}&#92;)&lt;/span&gt; 是为了保证 &lt;span class=&quot;math inline&quot;&gt;&#92;(f(x)&#92;)&lt;/span&gt;
下的面积为 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; ，出现 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;pi&#92;)&lt;/span&gt; 是因为高斯积分 ( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Gaussian Integral}&#92;)&lt;/span&gt; ) 的结果为 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;sqrt{&#92;pi}&#92;)&lt;/span&gt; 。&lt;/p&gt;
&lt;p&gt;那么什么是高斯积分呢？高斯积分和圆有什么关系呢？&lt;/p&gt;</summary>
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Gaussian Integral" scheme="https://www.longluo.me/tags/Gaussian-Integral/"/>
    
    <category term="Normal Distribution" scheme="https://www.longluo.me/tags/Normal-Distribution/"/>
    
    <category term="Statistics" scheme="https://www.longluo.me/tags/Statistics/"/>
    
    <category term="Circle" scheme="https://www.longluo.me/tags/Circle/"/>
    
  </entry>
  
  <entry>
    <title>从最小二乘法到正态分布：高斯是如何找到失踪的谷神星的？</title>
    <link href="https://www.longluo.me/blog/least-squares-and-normal-distribution/"/>
    <id>https://www.longluo.me/blog/least-squares-and-normal-distribution/</id>
    <published>2024-05-02T02:35:08.000Z</published>
    <updated>2026-01-14T12:47:47.042Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;在上一篇文章 &lt;a href=&quot;https://www.longluo.me/blog/normal-distribution/&quot;&gt;正态分布(Normal
Distribution)公式为什么长这样？&lt;/a&gt;
中，我们使用了&lt;strong&gt;投掷飞镖&lt;/strong&gt;的模型，推导出了正态分布( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Normal Distribution}&#92;)&lt;/span&gt;
)的表达式。这种方法既优雅又直观，所以常被用于科普视频或者文章中。那么这个例子是怎么来的呢？我们知道这个方法是天文学家赫歇尔（
&lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{John Herschel}&#92;)&lt;/span&gt; ）在 1850
年给出的，难道他在投掷飞镖时想到的吗？&lt;/p&gt;
&lt;p&gt;答案是否定的，原因是因为赫歇尔作为一个天文学家，需要精确的测量天体的位置，而在观测星星时，必须要考虑误差的影响。星星在天球中的位置误差是&lt;strong&gt;二维&lt;/strong&gt;的，考虑到误差大家不太好理解，所以用了投掷飞镖这个更通俗易懂的例子。&lt;/p&gt;
&lt;p&gt;正如法国著名哲学家孔德( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Auguste
Comte}&#92;)&lt;/span&gt; ，1798-1857)所说“To understand a science, it is
necessary to know its history.
”，只有了解这个学科的发展历史，了解这个学科的重要概念是如何建立起来的，才能真正理解这个学科。不同于我们在课本中学习顺序，科学是用来解决实际问题的，科学是由一个个问题所驱动发展的。正如仅次牛顿和爱因斯坦的伟大物理学家麦克斯韦(
&lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{James Clerk Maxwell}&#92;)&lt;/span&gt; )
曾说过“It is of great advantage to the student of any subject to read
the original memoirs on that subject, for science is always most
completely assimilated when it is in the nascent
state…”，我们学习历史上科学家是如何解决这些问题，用了什么方法，才能获取某个概念的
&lt;strong&gt;insight&lt;/strong&gt; ，建立 &lt;strong&gt;intuition&lt;/strong&gt; 。&lt;/p&gt;
&lt;p&gt;正态分布，又被称为高斯分布（ &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Gaussian Distribution}&#92;)&lt;/span&gt;
），人们可能会以为正态分布是由高斯发现的，但事实并非如此！&lt;/p&gt;
&lt;p&gt;正态分布最早是由法国数学家棣莫弗( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Abraham de Moivre}&#92;)&lt;/span&gt; , 1667-1754)在
1718
年左右发现的。他为了解决朋友提出的一个赌博问题，而去认真研究了二项分布。他发现当实验次数增大时，二项分布(
&lt;span class=&quot;math inline&quot;&gt;&#92;(p=0.5&#92;)&lt;/span&gt;
)趋近于一个看起来呈钟形的曲线，如下图 1
所示。后来著名法国数学家拉普拉斯( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Pierre-Simon Laplace}&#92;)&lt;/span&gt; ,
1749-1827)对此作了更详细的研究，并证明了 &lt;span class=&quot;math inline&quot;&gt;&#92;(p
&#92;ne 0.5&#92;)&lt;/span&gt;
时二项分布的极限也是正态分布。之后人们便将此称为&lt;strong&gt;棣莫弗 -
拉普拉斯中心极限定理&lt;/strong&gt;（ &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Central limit theorem}&#92;)&lt;/span&gt; ）。&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/probability/de-moivre-laplace.gif&quot; alt=&quot;图1. 二项分布趋近钟形曲线&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图1. 二项分布趋近钟形曲线&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id=&quot;失踪的谷神星&quot;&gt;失踪的谷神星&lt;/h2&gt;
&lt;p&gt;16 和 17
世纪是天文学发展的黄金时期，这一时期的科学革命彻底改变了人类对宇宙的理解。哥白尼(
&lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Nicolaus Copernicus}&#92;)&lt;/span&gt;
，1473-1543)的日心说、开普勒( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Johannes
Kepler}&#92;)&lt;/span&gt; ，1571-1630)的行星运动三定律、伽利略( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Galileo Galilei}&#92;)&lt;/span&gt;
，1564-1642)的望远镜观测以及牛顿( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Isaac Newton}&#92;)&lt;/span&gt;
，1643-1727)的万有引力定律共同构成了现代天文学的基础。这一时期的科学家们不仅改变了人类对宇宙的理解，还为后续的科学研究提供了重要的方法和工具。&lt;/p&gt;</summary>
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Normal Distribution" scheme="https://www.longluo.me/tags/Normal-Distribution/"/>
    
    <category term="Least Squares" scheme="https://www.longluo.me/tags/Least-Squares/"/>
    
    <category term="Gauss" scheme="https://www.longluo.me/tags/Gauss/"/>
    
  </entry>
  
  <entry>
    <title>正态分布(Normal Distribution)公式为什么长这样？</title>
    <link href="https://www.longluo.me/blog/normal-distribution/"/>
    <id>https://www.longluo.me/blog/normal-distribution/</id>
    <published>2024-04-27T05:16:57.000Z</published>
    <updated>2026-01-14T12:48:05.052Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;相信大家或多或少都听过六西格玛( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{6
Sigma}&#92;)&lt;/span&gt; ) &lt;a href=&quot;#fn1&quot; class=&quot;footnote-ref&quot; id=&quot;fnref1&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt; 这个词，六西格玛是指生产的产品中，
&lt;span class=&quot;math inline&quot;&gt;&#92;(99.99966&#92;%&#92;)&lt;/span&gt;
的产品是没有质量问题的，即只有 &lt;span class=&quot;math inline&quot;&gt;&#92;(3.4ppm&#92;)&lt;/span&gt; 的不良率。&lt;/p&gt;
&lt;p&gt;假如一家工厂生产某型号零件，零件的长度要求是 &lt;span class=&quot;math inline&quot;&gt;&#92;(100mm&#92;)&lt;/span&gt; ，允许的标准差是 &lt;span class=&quot;math inline&quot;&gt;&#92;(0.1mm&#92;)&lt;/span&gt; 。根据 &lt;span class=&quot;math inline&quot;&gt;&#92;(6 &#92;sigma&#92;)&lt;/span&gt; 原则，零件规格允许的偏差范围是：
&lt;span class=&quot;math inline&quot;&gt;&#92;(100 &#92;pm  6 &#92;times 0.1 = 100 &#92;pm 0.6&#92;)&lt;/span&gt;
。&lt;/p&gt;
&lt;p&gt;这意味着，零件长度超过 &lt;span class=&quot;math inline&quot;&gt;&#92;(100.6mm&#92;)&lt;/span&gt;
或低于 &lt;span class=&quot;math inline&quot;&gt;&#92;(99.4mm&#92;)&lt;/span&gt;
的概率是非常低的，约为 &lt;span class=&quot;math inline&quot;&gt;&#92;(0.00034&#92;%&#92;)&lt;/span&gt;
。如果工厂每天生产 100 万个零件，只允许有 &lt;span class=&quot;math inline&quot;&gt;&#92;(3.4&#92;)&lt;/span&gt; 个零件会超出 &lt;span class=&quot;math inline&quot;&gt;&#92;(6 &#92;sigma&#92;)&lt;/span&gt;
的范围，几乎可以忽略不计。因此，生产过程是极其稳定和可靠的，达到了六西格玛水平。&lt;/p&gt;
&lt;p&gt;那么 &lt;span class=&quot;math inline&quot;&gt;&#92;(6 &#92;sigma&#92;)&lt;/span&gt; 中 &lt;span class=&quot;math inline&quot;&gt;&#92;(3.4ppm&#92;)&lt;/span&gt; 的不良率来自哪里呢？&lt;/p&gt;
&lt;p&gt;学过中学数学都知道，在&lt;strong&gt;正态分布&lt;/strong&gt;( &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Normal Distribution}&#92;)&lt;/span&gt; ) &lt;a href=&quot;#fn2&quot; class=&quot;footnote-ref&quot; id=&quot;fnref2&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt; 中， &lt;span class=&quot;math inline&quot;&gt;&#92;(68.27&#92;%&#92;)&lt;/span&gt; 的数据位于平均值的一个标准差内，
&lt;span class=&quot;math inline&quot;&gt;&#92;(95.45&#92;%&#92;)&lt;/span&gt; 位于两个标准差内， &lt;span class=&quot;math inline&quot;&gt;&#92;(99.73&#92;%&#92;)&lt;/span&gt; 位于三个标准差内，这也是著名的
68-95-99.7 Rule &lt;a href=&quot;#fn3&quot; class=&quot;footnote-ref&quot; id=&quot;fnref3&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt; ，如下图 1 所示：&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/normal-distribution/standard-deviation-diagram-micro.svg&quot; alt=&quot;图1. 68-95-99.7 Rule&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图1. 68-95-99.7 Rule&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id=&quot;什么是正态分布&quot;&gt;什么是正态分布？&lt;/h2&gt;
&lt;p&gt;数据可以用不同的方式“分布”，比如数据可以向左散布的多一些，也可以向右散布的多一些，或者分布的乱七八糟，如下图
2 - 4 所示，&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/normal-distribution/normal-distribution-skew-left.gif&quot; alt=&quot;图2. 数据偏向左散布&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图2. 数据偏向左散布&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/normal-distribution/normal-distribution-skew-right.gif&quot; alt=&quot;图3. 数据偏向右散布&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图3. 数据偏向右散布&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/normal-distribution/normal-distribution-random.gif&quot; alt=&quot;图4. 数据随机分布&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图4. 数据随机分布&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;但数据经常会集中在一个中心值的附近，而不向左或右偏斜，像一个&lt;strong&gt;钟形&lt;/strong&gt;，如下图
5 所示。&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/normal-distribution/empirical-rule-histogram.svg&quot; alt=&quot;图5. 数据正态分布&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图5. 数据正态分布&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;正态分布，又称高斯分布（ &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Gaussian
Distribution}&#92;)&lt;/span&gt; ），是一种重要的概率分布，数学王子高斯 &lt;a href=&quot;#fn4&quot; class=&quot;footnote-ref&quot; id=&quot;fnref4&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;
在正态分布的研究和应用上做出了巨大贡献。有很多日常现象都符合这种分布，如人的身高、考试成绩等。正因为它几乎无处不在，所以叫
&lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;text{Normal Distribution}&#92;)&lt;/span&gt;
。德国曾经发行的一款 10 马克的纸币上就印着高斯和正态分布曲线，如下图 6
所示。&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/normal-distribution/gauss-10-mark.jpg&quot; alt=&quot;图6. 高斯和正态分布曲线&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图6. 高斯和正态分布曲线&lt;/figcaption&gt;
&lt;/figure&gt;</summary>
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Probability" scheme="https://www.longluo.me/tags/Probability/"/>
    
    <category term="Normal Distribution" scheme="https://www.longluo.me/tags/Normal-Distribution/"/>
    
    <category term="Statistics" scheme="https://www.longluo.me/tags/Statistics/"/>
    
  </entry>
  
  <entry>
    <title>高速公路编号背后的数学密码</title>
    <link href="https://www.longluo.me/blog/decode-the-highway-system-numbers/"/>
    <id>https://www.longluo.me/blog/decode-the-highway-system-numbers/</id>
    <published>2024-04-21T00:08:32.000Z</published>
    <updated>2026-01-14T12:45:19.791Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;世界那么大，我想去看看！随着科技的发展，我们早已做到无需离开家就能领略世界各地的风景和文化。通过高清视频、高清直播、社交媒体、
VR
技术、各种图片或者视频分享平台，我们不仅可以体验世界名胜古迹、自然美景和各地的风土人情，还能与当地居民互动，了解他们的日常生活和传统文化。互联网丰富了人们的生活，缩小了地域的界限，真正实现了让世界触手可及，足不出户便可周游世界的梦想。但正所谓“百闻不如一见”，“读万卷书，不如行万里路！”，尽管互联网让我们可以虚拟游览世界，但亲自出行的体验无可替代。自由行不仅提供了前所未有的自由和灵活性，还能让我们亲身感受到大自然的美妙、城市的活力。这种身临其境的体验，远非屏幕前的感受可比。&lt;/p&gt;
&lt;p&gt;当你打开地图软件时，你会看到如图 1 所示的道路标志，&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/road/highway-mark.png&quot; alt=&quot;图1. 道路编号&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图1. 道路编号&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;当你在道路出行时，你也会看到看到如下图 2
所示的路牌，但你可能并未真正留意过这些标志。因为现在我们只需要有一部联网的智能手机，在地图类软件里，设定出发地和目的地，自然有导航会指引我们到达目的地。&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/road/china-expwy-g35-sign-with-name-in-luogang-tollgate.jpg&quot; alt=&quot;图2. G35 高速萝岗路段&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图2. G35 高速萝岗路段&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;这些编号肯定不是随机的，那么这些道路编号到底有什么用呢？出于好奇心你可能会去寻找答案，你很容易轻松找到
中国国家高速的编号密码 &lt;a href=&quot;#fn1&quot; class=&quot;footnote-ref&quot; id=&quot;fnref1&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt; 和 高速公路是怎样命名和编号 &lt;a href=&quot;#fn2&quot; class=&quot;footnote-ref&quot; id=&quot;fnref2&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;
这样的文章。但这些文章只是告诉我们是什么，并没有告诉我们为什么。&lt;/p&gt;
&lt;p&gt;国内现行的高速公路命名是由交通部从 2005 年启动的 &lt;a href=&quot;#fn3&quot; class=&quot;footnote-ref&quot; id=&quot;fnref3&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;
，之前道路都以起始地和终点地命名。你可能会想，之前那种命名方式不是更合理吗？用了数字不是更加不清晰易懂吗？如果图
1 不是路牌上写了济广高速，谁知道 G35 &lt;a href=&quot;#fn4&quot; class=&quot;footnote-ref&quot; id=&quot;fnref4&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt; 是哪里到哪里呢？&lt;/p&gt;
&lt;p&gt;如果你更进一步的话，如果你去了解世界其他国家的高速公路命名的话，你会惊讶的地发现为什么居然全世界各主要大国都选择了类似的编号系统，这背后的原因是什么呢？&lt;/p&gt;
&lt;p&gt;要回答这个问题，我们需要把时钟拨回几十年前，回到高速公路诞生的时期，那个没有
GPS
，没有手机，只有纸质地图的时代，我们才能知道这种编号系统的&lt;strong&gt;重要意义&lt;/strong&gt;和&lt;strong&gt;实用性&lt;/strong&gt;，以及背后的&lt;strong&gt;数学密码&lt;/strong&gt;。&lt;/p&gt;
&lt;h2 id=&quot;世界各国如何对高速公路进行编号&quot;&gt;世界各国如何对高速公路进行编号？&lt;/h2&gt;
&lt;p&gt;我们已经了解了国内高速公路编号 &lt;a href=&quot;#fn5&quot; class=&quot;footnote-ref&quot; id=&quot;fnref5&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt;
，让我们看看其他国家的高速公路系统编号是什么样的。这些国家需要国土面积足够大，高速公路系统足够发达，国土疆域长宽比例没有太夸张，人口分布比较均匀。&lt;/p&gt;</summary>
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Code" scheme="https://www.longluo.me/tags/Code/"/>
    
    <category term="Navigation" scheme="https://www.longluo.me/tags/Navigation/"/>
    
    <category term="Highway" scheme="https://www.longluo.me/tags/Highway/"/>
    
  </entry>
  
  <entry>
    <title>2024 阿里巴巴全球数学竞赛预选赛 试题解答</title>
    <link href="https://www.longluo.me/blog/2024-alibaba-global-mathematics-competition-qualifying-round/"/>
    <id>https://www.longluo.me/blog/2024-alibaba-global-mathematics-competition-qualifying-round/</id>
    <published>2024-04-16T03:13:48.000Z</published>
    <updated>2026-01-14T12:43:01.820Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://damo.alibaba.com/?language=zh&quot;&gt;阿里巴巴达摩院&lt;/a&gt; 从
2018
年开始每年都会举办一届全球数学竞赛，之前一方面自己数学水平比较弱，另外一方面也没有报名，但一直很仰慕那些数学大神的风采。今年是第一次报名参加
&lt;a href=&quot;https://damo.alibaba.com/alibaba-global-mathematics-competition?language=zh&quot;&gt;2024阿里巴巴全球数学竞赛&lt;/a&gt;
，上周末参加了预选赛，但遗憾的是，全部 &lt;span class=&quot;math inline&quot;&gt;&#92;(7&#92;)&lt;/span&gt; 道题中只有第 &lt;span class=&quot;math inline&quot;&gt;&#92;(1, 2, 6&#92;)&lt;/span&gt; 题会做，这里分享下我的解答：&lt;/p&gt;
&lt;h2 id=&quot;problem-1&quot;&gt;Problem 1&lt;/h2&gt;
&lt;p&gt;几位同学假期组成一个小组去某市旅游. 该市有 &lt;span class=&quot;math inline&quot;&gt;&#92;(6&#92;)&lt;/span&gt; 座塔，它们的位置分别为 &lt;span class=&quot;math inline&quot;&gt;&#92;(A, B, C, D, E, F&#92;)&lt;/span&gt;
。同学们自由行动一段时间后，每位同学都发现，自己在所在的位置只能看到位于
&lt;span class=&quot;math inline&quot;&gt;&#92;(A, B, C, D&#92;)&lt;/span&gt; 处的四座塔，而看不到位于
&lt;span class=&quot;math inline&quot;&gt;&#92;(E&#92;)&lt;/span&gt; 和 &lt;span class=&quot;math inline&quot;&gt;&#92;(F&#92;)&lt;/span&gt; 的塔。已知：&lt;/p&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;同学们的位置和塔的位置均视为同一平面上的点，且这些点彼此不重合；&lt;/li&gt;
&lt;li&gt;塔中任意 &lt;span class=&quot;math inline&quot;&gt;&#92;(3&#92;)&lt;/span&gt; 点不共线；&lt;/li&gt;
&lt;li&gt;看不到塔的唯一可能就是视线被其它的塔所阻挡，例如，如果某位同学所在的位置
&lt;span class=&quot;math inline&quot;&gt;&#92;(P&#92;)&lt;/span&gt; 和 &lt;span class=&quot;math inline&quot;&gt;&#92;(A
, B&#92;)&lt;/span&gt; 共线，且 &lt;span class=&quot;math inline&quot;&gt;&#92;(A&#92;)&lt;/span&gt; 在线段
&lt;span class=&quot;math inline&quot;&gt;&#92;(PB&#92;)&lt;/span&gt; 上，那么该同学就看不到位于 &lt;span class=&quot;math inline&quot;&gt;&#92;(B&#92;)&lt;/span&gt; 处的塔。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;（5 分）&lt;/strong&gt; 请问 这个旅游小组最多可能有多少名同学？&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math inline&quot;&gt;&#92;(A. 3&#92;)&lt;/span&gt;&lt;br&gt;
&lt;span class=&quot;math inline&quot;&gt;&#92;(B. 4&#92;)&lt;/span&gt; &lt;span class=&quot;math inline&quot;&gt;&#92;(C.
6&#92;)&lt;/span&gt; &lt;span class=&quot;math inline&quot;&gt;&#92;(D. 12&#92;)&lt;/span&gt;&lt;/p&gt;
&lt;h3 id=&quot;solution&quot;&gt;Solution&lt;/h3&gt;
&lt;p&gt;这道题选 &lt;span class=&quot;math inline&quot;&gt;&#92;(C&#92;)&lt;/span&gt; ，最多只能有 &lt;span class=&quot;math inline&quot;&gt;&#92;(6&#92;)&lt;/span&gt; 名同学。&lt;/p&gt;
&lt;div class=&quot;note info&quot;&gt;&lt;p&gt;这道题的&lt;strong&gt;解题思路&lt;/strong&gt;是从假设只有 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; 座塔开始，一直到 &lt;span class=&quot;math inline&quot;&gt;&#92;(6&#92;)&lt;/span&gt; 座塔，找到思路。&lt;/p&gt;
&lt;/div&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;&lt;p&gt;假设有 &lt;span class=&quot;math inline&quot;&gt;&#92;(1&#92;)&lt;/span&gt; 座塔 &lt;span class=&quot;math inline&quot;&gt;&#92;(A&#92;)&lt;/span&gt; ，那么很显然有无数多同学可以看到塔
&lt;span class=&quot;math inline&quot;&gt;&#92;(A&#92;)&lt;/span&gt; ，也可以有无数多同学看不到塔
&lt;span class=&quot;math inline&quot;&gt;&#92;(A&#92;)&lt;/span&gt;​ ；&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;假设有 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 座塔 &lt;span class=&quot;math inline&quot;&gt;&#92;(A, B&#92;)&lt;/span&gt; ，那么只有以 &lt;span class=&quot;math inline&quot;&gt;&#92;(A&#92;)&lt;/span&gt; 为起点的射线 &lt;span class=&quot;math inline&quot;&gt;&#92;(AB&#92;)&lt;/span&gt; 且位于 &lt;span class=&quot;math inline&quot;&gt;&#92;(B&#92;)&lt;/span&gt; 之后的同学无法看到塔 &lt;span class=&quot;math inline&quot;&gt;&#92;(A&#92;)&lt;/span&gt; ；&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;假设有 &lt;span class=&quot;math inline&quot;&gt;&#92;(3&#92;)&lt;/span&gt; 座塔 &lt;span class=&quot;math inline&quot;&gt;&#92;(A, B, C&#92;)&lt;/span&gt;
，同理可知存在无数位同学至少可以看见 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 座塔；&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;假设有 &lt;span class=&quot;math inline&quot;&gt;&#92;(4&#92;)&lt;/span&gt; 座塔 &lt;span class=&quot;math inline&quot;&gt;&#92;(A, B, C, D&#92;)&lt;/span&gt;
，同理可知存在无数位同学至少可以看见 &lt;span class=&quot;math inline&quot;&gt;&#92;(2&#92;)&lt;/span&gt; 座塔；&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;假设有 &lt;span class=&quot;math inline&quot;&gt;&#92;(6&#92;)&lt;/span&gt; 座塔 &lt;span class=&quot;math inline&quot;&gt;&#92;(A, B, C, D, E, F&#92;)&lt;/span&gt; ，如果每位同学都无法看见
&lt;span class=&quot;math inline&quot;&gt;&#92;(E, F&#92;)&lt;/span&gt; 塔，如下图1 所示：&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;figure&gt;
&lt;img src=&quot;https://www.longluo.me/assets/blog/images/math/2024-alibaba-math-contest-problem1-solution.png&quot; alt=&quot;图1. Solution of Problem 1&quot;&gt;
&lt;figcaption aria-hidden=&quot;true&quot;&gt;图1. Solution of Problem 1&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;所以至多有 &lt;span class=&quot;math inline&quot;&gt;&#92;(6&#92;)&lt;/span&gt; 位同学位于 &lt;span class=&quot;math inline&quot;&gt;&#92;(M, N, O, P, R, Q&#92;)&lt;/span&gt; 处，无法看到塔 &lt;span class=&quot;math inline&quot;&gt;&#92;(E, F&#92;)&lt;/span&gt; 。&lt;/p&gt;</summary>
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Geometry" scheme="https://www.longluo.me/tags/Geometry/"/>
    
    <category term="Algebra" scheme="https://www.longluo.me/tags/Algebra/"/>
    
    <category term="Probability" scheme="https://www.longluo.me/tags/Probability/"/>
    
    <category term="Analysis" scheme="https://www.longluo.me/tags/Analysis/"/>
    
  </entry>
  
  <entry>
    <title>库函数 (libm) 是如何计算三角函数值的？</title>
    <link href="https://www.longluo.me/blog/sine/"/>
    <id>https://www.longluo.me/blog/sine/</id>
    <published>2024-02-16T12:32:58.000Z</published>
    <updated>2025-05-08T13:44:13.337Z</updated>
    
    
      
      
        
        
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;挖坑&quot;&gt;挖坑！&lt;/h2&gt;
&lt;figure class=&quot;highlight java&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td</summary>
        
      
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Algorithm" scheme="https://www.longluo.me/tags/Algorithm/"/>
    
    <category term="Arithmetic" scheme="https://www.longluo.me/tags/Arithmetic/"/>
    
    <category term="Floating point" scheme="https://www.longluo.me/tags/Floating-point/"/>
    
  </entry>
  
  <entry>
    <title>payne hanek 归约算法</title>
    <link href="https://www.longluo.me/blog/payne-hanek/"/>
    <id>https://www.longluo.me/blog/payne-hanek/</id>
    <published>2024-01-22T13:10:50.000Z</published>
    <updated>2026-04-01T15:55:36.446Z</updated>
    
    
      
      
        
        
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;挖坑&quot;&gt;挖坑&lt;/h2&gt;
&lt;h2 id=&quot;参考文献&quot;&gt;参考文献&lt;/h2&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;&lt;a</summary>
        
      
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Algorithm" scheme="https://www.longluo.me/tags/Algorithm/"/>
    
    <category term="Arithmetic" scheme="https://www.longluo.me/tags/Arithmetic/"/>
    
    <category term="Argument Reduction" scheme="https://www.longluo.me/tags/Argument-Reduction/"/>
    
    <category term="Computer Arithmetic" scheme="https://www.longluo.me/tags/Computer-Arithmetic/"/>
    
    <category term="Floating point" scheme="https://www.longluo.me/tags/Floating-point/"/>
    
    <category term="Trigonometric" scheme="https://www.longluo.me/tags/Trigonometric/"/>
    
  </entry>
  
  <entry>
    <title>音乐背后的数学</title>
    <link href="https://www.longluo.me/blog/math-of-music/"/>
    <id>https://www.longluo.me/blog/math-of-music/</id>
    <published>2024-01-12T11:18:38.000Z</published>
    <updated>2025-05-03T05:19:06.348Z</updated>
    
    
      
      
        
        
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;挖坑&quot;&gt;挖坑&lt;/h2&gt;
&lt;h2 id=&quot;声音是什么&quot;&gt;声音是什么？&lt;/h2&gt;
&lt;h2 id=&quot;什么是和弦&quot;&gt;什么是和弦？&lt;/h2&gt;
&lt;h2</summary>
        
      
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Music" scheme="https://www.longluo.me/tags/Music/"/>
    
  </entry>
  
  <entry>
    <title>素描背后的物理</title>
    <link href="https://www.longluo.me/blog/physics-behind-drawings/"/>
    <id>https://www.longluo.me/blog/physics-behind-drawings/</id>
    <published>2023-12-30T14:53:51.000Z</published>
    <updated>2024-03-11T13:15:42.116Z</updated>
    
    
      
      
        
        
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h1 id=&quot;挖坑&quot;&gt;挖坑&lt;/h1&gt;
&lt;h1 id=&quot;参考文献&quot;&gt;参考文献&lt;/h1&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;&lt;a</summary>
        
      
    
    
    
    <category term="Physics" scheme="https://www.longluo.me/categories/Physics/"/>
    
    
    <category term="Physics" scheme="https://www.longluo.me/tags/Physics/"/>
    
  </entry>
  
  <entry>
    <title>cody waite</title>
    <link href="https://www.longluo.me/blog/cody-waite/"/>
    <id>https://www.longluo.me/blog/cody-waite/</id>
    <published>2023-12-19T12:10:19.000Z</published>
    <updated>2025-10-31T14:22:37.828Z</updated>
    
    
      
      
        
        
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;挖坑&quot;&gt;挖坑&lt;/h2&gt;
&lt;h2 id=&quot;参考文献&quot;&gt;参考文献&lt;/h2&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;&lt;a</summary>
        
      
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Algorithm" scheme="https://www.longluo.me/tags/Algorithm/"/>
    
    <category term="Arithmetic" scheme="https://www.longluo.me/tags/Arithmetic/"/>
    
    <category term="Argument Reduction" scheme="https://www.longluo.me/tags/Argument-Reduction/"/>
    
    <category term="Computer Arithmetic" scheme="https://www.longluo.me/tags/Computer-Arithmetic/"/>
    
    <category term="Floating point" scheme="https://www.longluo.me/tags/Floating-point/"/>
    
    <category term="Trigonometric" scheme="https://www.longluo.me/tags/Trigonometric/"/>
    
  </entry>
  
  <entry>
    <title>浮点数</title>
    <link href="https://www.longluo.me/blog/floating-point/"/>
    <id>https://www.longluo.me/blog/floating-point/</id>
    <published>2023-12-03T14:12:45.000Z</published>
    <updated>2025-05-03T05:31:43.424Z</updated>
    
    
      
      
        
        
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;挖坑&quot;&gt;挖坑&lt;/h2&gt;
&lt;p&gt;假如你知道浮点数的话，你就知道为什么了！&lt;/p&gt;
&lt;p&gt;按照 IEEE 754 浮点数标准 制定的 浮点数运算法则，</summary>
        
      
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Algorithm" scheme="https://www.longluo.me/tags/Algorithm/"/>
    
    <category term="Arithmetic" scheme="https://www.longluo.me/tags/Arithmetic/"/>
    
    <category term="Floating-point" scheme="https://www.longluo.me/tags/Floating-point/"/>
    
  </entry>
  
  <entry>
    <title>Remez Algorithm</title>
    <link href="https://www.longluo.me/blog/remez-algorithm/"/>
    <id>https://www.longluo.me/blog/remez-algorithm/</id>
    <published>2023-10-06T23:08:37.000Z</published>
    <updated>2025-10-31T14:22:11.433Z</updated>
    
    
      
      
        
        
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;挖坑&quot;&gt;挖坑&lt;/h2&gt;
&lt;h2 id=&quot;参考文献&quot;&gt;参考文献&lt;/h2&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;&lt;a</summary>
        
      
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Analysis" scheme="https://www.longluo.me/tags/Analysis/"/>
    
    <category term="Calculus" scheme="https://www.longluo.me/tags/Calculus/"/>
    
    <category term="Taylor Series" scheme="https://www.longluo.me/tags/Taylor-Series/"/>
    
  </entry>
  
  <entry>
    <title>参数归约算法(Argument Range Reduction)：如何在浮点数环境下计算超大数字的三角函数值？</title>
    <link href="https://www.longluo.me/blog/argument-range-reduction/"/>
    <id>https://www.longluo.me/blog/argument-range-reduction/</id>
    <published>2023-09-16T14:05:07.000Z</published>
    <updated>2025-05-08T13:41:25.714Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;strong&gt;&lt;em&gt;By Long Luo&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;之前写过一篇介绍 CORDIC 算法 &lt;a href=&quot;#fn1&quot; class=&quot;footnote-ref&quot; id=&quot;fnref1&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt; 的文章，里面提到 CORDIC
算法的 &lt;a href=&quot;https://www.longluo.me/blog/cordic/#cordic-%E7%AE%97%E6%B3%95%E7%9A%84%E4%B8%8D%E8%B6%B3&quot;&gt;&lt;strong&gt;不足&lt;/strong&gt;&lt;/a&gt;
之处，CORDIC 算法的输入角度范围需要在 &lt;span class=&quot;math inline&quot;&gt;&#92;([−99.88^{&#92;circ} , 99.88^{&#92;circ}]&#92;)&lt;/span&gt;
，那么我们不禁要问，如果输入角度 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;large
{&#92;theta }&#92;)&lt;/span&gt; 很大的话，怎么处理呢？&lt;/p&gt;
&lt;p&gt;这个问题同样存在于 泰勒展开式(Taylor series) &lt;a href=&quot;#fn2&quot; class=&quot;footnote-ref&quot; id=&quot;fnref2&quot; role=&quot;doc-noteref&quot;&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;
中，比如 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;large {&#92;sin (x) }&#92;)&lt;/span&gt; 和
&lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;large {&#92;cos (x) }&#92;)&lt;/span&gt;
的泰勒展开式：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
&#92;sin(x) = x - &#92;frac {1}{3!}x^3 + &#92;frac {1}{5!}x^5 - &#92;frac {1}{7!} x^7 +
&#92;frac {1}{9!} x^9 + o(x^9) &#92;quad &#92;forall x &#92;subset &#92;mathbb{R}
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
&#92;cos(x) = 1 - &#92;frac {1}{2!}x^2 + &#92;frac {1}{4!}x^4 - &#92;frac {1}{6!} x^6 +
&#92;frac {1}{8!} x^8 + o(x^8) &#92;quad &#92;forall x &#92;subset &#92;mathbb{R}
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;虽然在整个实数集 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;large {
&#92;mathbb{R}}&#92;)&lt;/span&gt;
都成立，但是在实际应用中因为展开项数限制和浮点数的精度限制， &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;large {x}&#92;)&lt;/span&gt; 的范围只有在接近 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;large {0}&#92;)&lt;/span&gt; 的时候才有比较高的精度。&lt;/p&gt;
&lt;p&gt;但是实际应用中，如果输入 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;large
{x}&#92;)&lt;/span&gt; 很大的话，比如 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;large {2^{32},
10^{10}, 10^{22} &#92;dots }&#92;)&lt;/span&gt; 情况下怎么得到足够精确的值呢？&lt;/p&gt;
&lt;p&gt;中学里我们知道三角函数是&lt;strong&gt;周期函数&lt;/strong&gt;，对于比较大的值，我们可以使用下面的公式将值&lt;strong&gt;归约&lt;/strong&gt;到一个比较小的范围内。&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
x&#39; = x - 2k &#92;pi &#92;quad k &#92;subset &#92;mathbb{Z}
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;这就是我们今天要讲的 &lt;strong&gt;参数归约(Argument Reduction)&lt;/strong&gt;
算法。&lt;/p&gt;
&lt;h2 id=&quot;从小学计算题开始&quot;&gt;从小学计算题开始&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;参数归约&lt;/strong&gt;
听起来就很唬人，什么是参数啊，什么归约啊，都是些高大上的名词，听起来云里雾里的！&lt;/p&gt;
&lt;p&gt;为了不让大家产生厌倦和畏难心理，我们先从一道小学数学计算题开始：&lt;/p&gt;
&lt;p&gt;不借助计算器，计算 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;large {66600 &#92;times
666000}&#92;)&lt;/span&gt; 的值！&lt;/p&gt;
&lt;p&gt;对于这道题，大家可能会列出下列算术：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
66600 &#92;times 666000 = 666 &#92;times 666 &#92;times 100000 = 44355600000
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;但其实呢，我们也可以使用下面的方法：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;&#92;[
&#92;begin{aligned}
66600 &#92;times 666000 &amp;amp;= 111^2 &#92;times 4 &#92;times 9 &#92;times 10^5
&#92;&#92;&amp;amp;= 444 &#92;times 999 &#92;times 10^5
&#92;&#92;&amp;amp;= 444 &#92;times (1000 - 1) &#92;times 10^5
&#92;&#92;&amp;amp;= 4443556 &#92;times 10^5    
&#92;end{aligned}
&#92;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;如果我说上面这 &lt;span class=&quot;math inline&quot;&gt;&#92;(&#92;large {2}&#92;)&lt;/span&gt;
种方法都用到了&lt;strong&gt;参数归约&lt;/strong&gt;的思想，你可能会感到震惊，什么？这种小学计算题也用到了参数归约算法吗？&lt;/p&gt;</summary>
    
    
    
    <category term="Math" scheme="https://www.longluo.me/categories/Math/"/>
    
    
    <category term="Math" scheme="https://www.longluo.me/tags/Math/"/>
    
    <category term="Algorithm" scheme="https://www.longluo.me/tags/Algorithm/"/>
    
    <category term="Arithmetic" scheme="https://www.longluo.me/tags/Arithmetic/"/>
    
    <category term="Argument Reduction" scheme="https://www.longluo.me/tags/Argument-Reduction/"/>
    
    <category term="Computer Arithmetic" scheme="https://www.longluo.me/tags/Computer-Arithmetic/"/>
    
    <category term="Floating point" scheme="https://www.longluo.me/tags/Floating-point/"/>
    
    <category term="Trigonometric" scheme="https://www.longluo.me/tags/Trigonometric/"/>
    
  </entry>
  
</feed>
