2009年4月30日 星期四

一個質數分佈的統計方法

又是時代已久遠到無從躇考的主意,當時剛剛升上中一,興致勃勃要拿一個諾貝爾數學獎,其中一個開心大發現是質數的分佈,是當時在研究如何寫一個找一個數的因子,由此去統計世上所有的質數,但是如此文,遇到了死迴圈便放棄了,心想人腦比電腦聰明的地方在於人腦可以自行發現解決不了的問題(Infinite recursion)而放棄的,而電腦就不懂,一定要寫程式的人去代它發現,電腦並不聰明,而是寫程式的人聰明!

今天似乎是解決了,但想必早有其他數學家發現了!

我的思路是:
1. 因為一個數的因子最大只可能是它的平方根,即任何數在某意義上都涵蓋了它的平方,由它的性質去決定在它平方範圍內的數是不是質數;
2. 另外,再考慮到所有非質數的分佈,例如2的倍數出現在任何數字的機會是2份1.3的倍數出現在任何數字的機會是3份1,N的倍數出現在任何數字的機會是N份1,只要除去該範圍內的所有部數,剩下的一定非質數不可。
1是決定了質數範圍,2是用反向思維來提供找質數的方法,關門可以打狗!

所以結論是:
質數在N^2內的機會率為:
1-[(2的倒數+3的倒數+4的倒數+...N的倒數)-(2...N的倒數的所有組合,如此是減去多數一次的因子,例如4是2的部數)]

出問題了!
因為2也是2的倍數,3也是3的倍數,如此類推,即如果因子本身是質數,在我算法內也會被當成非質數,因為我的算法本身不是用來決定一個數是不是質數,我的算法只可以排除一定不是質數的數字,所以此算法只可以作為近似值,用來比較N平方到(N+1)平方的質數分佈,不可以推出一個絕對值。

(後記,現在剛想到的是可不可冒險犯難,把所有因子自動當成質數而加入算式內呢?因此變成:
1-[(2的倒數-N平方的倒數+3的倒數-N平方的倒數+4的倒數-N平方的倒數+...N的倒數)-(2...N的倒數
的所有組合,如此是減去多數一次的因子,例如4是2的部數)]
或:
1-[(2的倒數+3的倒數+4的倒數+...N的倒數)-(2...N的倒數的所有組合,如此是減去多數一次的因子,例如4是2的部數)-N的倒數]
未解決,未解決,未解決!)

找一個數的所有因子的方法

這是我中一時遇到而解決不了的問題,解決不了不是因為我不懂寫電腦程式,也不是因為這問題本身很困難,而是自己的思想陷入了一個無窮遞歸的循環中跑不出來,因此令我對電腦最初設計者Newman提出的「停止問題(Halting problem)」印象深刻,人腦真的不同電腦。
我當時用的是Dbase作業系統,所以當學到有速算法可立刻分出哪一個數是某數的倍數時,立刻蠢蠢欲動,想寫一個可以分解一個數的所有因子的程式,我的思路是既然一個數最高的因子是它的平方根,因此只要由2開始逐個用速算法測試,直到它最接近它的平方根的整數為止,但是如此一來,數值大小便和要測試的時間成指數比例,8個位的數字是4個位的100部,如何縮短它的所需時間呢?
其中一個思路就是利用遞歸的慨念,在測試某一數字是否它的因子之前,先去測此因子是不是之前已測試的因子之部數,例如要測試101是否為4的部數,只要再測試一下4是不是之前曾測試過的因子2的部數,另外再用邏緝去推斷,既然101不可以被2整除,則它當然不可能被2的部數4來整除;倒過來說,如果它可以被2去整除,則一定要先測試才知道它可不可以被4去整除。

所以最初想的程式的大致結構如下:
輸入1N位的數字,用它的平方根來產生1陣列,以陣列的1來表達可被整除
由2開始到它的平方根(否則會進死迴圈不能停止),
{當陣列對應的值不是1時,
用存在資料庫的樣式來比較輸入之數字是不是可被整除,
如果可以的話把陣列對應的值改成1}

,好像是忘記了什麼?忘記了節省時間的因子再被之前的因子去測試的「偉大發現」!
再補充一下,但如何加上去呢?因為測試數字的次數是定值,而測試因子的次數卻跟因子值而變,我當時不懂如何用Dbase寫出來,因此問題被擱置了!

