In [ ]:
from local_utils import *
%pylab inline

從生活中發現數學: 選擇的智慧

國立東華大學 應用數學系 魏澤人

2015 Nov 27 @師大附中

MIT License

http://github.com/tjwei/math-can-see-dimensions

$\swarrow$ 打開$\|數學\|$之$\mathbf{\widetilde{眼}}$ $\nearrow$

∿ $\small\oint$奧義$\small\oint$ $\otimes$ $\mathbf{次元}^{\tiny\infty}$

𝕸𝕬𝕿𝕳 𝕮𝕬𝕹 𝕺𝕰𝕰 𝕯𝕴𝕸𝕰𝕹𝕺𝕴𝕺𝕹𝕺

從生活中發現數學: 選擇的智慧

小女孩撿石頭的故事

(轉寄信、民間傳說故事)

據說林肯總統,在郊外散步時,遇到了一個小女孩。他想考驗這個女孩

說:「小朋友,這段路上有很多石頭,妳從這裡走到那頭,撿一個最大的石頭來給我。石頭愈大,禮物就愈大。

But

絕對不可以回頭撿哦!」

女孩便出發。

不多久,看到一粒很大的石頭,想撿,但又想:說不定前面還有更大的呢。

往前走了一陣,果然看到一粒更大的石頭。正想撿起,又想:「後面說不定還有更大的呢」。

就這樣猶豫不決,一不注意,便走到了盡頭,什麼也沒撿到。

很多人把它解釋在愛情上

小女孩走的這一段路不就好像是我們的人生嗎?

人生錯過了就再也不能回頭

  • 用數學之眼,會看到裡面的數學
  • 舒老師也看到了,等下會講
  • 選擇的智慧,斬掉這一段
If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.

    ---John von Neumann 

旋轉


In [7]:
!./rungeogebra

你的數學書在吶喊著:

換個角度來看世界吧!

真相藏在背後的次元

照片是怎麼壓縮成 JPEG 的?

"JPEG is alien technology from the future".

-- Tim Terriberry


In [ ]:
show_dct_fig()


In [ ]:
img = mpimg.imread('img/abel.jpg'); plt.imshow(img, cmap=mpl.cm.gray);

In [ ]:
show_image(img)

In [ ]:
tiny = img[40:48, 64:72];show_image(tiny)
$$ G = {DCT} \cdot f \cdot {DCT}^{T} $$$$ f = {DCT}^T \cdot G \cdot {DCT} $$

現代數學的書只分成兩種

  • 那些你讀不完第一頁的,和
  • 那些你讀不完第一行的。

    --- C. N. Yang


In [ ]:
tinyDCT = doDCT(tiny);show_image(tinyDCT)

In [ ]:
figure(figsize=(12,36))
for u in range(12):
    subplot(6, 2, u+1)
    title(str(u))
    imshow(dct_all(img, u), cmap=mpl.cm.gray, interpolation="none")

Hybrid Image

A. Oliva, A. Torralba, P.G. Schyns (2006). Hybrid Images. ACM Transactions on Graphics, ACM Siggraph, 25-3, 527-530.

Art Style Transfer

A Neural Algorithm of Artistic Style" by Gatys, Ecker and Bethge. (26 Aug 2015)

http://arxiv.org/abs/1508.06576, http://arxiv.org/abs/1505.07376, http://bethgelab.org/deepneuralart/.

The difference between science and magic is that magicians usually know what they're doing.

-- Ashleigh Brilliant

乘法

$53 \times 78$

$ 5 \cdot 7 $

$ 5 \cdot 8 + 3 \cdot 7 $

$ 3 \cdot 8 $

Karatsuba algorithm

$53 \times 78$

$ A = 5 \cdot 7 $

$ B = 3 \cdot 8 $

$ C = (5+3)\cdot(7+8)$

$ 5 \cdot 8 + 3 \cdot 7 = C - A -B $

$5321 \times 7894$

$ A = 53 \cdot 78 $

$ B = 21 \cdot 94 $

$ C = (53+21)\cdot(78+94)$

$ 53 \cdot 94 + 21 \cdot 78 = C - A - B $

Toom–Cook

$ 352 \times 516 $

只要 5 次乘法

$ 352 \times 516 $

$p(x) = 3x^2 + 5x + 2 $

$q(x) = 5x^2 + 1x + 6 $

我們想求 $ p(10)q(10) $

$ r(x) = p(x)q(x) $ 是 4 次多項式

代入5 個值就能決定係數

$\left(\begin{matrix}p(0)\\ p(1)\\ p(-1)\\ p(-2)\\ p(\infty) \end{matrix}\right)=\left(\begin{matrix}0 & 0 & 1\\ 1 & 1 & 1\\ 1 & -1 & 1\\ 4 & -2 & 1\\ 1 & 0 & 0 \end{matrix}\right)\left(\begin{matrix}3\\ 5\\ 2 \end{matrix}\right)$

$\left(\begin{matrix}q(0)\\ q(1)\\ q(-1)\\ q(-2)\\ q(\infty) \end{matrix}\right)=\left(\begin{matrix}0 & 0 & 1\\ 1 & 1 & 1\\ 1 & -1 & 1\\ 4 & -2 & 1\\ 1 & 0 & 0 \end{matrix}\right)\left(\begin{matrix}5\\ 1\\ 6 \end{matrix}\right)$

$\left(\begin{matrix}r(0)\\ r(1)\\ r(-1)\\ r(-2)\\ r(\infty) \end{matrix}\right)=\left(\begin{matrix}p(0)q(0)\\ p(1)q(1)\\ p(-1)q(-1)\\ p(-2)q(-2)\\ p(\infty)q(\infty) \end{matrix}\right).$

$\left(\begin{matrix}r(0)\\ r(1)\\ r(-1)\\ r(-2)\\ r(\infty) \end{matrix}\right)=\left(\begin{matrix}0 & 0 & 0 & 0 & 1\\ 1 & 1 & 1 & 1 & 1\\ 1 & -1 & 1 & -1 & 1\\ 16 & -8 & 4 & -1 & 1\\ 1 & 0 & 0 & 0 & 0 \end{matrix}\right)\left(\begin{matrix}?\\ ?\\ ?\\ ?\\ ? \end{matrix}\right).$

  • 原來是交叉相乘(covolution)
  • 經由座標變換
  • 變成逐點相乘
  • 再轉換回來即可

Schönhage–Strassen


In [ ]:
show_dct_fig()

更多更多

word2vec

King - Man + Woman = Queen


In [ ]:
w('掌法')

In [ ]:
w('蛤蟆功')-w('歐陽鋒')+ w('洪七公')

In [ ]:
w("華箏")-w("郭靖") + w("周師兄")

In [ ]:
w('丘處機') + (w('鐵杖')-w("柯鎮惡"))

In [ ]:
w("鐵掌") + (w('周伯通')-w("空明拳"))

In [ ]:
w('降龍十八掌')-w("郭靖")

In [ ]:
w("飯")-w("吃")+w("喝")

Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks

Alec Radford, Luke Metz, Soumith Chintala

Nov 19 2015

編碼

  • 一千瓶酒和 10 隻小老鼠
  • 一千瓶酒和 30 隻小老鼠
  • 霍夫曼編碼(壓縮)
  • Entropy
  • 如果老鼠會騙人?
    • 一千瓶酒和 30 隻小老鼠(again?)
    • 一千瓶酒和 14 隻小老鼠

世界充滿著「魔法」

打開數學之眼

世界變得更大