20101010

開立方根不用計算機


4 3 次方是4 x 4 x 4 = 64,換言之,64 3 方,即64 的立方根便是4,很簡單的。

66 的立方根是多少?

66 64 相差不遠,答案必定是 4 再多一點點。

一按計算機,答案是4.0412...

不用計算機,那很難吧?

這裡有個方法:

那一點點,就是數字多出的部分除以3,再除以該數字立方根的平方。

比方說,現在要求66 的立方根,那66 - 64 = 2 就是那多出的部分。所以,立方根多出的部分,就是 2 除以3,再除以64 的立方根的平方,即4的平方,那就是16。而23再除16,則等於八分一除3,即0.1253,約等於0.042

這多出的一點點再加上原來的4,就是4.042。而4.042 3 方,等於66.04,和66相比,誤差只有百分之四左右,不俗吧?


為什麼這方法可以求出立方根?

在微積分裡,

所以

現在是開立方根,所以設

這就是為何會出現那三分之一。

所以

這方法其實用來求平方根也可以,稍加更改,那一點點超出的部分,就是相差的數目再除以2,然後再除以該數字的平方根。

20100606

超焦距及其應用(續)

The Physical Theory of Hyperfocal Distance and its Application to Photography (cont.)

May, 2010

Ringo Cheung


Abstract
Last time the hyperfocal distance equation in terms of f, N and c was derived from the thin lens formulas. In this article, the relationship between H with f, N and c will be analyzed and some physical inference will be discussed.

Relationship of H with f
Recall that the equation for hyperfocal distance H is given by :


Since H varies with the square of f rather than linearly, a small increase in f will result in a large increase in H. For example, for a 25mm lens of 135 format, H = 2.72m at an aperture of F8; while that for a 50mm lens, H = 10.83m at the same F-stop.

Graph of H vs. f
The 2nd time derivative of H w.r.t. f is :


and the minimum of H exists at f = -Nc/2, the graph concaves upwards. By considering only positive values of f for practical purposes, the graph of H vs. f for 135mm format camera (coc = 0.029) and an F-stop of N = 8 is :


For focal length of 35mm and longer, H is over 5.32m. While this is useful for scene photography, it is not very convenient for street photography and snapshot.

Graph of H vs. N
For a lens of fixed f and c, H is strictly decreasing with N since



as c > 0. On the other hand, a larger f-number means a smaller aperture. Therefore a larger f-number like f8 or f11 will result in a smaller H than with f4. The graph of a 25mm lens (135 format, i.e. coc = 0.029) with f-number from 1 to 16 is depicted below :


which is a hyperbola.

Relationship of H vs. c
Roughly speaking, H is strictly decreasing with c from the hyperfocal distance equation. However, since cameras of different formats have their own definition of wide angle, standard and telephoto lenses, (e.g. a standard 50mm lens in 135 format is considered a wide angle lens in 6x6, 120 format, with c = 0.053) a direct comparison of H vs. c (i.e. different camera formats / film sizes) is not of much practical usefulness.


Conclusion
From the above discussion, a wide angle lens set at small aperture (i.e. a large f-number) is a good candidate for short hyperfocal distance (H) and is more convenient for street and snapshot photos.

20091025

The Physical Theory of Hyperfocal Distance and its Application to Photography

The Physical Theory of Hyperfocal Distance and its Application to Photography

Ringo Cheung

Oct, 2009


Introduction

Applying the method of producing a long depth of field has long been the practice of experienced photographers, especially for those who are engaged in scene photography. Ansel Adams, who is widely recognized as the master of large format natural scene photography and dark room expert, established the "Group f/64" [1] with some other experts like Edward Weston in the same field. It is known that with a smaller aperture of lens (i.e. larger f-number), a longer (larger) depth of field can be achieved. While this is a widely accepted general knowledge among the professionals and even serious amateurs, the concept and application of Hyperfocal Distance (HFD), which extends the depth of field to a distance of infinity, was largely ignored by modern photographers. This can be seen from the lack of "depth of field" indicator in some modern lenses manufactured today [2].

In this article, important concepts that lead to HFD such as lens maker formula, circle of confusion (COC) and depth of field (DOF) will be explained. It is then followed by an explanation of how the equation of HFD is derived. Finally, its applications to photography will be explained with examples.