現在當然是想通了,
輸入1N位的數字,用它的平方根來產生1陣列,以陣列的1來表達可被整除
K由2開始到它的平方根(否則會進死迴圈不能停止),
{
N由2開始直到K的正整數平方根
(當陣列K的值不是1時,
用存在資料庫的樣式來比較輸入之數字是不是可被N整除,
如果可以的話,則:
假如陣列K的值是0,即之前已測試的因子不可以整除輸入的數字,改陣列N的值為0;
並把K加1)
當陣列K的值不是1時,
用存在資料庫的樣式來比較輸入之數字是不是可被整除,
如果可以的話把陣列對應的值改成1;}

不過我當時想的還有更深的一步,有沒有辦法去令電腦自己懂得尋找速算法而不見程式人員輸入呢?我當然懂2,3,4,5,6,9的速算法,但要是其他未知的呢?可不可以寫一個程式去讓電腦先去自己生產一個速算法,然後再利用自己生產的速算法來檢測因子呢?可不可以再推前幾步呢?

(以當時的技術是決沒有可能,但現在可以利用程式天演算法(evolutionary computing)來自己生產程式,所以是絕對可能,但是它可能到再前哪一步呢?相信再進步的電腦也不懂自己找問題來研究吧!)

環保數學?

環保數學不是我原創的,記得曾在多年前的比賽時已有中學生提出在數學科中加環境保護相關的項目/教材,如在教正比例時計一下當香港成為曾蔭權心目中的一千萬人口大都會時每天排出的污水有多少,每天生產了多少二氧化碳,環保設施又要增加幾多,因此庫房額外多支出多少等等,我以為可以再進一步,因為據認知心理學的研究,人類似乎是天生難於理解指數式增進,所以與其還是背誦計算機可應付得焯焊有餘的9*9乘數表,不如背9^9的指數表來補償人類天生的認知缺陷, 斧底抽薪地學習環保意識。因為此指數表的數位太大,所以建議小學時只背到所有結果為5位數範圍以內的指數,而中學畢業前要完成9位以內所有的指數。

睡夢中發電郵:潛意識在演化中?

一直以來,在心理分析學說及心理學界中都會把潛意識看成是很原始和簡單的精神結構,因此不會邏緝思考,不會分辨好壞,只有慾望和最簡單的分析能力;但是睡夢中發電郵此例似乎是打破了此一共識,人類不單在意識層面會演化,會學習新能力,而且似乎在潛意識層面會演化,會學習新能力,因為發電郵要登入登出及掌握通訊理論這些頗複雜的東西。而我以為,似乎在動物中除人類之外就沒有其他物種有此能力,你不會看見老鼠可以在睡夢中走迷宮,馬在睡夢中由賽跑,狗在睡夢擔報紙,因為人類的潛意識和意識在神經系統中區間較少,所以人類的知識和能力可以較容易由意識上的行為轉化為潛意識的自動反應,令人類可花更多精力集中去更高深及更抽象的鑽研自然現象,所以人是萬物之靈,不過因為同樣原因,人類出現了其他物種都沒有的問題:精神分姴症。

The evolution of unconscious mind: Writing email during dream?

I would think the case which a woman found writing email during her sleep-walking demonstrate the unique advantage of human being compare to other species. That is I never heard of case which mice run through the maze during slept, or horse ran from place to place during dream. It appears to me that not just our conscious mind is capable to restructure itself by learning, so do our unconscious mind.
It has been traditional thought unconscious to be a more primitive mind that is incapable of performing logical operation. Human unconscious mind is richer than we once thought. I suspect it is easier for human being to 'transfer' knowledge/skills from conscious mind to unconscious. i.e. It is easier for us to form complex habit, thus make room for us to entertain even more complex and abstract thought. So logically, the next question would be how many skills that are master by unconscious mind that we don't know of?
Monkey or ape maybe able to learn as fast as human being during conscious, but I am doubtful if they can perform the same trick while they are sleeping. Since it take them relatively longer to move the same knowledge/skill from conscious mastery to unconscious automation. That maybe the unique human trait(less differentiation between conscious mind/unconscious mind led to more case of schizophrenia?)

From the ordeal of e-book to the nature of HKSAR governance

