2016年1月14日 星期四

美女與野獸的故事。


老商人時運不濟,

所謂老就是年紀大呼吸過的空氣比放的屁還要多,

年輕林業生意做光山上只剩腐敗的紅檜,只剩不是鳥居的索道,

祖產沒了沒有錢了,只能巴望著女兒嫁給有錢人繼續安定過好日子。



野獸老爺不講道理拿著水壺便能四處小便,

看似沒有文化但有錢就是可以任性,身旁亦不缺美女但多個也無礙,

老商人女兒的美貌等於一大箱沈甸甸的人民幣。

美女盡職地嫁給野獸老爺,老商人的善良正義回來了,

沈默偉大歲月從先人墳墓慢慢流出,又是美妙時光,

空氣泛著輕飄的音樂,可能是擾亂空氣波的流行音樂吧。



最初,美女無法忍受野獸老爺的低水平,野獸!

但在百般順從愛情的影響下,野獸老爺終於變成韓系師奶殺手,

心由相生,開始大談抽象廢話追尋心靈價值,

再也沒有人莫名其妙的消失,

再也沒有人可以顛覆野獸苦蹲十年監牢。



這是古典童話故事,美女不可以選擇丈夫,女人必須充分發揮她的命運,

如果她不愛男人,無法順著神的劇本演人生大戲,婚姻家庭價值將會崩解,

信望盟會很生氣喔,不可以欺負多數人的沈默喔,科科。



空氣中突然嘔出腐敗的蘇格蘭威士忌味道,這是什麼西方思想?

沒有婚姻的美女,一文不值,

老商人把人民幣換成新台幣,

開心數錢,數好數滿,數到痔瘡都坐破了。

2016年1月12日 星期二

Notes on ellipse

1. Equation:
  • x^2/a^2 + y^2/b^2 = 1
  • x(t) = a cos(t), y(t) = b sin(t)


2. Arc length:
  • Integrate from t = 0 to t_0, sqrt[x'(t)^2 + y'(t)^2] dt
  • Integrate from t = 0 to t_0, sqrt[a^2 sin(t)^2 + b^2 cos(t)^2] dt


2016年1月7日 星期四

Fermat's theorem on sums of two squares

1. Introduction


2. Brahmagupta–Fibonacci identity


3. Algorithm

2016年1月4日 星期一

Pythagorean triples

1. wiki:


2. Euclid's formula is a fundamental formula for generating Pythagorean triples given an arbitrary pair of positive integers m and n with m > n.
  • a = m^2 - n^2
  • b = 2mn
  • c = m^2 + n^2
where m and n is coprime and odd parity.

How to iterate all coprime pairs:

2016年1月3日 星期日

算不出來的滋味。


沮喪的心情,往日你喜歡沈溺複雜公式,

成長的題數,曾百岳般刺激你的活力,

再不願讓妳征服!別害羞,快撤退,

你這老人每個地形架繩確保也要跌跌撞撞。



算了吧,我的心。

睡吧,呼呼鼾聲喊著喊著。



精神失敗,筋疲力盡!

這業餘數學家,成功再也無法引誘好勝的心,

台北的冬天失去霉鏽味的雨滴卻留住了寒冷,

寒冷呀,你可願意帶著我離開算不出來的滋味?

2015年12月25日 星期五

Notes on Möbius function

To solve ProjectEuler problems, we need some basic knowledge about Möbius function.



1. Definition: mu(n).



2. sum_{d|n} mu(d) = [n = 1].
Let n = gcd(a, b). sum_{d|gcd(a, b)} mu(d) = sum_{d|a, d|b} mu(d) = [gcd(a, b) = 1]



3. Mertens function: M(n) = sum_{k ≤ n} mu(k).



4. M(n) = 1 - sum_{d ≥ 2} M(n/d).
sum_{d ≤ n} M(n/d) = sum_{d ≤ n} sum_{k ≤ n/d} mu(k) = sum_{d ≤ n} sum_{k|d} mu(k) = sum_{d ≤ n} [d = 1] = 1

Reference: Deléglise, M., Rivat, J.: Computing the summation of the Möbius function. Experimental Mathematics 5(4), 291–295 (1996). [https://projecteuclid.org/download/pdf_1/euclid.em/1047565447]



5. Let S(n) denote the number of square-free positive integers ≤ n.
S(n) = sum_{d ≤ sqrt(n)} mu(d) floor(n/d^2).

Besides, let C(n) be the number of cube-free positive integers ≤ n.
C(n) = sum_{d ≤ n^{1/3}} mu(d) floor(n/d^3).

Reference: Jakub Pawlewicz, Counting square-free numbers (2011), arXiv:1107.4890. [http://arxiv.org/pdf/1107.4890v1.pdf]



6. Let P(n) be the number of primitive Pythagorean triples with a < b < c ≤ n.
Let a = x^2 − y^2, b = 2xy, c = x^2 + y^2 with x, y coprime (positive) integers of opposite parity.

Hence, P(n) = { (x, y) in R(n) : gcd(x, y) = 1, opposite parity } where R(n) = { (x, y) : x^2 + y^2 ≤ n, 0 < x < y }.
Also we let Q(n) = { (x, y) in R(n) : gcd(x, y) = 1 }.

If (x, y) in Q(n), then (1) x, y opposite parity (2) x, y are odd.  In case (1), (x, y) in P(n).  In case (2), gcd(a, b, c) = gcd(x^2 - y^2, 2xy, x^2 + y^2) = gcd(2x^2, 2xy, 2y^2) = 2 gcd(x^2, xy, y^2) = 2.  So (x, y) in P(n/2).  Hence Q(n) = P(n) + P(n/2).

Therefore, P(n) = sum_{k ≥ 0}(-1)^k Q(n/2^k). (no more opposite parity).

Now we want to represent Q(n) in terms of R(n): Q(n) = sum_{1 ≤ k ≤ Floor[Sqrt[n]]} mu(k) R(n/k^2).

Reference: Pythagorean triangles with legs less than n [http://ac.els-cdn.com/S0377042701004964/1-s2.0-S0377042701004964-main.pdf?_tid=2a2d0446-ac6b-11e5-a15e-00000aab0f27&acdnat=1451201377_754b996c3258324dc6694d8b83ba6b6f]