Circle of Confusion (COC) and Depth of Field (DOF)

The concept of COC is highly related to depth of field (DOF). Due to the defects of human eyes, we are not able to distinguish a very small circle from a very small spot [3]. When a cone of light rays passes through a lens, it is not perfectly focused even when imaging a point source, instead, an optical spot is resulted. This is the COC, and is used to determine the DOF, the part of the image that is acceptably sharp. Different lens manufacturers have different values of COC. The widely accepted values of COC for 35mm format is 0.03mm, for APS format is 0.02mm and for Four Thirds System is 0.015mm [4].

Hence, DOF can be viewed as the portion of the scene that is acceptably sharp, or appears to be sharp in the image. In some images such as landscape or scene photography, a large DOF is desirable, or appropriate, to depict the fine details of the scene. As a result, scene photographers usually use a very small aperture to achieve a long DOF.

Largest DOF is achieved when focus is set to the so called HFD. The DOF will extend from half the HFD to infinity (as will be proved below). This is the largest DOF possible for a given f-number.


Hyperfocal Distance (HFD)

The following discussion assumes the use of symmetrical thin lenses. For asymmetrical lenses, a factor called "pupil of magnification" must be taken into consideration [5].

Fig.1

Referring to Fig.1 and making use of similar triangles and the thin lens equation [6]


where as usual, O is the object distance, I is the image distance and f the focal length, the near and far limits of DOF is given by [5]:

and

where

s is the subject distance

f is the focal length of the lens

N is the aperture

c is the COC


The HFD formula is derived as follow. According to the definition of HFD, the far limit of DOF, DF is infinity. Hence the denominator vanishes, giving:


where H is the HFD.

On the other hand, the near limit or DN will be H since we are focusing on the HFD. Setting s to H and solving for DN gives [5]:


Hence the depth of field will extend from half of the HFD to infinity.


Examples of Applications of HFD

Recall the formula for HFD is

For a 35mm format camera with typical COC value of 0.03mm, using an f-number of f16 and a lens of focal length 50mm, the HFD is

H = (50)2/ (16 x 0.03) + 50 = 5258.33mm≒5.26m

Hence for this lens using an aperture of f16 and focusing on a distance of 5.26m, the DOF will extend from approximately 5.26÷2 = 2.63m to infinity.

Fig.2

To set the HFD on the camera, first adjust an f-number that will be used, e.g. f16. Then on the lens DOF indicator, set the focus to infinity (fig. 2) [7]. We can see that the DOF indicator gives us the DOF from approx. 5m to infinity. Then turn the focusing ring on the lens until it focuses on the hyperfocal distance of 5m (fig. 3). Now the DOF will be from 2.5m to infinity, meaning that anything within this range will be sharp. In other words, HFD maximizes usable DOF.
With appropriate use of the HFD theory, snap shot on the street (aka street photography) would become easy. By estimating the hyperfocal distance, everything within the range will be sharp. Photographers need only concentrate on framing and motion of the subjects, instead of worrying about the sharpness [7].



References

[1] Biography of Ansel Adams, The Ansel Adams Gallery - http://www.anseladams.com/content/ansel_info/anseladams_biography2.html
[2] DOF, Hyperfocal distance and Calculator, Guides @ nikonians.org - http://www.nikonians.org/html/resources/guides/dof/hyperfocal4.html
[3] 高品質黑白攝影的技法, 蔣載榮, 雄獅圖書股份有限公司, 1996, p.20
[4] Circle of confusion, Wikipedia - http://en.wikipedia.org/wiki/Circle_of_confusion
[5] Depth of field, Wikipedia - http://en.wikipedia.org/wiki/Depth_of_field
[6] How to derive the thin lens equation, Hirophysics.com - http://hirophysics.com/Anime/thinlenseq.html
[7] Using Hyperfocal Distance in Street Photography, Olympus/Zuiko - http://olympuszuiko.wordpress.com/2007/03/20/using-hyperfocal-distance-in-street-photography/

20090417

《我的十年書單》