I had recently writing too much on Christian right, to the point that I almost forgot that I was once a FOSS activist, which I only criticize HKSAR for its colonial complex and entanglement of business interest and politics. Now there is yet another case to demonstrate the validity of my claim of 'crony' capitalism practice by HKSAR: Originally the e-book scheme proposed could reduce the cost of textbooks for many lower class parents, while stimulate the growth of creative industry: Programming and create a local ecosystem of knowledge workers and layperson expertise. However, in the name of free market and fairness in procurement, it devolve to the point where it is not longer affordable by not just lower class, but the lower end of middle class. What is happening?
Because once and again, HKSAR always has a heart for Big Business monopoly just like itself being a political hegemony. So the operating system of choice to run this scheme has switch from stable and free Linux which is free to modify and improve to Microsoft Windows system which has hundreds of software patent. Once HKSAR has chosen the stupid road of Intellectual Property in its local software development industry, those who can participate switch from tens of thousand of Netizen who barely made their ends meet to hundreds of certified Microsoft expert. And inevitably, the rich and knowledgeable only become richer and more knowledgeable; the poor and needy of knowledge in Age of Internet only become more deprave in terms of knowledge and money. Why?
In order to become a certified Microsogy expert like MCSE, one would have to be able to afford more than just a broadband Internet connection, but a computer with all latest and best hardware certified by Microsoft to be comparable, on top of the expansive but not so stable Windows-XP, plus a few suits of softwares like Visual Basic Studio along with Anti-Virus softwares. Beside, you can't cooperate with your friends using this software since it is against the user license agreement that you can't disagree. Then you got to pass MCSE and the like only to discover that the final decision whether developing such a software is feasible depends on:
A. Would you like your knowledge to be copyrighted(monopolize) by Microsoft(which is how they license the so-called 'Wikipedia of music')?
B. Would such a software hurt Microsoft's future business plan?
So much investment in Microsoft that would made anyone become a partner in business interest of Microsoft.

In comparison, when this software is develop locally using Free and Open Source operating systems like FreeBSD/Linux. The cost is mostly to maintain your Internet connection and your computer working. Since Linux/FreeBSD doesn't require the latest and best hardware certified by a convicted Big monopoly, nor you need a license agreement with Microsoft to utilize the patented software technologies of Microsoft. Most of your resource needed to develop e-book is freely available in the Linux/FreeBSD community of on the Internet. Plus you can use FOSS software to collaborate with your friends from all over the world legally and without cost. Certainly you don't need any 'approval' from Linux/FreeBSD community, nor worrying about hurting the 'business interest' of LUGs. Beside, you can always make you and other Netizen's contribution acknowledged by using one of the donzes license from Common Creative. How would such a software be qualitatively poorer than those who made by patented technologies, so to warrant HKSAR to choose Microsoft instead of FOSS alternative?

It is ridiculous and extremely backward to utilize the legal mechanism of copyright protection for protecting the intellectual property of textbook, since Netwon and Einstein never got a dime from the producers of Physics textbook. It is even worst when the prices of textbook has become prohibitively expansive for some parents in those few years at Hong Kong. In the Age of Information yet we still charge textbook by its content which also freely available in Wikipedia but not charge by its unique method for synthesis and organizing data into useful system of knowledge! What unique value that those textbook publisher produced in the process of making this textbook that no educator could thought of (in terms of teaching method), and what advance and latest knowledge that Netizen has no idea of? When a GPL technology is freely available for HKSAR to take advantage of, why doesn't HKSAR to make the best out of it? Is that the idea of 'I will get the job done' of Donald Duck? Is that such a decision so hard to made, or a non-substainable oligarchies of Hong Kong would always perfer non-substainable policy over people's long term development?

Living in HKSAR is great for all of us, since the citizen is always lightyear ahead of its Idoitic Government. I wonder if Donald Tseung is still reading 'Dummy's Guide to Governing'?

2009年4月24日 星期五

政制及「內地」事務局的真正命名涵義

中文「及」通常的用法是把兩件有相關的事聯係起來,因此我們有「人力資源及勞工事務局」,因為兩者都是香港教育制度的目的,生產可供資本家任意剝削的「人力資源」,而人力資源被利用其中一個方式就是勞工;就算兩者不是有對等關係,如作者和讀者,民主和專制;兩者都可以歸類作因某一共同目的而在一起的東西,如成人及小童一同被資本家利用等,在此例中成人及小童在資本家眼都是同一類的東西,分別不大。

用上面邏緝去分析政制及內地事務局的命名涵義,可以聯想到:

1.香港的政治制度是內地事務的一環,還是內地事務是香港的政治制度務,我相信沒有正常思想的香港會以為是前者,或者在2003年前人大政協為香港民主政治發展釋法前兩者真是差不多平行的,但現在當然完全屬於內地事務,香港人無容置喙了;

2. 香港的政治制度和內地事務在中共眼中都是同一類的東西,因此必須由一位根正苗紅的「自己人」曾德成來處理,而如此重要的國家事務當然不可能由香港人來歸類, 不過香港人也不是完全沒有自由可以「港人自講式」歸類為無關重要的東西,因為永遠道德政治經濟正確光榮偉大的中國共產黨一早已「預見」了香港未來五十年政制不變是對中國及香港最好的選擇,否則不知是成了龍還是成了籠的人仕就會覺得社會太黃太暴力太民主太自由太開放,道德不見底式淪亡了。

曾蔭權偽政改出籠時的一個觀察

如果香港是真真正正的言論自由,百花齊放的話,何以一般人要自費在報紙賣廣告來表達自己的想法呢?香港不是享受充份的言論自由,有六、七份報紙各有自己「獨立」的立場嗎?為什麼反對偽政改的廣告只會出現在蘋果日報呢?而支持偽政改又多數出現在另一份東方日報呢?不是說香港市民因為富有,所以可以比其他自由國家更多一個表達自己意見的地方呢?

如果香港是真真正正的言論自由,百花齊放的話,何以一般人要自費在報紙賣廣告來表達自己的想法呢?香港不是享有充份的言論自由呢?香港有六、七個電台、免費及收費的電視台不是都各有自己「獨立」的立場嗎,讓市民暢所欲言呢?為什麼反對偽政改的意見只會出現在香港電台呢?因此香港人是不用民間電台、電視台哪一額外多餘的意見渠道的!香港何來不民主、不自由?

(似乎忘記了最近不知什麼華人基督教聯會的東西四處在學校外掛橫額要求從嚴修訂淫審條例,香港因此又比以前更自由,宗教勢力又多了一個渠道去表達自己的意見了!)

香港電子書的大鬧劇看香港特區政府的心態

我寫得太多關於基督右派的文章,有時也忘記了自己曾是自由軟件運動的一名活躍份子,我曾發表文章痛批因香港特區政府的官商勾結和祟洋情結,把本來可以既減低一般學生家長的子女書簿費負擔、二來可發展本土的電腦創意工業﹝Linux/FreeBSD﹞及建立公共知識領域的電子書計劃,由所謂自由經濟的所謂公平競爭之名,竟然變成比實體書本更令一般學生家長負擔不起,何解?因為香港特區政府又一如以往選擇了微軟作業系統為其基礎,而一但使用擁有軟件專利的微軟系統,則由於走的不是開放源碼的路,可以參與的人就由一大堆普通網民變成一小撮間接被微軟操控的「微軟專家」,商業利益繼續被一小撮相對富有的壟斷者瓜分,富有更富有,貧困的更貧困。想像一下,學Linux的入門成本只是互聯網的費用,大部份學習資源都可以在全球Linux社群取得,不用未見官先打三百大板,先買最新的微軟作業系統,因為微軟作業系統要買較大的硬碟、較快的處理器以及由微軟認證的一大堆電腦硬體,再買一大堆的合法軟體如 Visual Basic Studio﹝只可以一人用,不可以和朋友一起研究,否則違反使用者條款﹞,然後考完多重的試MCSE,再由微軟決定你是否合格,當然,你最後可不可以在微軟的平台上發展電子書,還得看會不會有損微軟的商業利益﹝即微軟是否有意發展電子書﹞,以及你打不打算把公有知識的版權都當成微軟的﹝如微軟的音樂庫百科全書要求使用者放棄自己的版權﹞,投入了這麼多資源/時間,你怎可能不成為維護微軟既得利益者的一份子呢?