不是說其他書不好看,也可能因為其他書太好看,所以遲遲未清理這張清單。這只是本清單的第一部份,涵蓋部份我認為必須一看(至少看一次)的書籍。但由於種種原因,諸如時間、金錢、空間上的限制而未能實現。希望,在可見的將來,可以一口氣把它們看完。


電腦科學

書名:The Emperor's New Mind
作者:Roger Penrose
為何想看:二十世紀科普中的巨著。涵蓋電腦科學、思維、數學及物理。作者用近 600 頁的篇幅去解釋為何我們不能真正了解人是如何思考的。內容廣博,推導嚴謹,是我看過各類關於杜林機( Turing Machine)、計算理論(Computation Theory)、複數(Complex Number)、碎形(Fractal) 中最精彩的一部,關於人工智能的一本巨著。

書名:Introduction to the Theory of Computation
作者:Michael Sipser
為何想看:計算理論(Computation Theory)的入門書。雖說入門,但內容涵蓋多個重要題目,包括有限狀態自動機(Finite Automata)、杜林機、P / NP 難題、複雜性(Complexity)等等及其相關問題的嚴謹証明。作者序中有一小段發人深省的說話:
Computer technology changes quickly. Specific technical knowledge, though useful today, becomes outdated in just a few years. Consider instead the abilities to think, to express yourself clearly and precisely, to solve problems, and to know when you haven't solved a problem. These abilities have lasting values. Studying theory trains you in these areas.

物理學

書名:The Feynman Lectures on Physics
作者:Richard P. Feynman (1918 - 1988)
為何想看:被籲為講解相對論比愛因斯坦還要好的物理學家。此書是作者把60年代在加州理工學院的講課內容輯錄成書的傑作,花名紅皮書的『費曼物理學講義』在出版40年後仍被世界各地研究物理的人不停參巧及引用。1948年費曼提出『路徑積分』(Path Integral) 方法以解決量子電動力學的問題。1965年諾貝爾物理學獎得主之一。

書名:The Principles of Quantum Mechanics
作者:Paul Dirac (1902 - 1984)
為何想看:偉大的狄拉克(Paul Dirac),量子力學的開山祖師之一,曾是劍橋大學『盧卡遜數學教授』(此職位現為霍金(Stephen Hawking)擔任),其科學上的哲學為:"Physical laws should have mathematical beauty and simplicity." 此書於1930年出版,引入後來被廣泛應用的 Delta 函數及bra-ket 符號。狄拉克預言正電子(positron)的存在,後於1932年被証實。1933年諾貝爾物理學獎得主之一。Amazon 網站上其中一位給此書 5 星的書評:
"Dirac's masterpiece surely needs no reviews, but I dare to write one for younger people. This is it! The first chapter alone would be worth of the price. Wonderful insights, not to be found anywhere else, in almost every page. Supremely elegant, yet natural and self-contained. The whole way of writing physics was transformed by this gem of a book. Learn, at Chapter V, what led Feynman to his version of Quantum Mechanics. Schwinger started here too (at fourteen!). Unparalleled."

數學

書名:A Course of Pure Mathematics
作者:G. H. Hardy (1877 - 1947)
為何想看:1908年,劍橋大學數學家Hardy 為改革英國的數學教學方法而寫成的書,被籲為數學分析(Mathematical Analysis) 及微積分的入門經典巨著。雖說入門,但Hardy當年寫此書時是有意為尖子而設,故書中附有大量非常困難的題目。作者序中有以下一段:
"This book has been designed primarily for the use of first year students at the Universities whose abilities reach or approach something like what is usually described as 'scholarship standard'. I hope that it may be useful to other classes of readers, but it is this class whose wants I have considered first. It is in any case a book for mathematicians: I have nowhere made any attempt to meet the needs of students of engineering or indeed any class of students whose interests are not primarily mathematical."
2008年,此書出版了百周年記念版,是為第10版。

書名:Theory of Games and Economic Behavior
作者:John von Neumann (1903 - 1957), Oscar Morgenstern (1902 - 1977)
為何想看:數學家 Neumann 和經濟學家 Morgenstern 於1944年的巨著,首次將博弈論(Game Theory)數學化,被視為博弈論作為一門有系統科學的鼻祖。書中詳述多種博弈背後的理論,包括2-person、3-person、zero-sum、non-zero-sum 等等。Amazon 上的 5 星書評:
"You basically have to be a mathematician to get full value from this book. This book is absolutely full of equations and complex proofs. For a beginner with little math, I'd recommend Game Theory by Morton Davis, or for someone with some university math I'd recommend Games and Decisions by Luce and Raiffa. However, if your math is good, you might as well go straight to this book, which started the whole field of game theory."
此書的60周年記念版於2004年出版。