相反,如果發展電子書工業用GPL註冊的Linux系統,不單發展者不要付一筆龐大的版權費,發展者之間可自由交流,並由交流之中推動民間經濟的發展,把發展時累積的技術知識回譴給一般網民,而且系統相對安全穩定,病毒、木馬更是罕有中的罕有,且要求的硬體較低較便宜,不用最新最快最有名的,而且內容可由教師及公共知識份子、一般網民提供,以相同方式共享的版權註冊,甚至是不用版權。現在已經是資訊時代,知識的形式及內涵竟然還受版權保護的實體而收費,卻不是以資訊整理的方法和手段而收費,實屬落伍荒謬可笑,再者,魯迅未曾從香港的中文教科書收到一分錢,卻有市民因負擔不起中文教科書連CD而生活困頓被迫退學,但是起中文教科書連CD有什麼內容是原創兼結合最新最有效的教學手法,連教師及一般網民都想不到呢?如此,所謂教科書有價,它的價值來自哪兒?知識的傳播因官僚的因循而成為天價,有免費的開放源碼技術又不加以善用,造福社會,就是不給以不法手段的技術壟斷者多一分錢不安心,不單是慷納稅人之慨,更非迫市民大衆支持自己愚蠢的選擇,這叫什麼「打好這份工」?令富者愈富愈有控制資訊的能力,這叫什麼社會公義?一但微軟沒有興趣去支援電子書的作業平台,納稅人除了被迫向微軟「年年進貢,歲歲來朝」之外,還可以作什麼呢?這叫什麼可持續發展?

我看的是:一個不可以持續發展的政權,理所當然地選擇了一個不可以持續發展的政策,理所當然地傾向最富有最有勢力的洋集團,對香港未來一點承擔也沒有!

2009年4月22日 星期三

From the watchmaker's argument to the notion of Atheistic Intelligence

Surely, one of the familiar proof of the existence of Christian God is the Watchmaker's argument, namely when we look at the surrounding then any layperson should realize it must be a product of divine intelligence.
Evidently it has skipped one step:
Since human being is a biological entity, therefore we would infer with anthropocentric basis. We would identify 'evidence of God's work' using same criteria as we identify the product of human labor, which subtly equating human with Christian God(since both are active in shaping the environment.) Just like when we look out from our eye and forgot the eyesight of us is bounded by the structure and mechanism of the components of the eye; the proponent of this line of argument has forgotten we are thinking with a built-in bias: Our own existence. We are thinking from the structures of our brain using mechanisms of our mind. Much like eyelid bound our eyesight but we tend to think what we see is the whole world without boundary, when we are thinking we assume that our thinking is as unbounded as our eyesight. We naturally and easily forgot there is a framework which our thinking take place. The realization of this boundary and framework of our thinking, i.e. when we are thinking we know it is 'we as human being' are thinking. So we are more than ready to attribute any human characteristic to the natural world, much like we characterize storm with human emotion like angry, furor, rages.
I believe the realization of the boundary of one's thought is an remarkable intellectual achievement. I think it could be use as a reliable measurement of intelligence, and as a sign of intellectual maturity. What I am arriving at is a politically incorrect notion that Atheist are more intelligent than religious.

2009年4月21日 星期二

A program to find all the factors of a number(II)

Last time when I was writing to complete my childhood wish to write a (BASIC) program to find all the factors of a number using heuristic learn from Primary School. However, when I was doing so I has forgotten the true difficult of the program: To shorten the test time, the program would limit to test only the prime factors of the number without knowing which factor are prime. In order to do so, the program will have to test the factor recursively, but I fail to find a way to such write a recursive loop.

Now, I just thought of another method to shorten the search of all factors of a number.

Given a number N,

Define the lower limit of √N as K,

Make an array of K item,

Starting from K,

Check if the K-th element of the Array is zero, otherwise reduce K by 1.

Test if N is divisible by K,

If not reduce K by 1, otherwise:

1.Mark the K as divisible by making the value of K-th item of the array to be 1

2. start the Test for Prime Factor with K as the input.

Test For Prime Factor:

(Define the lower limit of √N as K,

Make an array of K item,

Starting from K,

Test if N is divisible by K,

If not reduce K by 1, otherwise Mark the K as divisible by making the value of K-th item of the array to be 1.)

So, in according to this procedure, if it discover a factor of the N, for instance, 40 is a factor for 1600. Then it would proceed to look up for the factor of 40, which it would arrive at the results: 1,2,4,5,8,10,20. Since 40 is a factor of 1600, and we can logically conclude that the factor of the factor 40 is also a factor of 1600, i.e. 1,2,4,5,8,10,20 are also factors for 1600, which will be skipped for checking in the bigger loop.

Notice the similarity between checking for factor of the number and the checking for factor of the factor. A usual way to save time when writing program is to re-use what is already developed, therefore my first intention is to re-use the same algorithm for checking for factor of the number to check for factor of the factor. Now, wouldn't we able to apply the same logic so we should also checking for factor of the factor of the number to further shorten the process? Should we should also checking for factor of the factor of the factor of the number to further shorten the process?

So in my mind there is no built it mechanism to prevent me from infinite recursion, but when programming in whatever programming language, I need to explicitly state when I need to re-use a sub-procedure. That is the difference between computer and human mind.

2009年4月20日 星期一

A strange phenomena?

Consider that 21^2=441,

Also (2+1)^2=(4+4+1).

i.e. The sum of square of the digits of a number is equal to the sum of digits of the number squared.

Now try 22^2=484,

Also (2+2)^2=(4+8+4)
Actually 11,12,13,31,10,20,30 also share the same property.

To find out why those number has this property, we can do some simple algebra:
For 2 digits, suppose the number is X(1) X(2), and the square of this number is S(1)S(2)S(3)
that has the property which The sum of square of the digits of a number is equal to the sum of digits of the number squared,
i.e. (10X(1)+X(2))^2=S(1)*100+S(2)*10+S(3) AND
(X(1)+X(2))^2=S(1)+S(2)+S(3)

Or 99X(1)^2+18X(1)*X(2)=99S(1)+9S(2)
Or 11X(1)^2+2X(1)*X(2)=11S(1)+S(2)
(which X(1),X(2),S(1),S(2),S(3) must be natural number)

Is that given any X(1),X(2);we can always find suitable pairs of S(1),S(2)?
Not necessarily, because All number are within the range of 0-9,
therefore, 108>11S(1)+S(2)>10 or 108>11X(1)^2+2X(1)*X(2)>10

A method to approximate the distribution of Prime numner

The idea is following my idea to find all the factors of a number. We know that for a number X, all its factor could be found within square of X. So for N^2, at most it will have N factors, or it will have none except 1 and N.

Since we also know that the factor of 2 has a probability of 1/2 in any natural number; the factor of 3 has a probability of 1/3 in any natural number; thereby the factor N has a probability of 1/N in any natural number. We thus can find the prime by eliminate all known factors.

To count the prime number within range of 1 to N^2 is thus,

[1-(1/2+1/3+1/4+...+1/N-(Any combinations of 1/2,1/3....1/N))]*N

Now consider the various range:
For N=2, the probability of a prime=1-1/2=1/2,
which is 2.
For N=3, the probability of a prime=1-(1/2+1/3-1/6)=1/3,
the prime numbers are 2,3,5,7 which is 4/9;
there is a difference of 1/9.

How come? Because when counting prime numbers, we discount 2,3 because they are also the multiple of 2 and 3.

We can assume that as N become greater, the different would be smaller.

A program to find all the factors of a number

That is yet another unfulfilled task dating from my Primary School. I was embarking on the challenge to write a program in DBASE to find all the factors of a number using heuristic like 'If the sum of digits of a number is divisible by 3, then the number itself is divisible by 3', or 'If the last digit of a number is 0 or 5, then it is divisible by 5'... etc. However, what I haven't fully considered is any number except prime number would always contain repeated factor, i.e. 2^n, 3^n...etc; and I fail to find a way to do recursion in DBASE so I gave up. Instead I write an extremely simple program which use the modulus of a number by a divisor, when there is a remainder then it return false otherwise true.

Now, I finally have the momentum to pick up when I left, to devise a method to find all divisor, include repeated ones. (Actually it is intended to find all the prime numbers within a range.)

Input the number X,
Initialize an array with length square of X.
The test would be ranged from 2 to square of X,
'Starting from 2 to N,
test if X is divisble by that number, if so added 1 to position (that number) of an array,
continue the process until it is no longer divisble by that number;'
The answer is those array element with value great than 0.
(We can branch off at divisibility test using any given criteria. )

i.e. If array(2)=3, then 2,4,8 is all factor of the number.

To use this method to find all prime number, we only require those with the result which all value of array is zero.

Fun to try!

2009年4月19日 星期日

某一條數學假說及它的推廣