20081104

通渠佬與 IT 人

以下文章轉載自討論區,雖然言論未免過激,但又真係幾好笑喎!

**********************************************************
通渠與 IT

今日在做 IT 資訊科技,幾乎成為了一種負擔,因為姨媽姑姐三姑六婆叔伯世姪人人都要上網,於是識 IT 的你,就變成一種原罪,要時時刻刻分分秒秒償還的罪。以前常聽 IT 界的朋友說:「再過幾年,人人都上網,在新的時代,做呢行一定好景啦!」--結果剛好相反,近年從事 IT 界的專才,幾乎人人都急著跳船跳槽,甚至平日要扮 IT 盲,以免受到親朋戚友無止境的壓迫與詛咒。

IT 界之內包萬有,有人寫程式,有人畫圖像,有人做設計,有人搞網絡--當然,最基本的 Wintel 系統,多少都會懂得使用,可是表面易用的背後,卻有很多麻煩鎖碎的事情,需要熟習與思考,遇著既懶、鈍又或者先天缺乏機械觸角的朋友,就立即膠到冇朋友。

秀才遇著兵,有理說不清,一般人既不肯學原理,又不肯花功夫自己試,卻要求多而手法不乾淨,必須的保養、維護的工作都不做,結果電腦長期七勞八傷,就正如不停把 M 巾與各種垃圾塞入馬桶,終有一天一定令馬桶閉塞,於是大嘆一聲:「好嬲呀!部電腦又唔聽話呀!」

當然了,咁用機就自然會唔聽話了,可是問題就來了,壞了電腦要怎樣處理呢?這時三姑六婆姨媽姑姐叔伯世姪兄弟等鄉親父老,就會諗起阿三姑媽的四叔婆的五外孫的朋友的朋友,其實係讀 IT 的(對,讀 IT 同修理電腦有咩關係呢?),所以要他幫手修理。

讀 IT 和修理電腦的關係,就正如治理江河的水利專家,與通渠佬的關係--廁所水同黃河,大家的水都係黃啡色的,因此電腦壞了,就要找大學讀 IT 的人去修理了,這就是一般人的邏輯。

可是做「通渠佬」,畢竟比「IT 人」好,通渠通常很暢快,雖然臭一點,但最起碼立竿見影,通就通,唔通就唔通,一兩個鐘就可以走人;另一方面,朋友們總不好意思叫你免費通渠,也不會在通渠失敗之時,叫你拆了馬桶回家再慢慢通--眼不見為乾淨,你在家修理三十個鐘,對方隨時連一句有誠意的「多謝哂」都沒有,反過來再遇到問題,立即又詛咒你:「乜果個大學讀電腦的友仔咁渣o架,呢頭修理完果頭又壞!」即使通渠不久後又爆屎渠,大家都會怪罪於亂拋垃圾的人,至多都是怪罪於馬桶,而不會怪罪於那個不幸的通渠佬。

於是乎醒水的,為求自保的,有其他出路的,都盡量詐傻走人;餘下忠直的一群,就變相承擔了更多的義務,承受更多的「任務」,天天從「大禹治水」的理論之中,演化出實地表演疏通坑渠水的絕技!當中有比較純真而忠直的男士,被封為「毒男」--因為純情的他們,常被身邊的女同學、女同事、女性友人等等,當作免費的苦力,美其名為「觀音兵」,實為「無償通渠佬」,除了心理另類或變態者之外,很少人能夠從中得到幾多樂趣。

其實通渠佬真的好做過 IT,至少馬桶的故障率較低,朋友也不好意思把你四圍「推介」或者「出賣」,叫你去長期做無償的免費勞工;而解決方法只得一個,應該把「電腦醫生」或「電腦維修員」或「電腦坑渠佬」的工作,改為有如醫生、律師等專業的「時薪制」,要應付那些千奇百怪麻煩的繁瑣事務與查詢的時候,合理地按時收費,而不是今日的「老奉制度」,於是識的要扮唔識,要由一些唔識的去扮識,結果兩敗俱傷。