說出來也為羞愧的,因為我自中四第一次見到此假說,過了超過十年竟然想不出如何用嚴僅的推理來證明,而它也是超級複雜的東西,它只有兩條演算規律:

A. 如果是單數則加1,
B. 如果是雙數則除2;
要證明的是任何一個正整數,在經過有限的步驟後最終一定會陷入1-2-1的死迴圈;

我想來想去的結論都是: 如何證明任何一個正整數都可以用2的升冪來表示呢?
即任何數=n(1)*2^0+n(2)*2^1+n(3)*2^2+.....n(k)*2^(k-1)

只要能證明此前設,其實即2進制可以成立的基礎,則不難證明任何一個單數:
A. 一定是先經A步再行B步,得出比本身少的數值,如25,26,13,14,7,8,4,2,1,因此這是遞減數列,數值只會愈來愈細,不會愈來愈大,因為數值本身是有限,所以最終一定在經過有限的步驟後最終一定會陷入1-2-1的死迴圈;

如果是任何一個雙數,同理會形成遞減數列,數值只會愈來愈細,不會愈來愈大,再分兩類:
A. 2的完整乘冪,如2的7次方128,則會直降到1,最終一定會陷入1-2-1的死迴圈,步驟數為2的完整次方數;
B. 2的不完整乘冪,如2的7次方加6次方192,則會經歷一有限次數的B步而成為單數,在此例中則是經歷6次B步後成為3,因為是單數,所以可以應用上面單數的證明來解決。

算不算證明完畢?

其實有更有趣的事,我想問的是到底在十進制可以有幾多條如此的假說,是不是有限數?而每一個假說又有什麼特色?
例如用三條演算規律:
A. 如果用3除剩1時是加2,
B. 如果用3除剩2時是加1,
C. 如果用3可整除時是除3,
要證明的是任何一個正整數,在經過有限的步驟後最終一定會陷入3-1-3的死迴圈;

單是加不夠好玩,不如改成:
例如用三條演算規律:
A. 如果用3除剩1時是減2,
B. 如果用3除剩2時是加1,
C. 如果用3可整除時是除3,
要證明的是任何一個正整數,在經過有限的步驟後最終一定會陷入3-1-3的死迴圈;

留意到什麼沒有?
理論上,我可以隨便作一條出來:
A. 如果用5除剩1時是減2,
B. 如果用5除剩2時是加1,
C. 如果用5可剩3時是減3,
D. 如果用5除剩4時是加1,
E. 如果用5可整除時是除3,
要證明的是任何一個正整數,在經過有限的步驟後最終一定會陷入5-1的死迴圈。

(未完待續....)

My idea on environmental friendly Mathematics

That is actually nothing new, using examples from environmental issue like pollution, growth of population, depletion of Ozone in Mathematics textbook is already an adopted idea. My thought is related to a more fundamental change in the syllabus of Mathematics: It was suggested human mind has difficulty to contemplate exponential growth, which maybe a root cause for the lack of awareness of the issue of population explosion. So my suggestion is instead of memorize the multiplication table of from 1*1 to 10*10, student should learn to memorize the index table from 1^1 to 10^10 (For all the result within 5 digits in Primary School, and 10 digits when graduate from Secondary School). In this way, student would built a sense of how growth of population affect the Earth from Primary school; moreover, what we master when we memorize the multiplication table is essentially doing the arithmetic operation of addition in our head, but not doing multiplication . Who can push it to the syllabus around the world?

2009年4月15日 星期三

中文輸入法的另一個主意

上次我談及改良中文輸入法的方向是減低使用者對某一輸入法的依賴,強迫使用者每次使用同一輸入法時要留神螢幕,因為每次出現的中文字順序不同;(我還未想到有什麼方式可以取替目前以字形或筆劃為本的中文輸入法。)而今次的方向則相當正路,就是如何改善使用者輸入中文的效率?

而本慨念發明有四個組成部份:

A.可動態由D修改的中文字碼對應表,該種中文輸入法的中文字輸出由此提供;

B.利用數據庫來記錄使用者使用某一種中文輸入法的習慣,主要以字碼輸入的組合為索引值;

C.使用習慣數據分析器,分析使用者使用該種中文輸入法時的習慣,用同一組字碼輸入中這些字最常用,這些字通常不用,當然,這是最簡單的方法,可以用更複雜的方法如Bayesian分析法來分析使用者使用某一中文輸入法中某一組字碼的習慣;