當然,以上的一廂情願的建議,係永遠冇可能發生的--點解?因為市場被人性的「極品硬膠」扭曲了,當明明沒有 supply,demand 高居不下之時,可是絕大多數人仍然覺得呢件貨唔值錢,死都要覺得用一蚊可以買到一個飯盒,於是大家就只去供應假飯盒,而最過癮的,係買主膠到連貨都唔識分,明明食緊紙,卻以為食緊飯,食極都唔飽的結果,都只係識買多幾盒來食,然後大鬧:「點解食極都唔飽的?」

點解?因為這叫瘋子市場--任何常理都不適用的地方,而無論任何「干預」,亦一樣都無法挽救的「真心膠」。
****************************************************************

我的見解:

『一個讀 IT 的人點解又一定要識整電腦呢?』

邏輯上,這個問題相當於:一個學駕駛的人,學成了,車牌也考過了,是合格的司機。一天,他的車子壞了,但他不懂如何修理。於是,他發個輪,叫了拖車拖回去,慢慢修理,然後他付錢。

對於這種情況,無論是否大學修讀 IT 的,都會絕對認同其合理性。還會說:那有什麼希奇?背後的邏輯是:一個懂得駕駛的人,並不一定懂得修理汽車。但原來,這個邏輯的背後,是有一個比較高層次的、約定俗成的道理:在這個社會上,駕駛技術和修理汽車(即機械)技術是完全分開的兩種技術,它們是分工的。這是一種對常識的認知。

問題來了,在社會上,竟然普遍地認為,在大學裡讀 IT 的人,就必然懂得修理電腦 (而且修不好可能還會被人 X 呢!)

這是一種誤解,是認知上的錯誤。

只要大家登入各大學的網頁,然後翻查一下電腦學系所提供的課程,不難發現,當中根本沒有專門教人維修電腦的課程。這意味著,大學的電腦課程並非是要訓練出一位電腦維修員 ── 無論你是否認同。

可是專門教人維修電腦的課程,在坊間卻比比皆是。

當然,久病能醫,揸得車多,都會識少少汽車維修的原理。同樣, IT 人因為每天都接觸電腦,多多少少也會懂一點維修保養的技巧。可是,他或她是沒有義務在事發現場做一個 『IT 神』的。意思是 IT 人並非大家心目中的萬能老官,他 \ 她只是一個人,不是神,沒有必要在你所期望的時限之內完成解決千奇百怪問題的任務的。

IT 裡面的知識,是分得很仔細的,而且是驚人地仔細。一個程式員的 programming skill 可能非常了得,但他 \ 她對維修電腦卻未必是專家;同樣一個攪 computer graphics 的人也並不一定是攪 infrastructure、Wintel server 或 Lotus Notes clustering 的箇中高手。

當然,明係識而扮唔識,而問題又屬於其份內事的話,那此人當真抵打!

至於有 IT 人要被人要求去修理影印機或冷氣機,那更是天大笑話!

20081006

何謂明、清時代之『大學士』?

有位舊同學,不知何故,很喜歡用電郵廣發言論,討論時事。惟他不喜寫 blog,亦非 facebook 之常客。是故大小 topic,個人意見,均以大量電郵發出。其數量之多,幾近逼人將之視為垃圾電郵而後快。

其實很多朋友的電郵,也不乏提供新知識的機會。是故我也不厭其煩,續一而拜讀之。惟其錯字之多,觀點之謬誤,實在到達令人發笑之地步。而且混淆視聽,比太陽報之社論有過之而無不及。

且節錄如下:
**********************************************
主旨:The secrets of the MBAs and Ph.Ds

在西方, 眾 MBA 們常常自垮道 , 我們只是 「胃口奔馳」 的一族, 再問下去他們只好回答 "Mandatory Bread Addicts".因他們多年來多已男性為主。

若論女性的 MBA 們, 他們多以 "Married. But available!" 來形容自己的處境, 過中原因是女性在工作方面多把 “吸引力” 也計算在內,要表達自己有要好的男朋友或大好家庭之餘, 也能鞠躬盡悴。

再論 Ph.Ds, 在我國遠古時代多稱為 「大學士」, 是皇帝身邊的紅人,以食客身份自居。 現代譯作 「博士生」, 多是 「懷材不遇」, 生活閣據!
**********************************************

頭兩段是過氣笑話,有錯字而且文理不通,大可不必理會。但最後一段『論 Ph.Ds』則實在錯得離譜。什麼 Ph.D 多稱為『大學士』、『以食客身份自居』、現代譯作『博士生』、多是『懷材不遇』云云。

比胡扯更胡扯。

由於有感於他對中國歷史一竅不通,更不值其胡說八道而教壞人(電郵是廣發,受者眾多),是故馬上尋找詳盡而可信的資料,供諸同好,以正視聽。

其實當時的大學士並非等於現在的大學教授,更非現代的 Ph.D,乃係官名,且有一定實權。

唐代有宏文館學士、集賢院學士,為掌文學著作之官,嘗以宰相兼領、知館、院事,稱大學士。宋沿襲之,對學士中資望特高者,加『大』字。及明洪武十三年(西元1382年)廢丞相及中書省,十五年仿宋制設大學士,以為皇帝顧問。

成祖即位後,以侍講、侍讀學士等翰林官參預機務,入內閣,至明中葉,遂以大學士為內閣長官,替皇帝起草詔令,批條奏章,商承政務,其本身官階在尚書、侍郎下,但實權甚重。稍後,以尚書、侍郎入閣辦事,兼大學士,加官至於一品,位望益尊,乃成為事實上的宰相。

清代設立軍機處,大學士職權為軍機大臣所代替,其稱僅作為榮銜,授予軍機大臣及內外各官資望特高者,為正一品。大學士皆以殿閣名入銜,明有中極、建極、文華、武英等殿和文淵閣、東閣大學士,並正五品,無定員;清乾隆十年(西元1745年)以後,大學士專以三殿(保和、文華、武英)三閣(文淵、體仁、東閣)入銜,滿、漢各二人;協辦大學士滿、漢各一人。均為文臣最高官位,漢人一般非翰林出身不授此官。

可見『大學士』並非現今之博士生或大學教授,而是官銜。而自明朝起更被加官至一品,故什麼『懷才不遇』、『以食客身份自居』云云,簡直胡說八道。

其他參考:http://zh.wikipedia.org/w/index.php?title=%E5%A4%A7%E5%AD%A6%E5%A3%AB&variant=zh-hk

20080916

Mamma Mia! - 極度懷舊‧不忘反智

很久沒有看不需要太用腦的電影,此言並無貶意,反而想推介給大家,如果想開懷兩小時,看一套無論朋友情侶一家大細也受落的電影,看吧。
Official web site 裡開宗明義,說明此片是 inspired by Abba's song,當然入場前單憑電影海報已經略知一二。但我沒有做什麼 research,並不知道背景是希臘的某某島 (其名字聞所未聞)。其實愈看愈覺得那個島太 raw,而且可能影片想刻意營造一種遊客多,島民少的渡假天堂感覺,反而覺得很不希臘,卻有種聯合國的意味。雖然片中已故意擺放一大堆做家務的希臘師奶,又有一個帶帽的希臘漁夫阿伯,但反倒覺有點堆砌了。
故事出奇地簡單:三個大男人千里迢迢去到希臘某小島,參加一個少女的婚禮,少女的媽媽卻是三男的舊情人。於是便起了『誰是生父』的疑雲。
全片劇情簡單,大多描寫 Meryl Streep 和她兩個死黨的搞笑場面,歌舞連場再加上處境喜劇的炮製手法,令一眾 Abba 迷聽出耳油之餘,個別場面也賞心悅目。我不是 70 年代的英文歌迷,卻因為家中也有隻 Super Trooper CD 而對片中的金曲耳熟能詳。
金曲以外,那些歌舞場面實在令人很易想起周星馳的少林足球,又或者很久已前的 "Jesus Christ Super Star"。
到中段赫然醒悟,為何片中的背景要是一個山卡拉小島,否則,『生父疑雲』便不能順理成章了。
在城市,大不了去驗 DNA 吧,煩什麼?