D.執行者用一早設定好的內建條件,利用C的方法來比較,計算某一組字碼輸入法中各中文字的最佳順序,以此來更新A的中文字碼對應表,令使用者打中文字的效率提高。

Yet another Idea on Chinese input method

Now this idea is truly about how to increase the efficiency and the speed of inputing Chinese character. Not that I am going to suggest a new paradigm to input Chinese without using keystrokes which each keystroke is associated with certain aspect of the Chinese character, I am thinking in the direction which the program can dynamically alter the correspondence table which the Chinese input method rely on. For instance, much like search engine would provide search suggestion while the user is entering the inquiry using statistically method, this new paradigm of Chinese input method would 'learn from the experience' of the pattern of how this Chinese input is used by this user, then dynamically place the most frequent choice in the front as priority choice in order to save user's time to look for the Chinese character which s/he is typing.(Or to learn more complex pattern of the input given all of us have enough computing cycle that we waste.)

This innovation require three components:

A. A correspondence table that can be dynamical updated by D each time it is loaded;

B. A recorder and counter program to run in the background whatever this Chinese input method is called. It would record the frequency of the user's choice of Chinese character everytime and keep a database with various variables.

C. A statistic program to analyze the data collected in B. It could be ranged from simplest implementation like taking the most frequent choice as the preferred choice by moving it to the front or more difficult implementation involve Bayesian statistical method.

D. By applying the result gathered from A to compare against the fixed criteria provided by programmer, this module update the content inside A so A would be optimized for this user.

一個古怪的中文輸入法主意

說古怪這主意真的很古怪,因為一般分析/設計/改良中文輸入法的人都會向如何增加輸入中文的速度及準誠度去想,決不會像我一樣把問題的方法倒轉去想的,因為我想解決的問題不在於中文輸入法是否好用實用,我意會的問題在於當一個人太熟悉一種中文輸入法時,他/她輸入中文便成了反射反應,他/她根本不用看鍵盤甚至是螢幕便知道自己打了什麼字,理論上可以令他/她的腦神經有更多的資源去進行更高階的運算如遣詞用字、文章組織及思想內涵等,但缺點就是打中文字的機械化,他/她失去了認知心理學中最低層反應的靈活性;要是一天有一種更新更好的輸入法時,他/她就失去了適應的能力,所以本文章的思路就是如何令使用者保持打中文字的靈活性?

要解決這問題很簡單,相信要實現也會太複雜,就是把目前的固定的中文編碼表改為可動態更新的,而每一次使用者使用完的時侯,就會把當中的中文順序更新,例如本來今次用某輸入法打ABCD得出來的是Q,W,E,R,T,Y;而下一次用同一種輸入法再打ABCD得出來的可能是W,E,R,T,Y,Q又或者是R,T,Y,Q,W,E...等等,因為每次出現的中文字順序不同,因此使用者不可能依賴習慣,看都不用看螢幕便打完一篇文章,否則一定會錯漏百出, 如此便強迫使用者每次用同一輸入法更新一下使用者的神經網絡,令使用者保持頭腦靈活!

2009年4月6日 星期一

A strange idea on Chinese input method

This is indeed an very odd idea, because this idea is not about simplify the input of Chinese character, rather it has an the opposite effect of lengthen the process. Why is it necessary?

My thought is that when we have been input Chinese using certain method for too long, we essentially programmed our neurons much like reflex action. Just like we have forgotten how to type in keyboard, the process has become largely unconscious automation.

The advantage of this mechanization of Chinese input free us from the repeating routine which involve little intelligence, and theoretically we thus have more neurological-computational resource to handle the higher level processing like think what to write, the effect and intend of the writing, the philosophy of writing... etc. However, on the other end, it may create an effect which one is essentially forgetting what s/he type, thus may result in unable to write Chinese without computer keyboard.

My solution is to make a dynamic realignment of the Chinese character everytime the user utilize this method for the same set of input. Thus s/he can't rely on rote memory of the location of the Chinese character, the user pay attention to the character s/he pick since it would appear in different location each time. So the user at least are trained to recognize the Chinese character, strengthen existing neurological representation of the particular Chinese character. Then when the user is face with the situation which s/he have to user another Chinese input method, s/he will adapt to it more readily compare to those who only memorize the associated keystroke of that Chinese character.

Who can implement such a strange idea?