Monday, September 29, 2008

HP-12C & New Numbers


Have you ever found any high tech gadgets last more than 25 years (1/4 of a century) on the market & still produced and supported by manufacturers.  It is indeed very hard to find one with average product cycle around 3 years in Silicon Valley. Believe it or not, I did find one that meet the honor. It is HP-12C Calculator.  I purchased one in 1983 which I still use these days.  I was in Walgreen last week, a drug store around the corner, looking for BeneFiber.  I passed by one aisle and see the familiar HP-12C calculator, priced at $69.  Although there is a platinum model that cost more, the original one is still there. This is a finance calculator for interest, mortgage, amortization, etc.  I heard that some big financial company bought this calculator for each employee & used for company's work.  This may be the reason why it is still around these days. But why they pick HP-12C?  I think the reasons is the pocket size, easy to use & its long-lasting batteries. As far as I can remember, I only changed batteries once in 25 years. HP-12C is truly a classic product in itself, amazing.

Related to calculator, it is the number---unit of number, the way we do the counting.   In most calculators, the number is displayed three digits in a group with comma.  In other words, it is easy to read it in thousand, million, billion etc. But this creates problems for 万& 億.  I am sure most of us have the same experience.  When someone said 700 billion dollars to bail out the financial mess.  What, 700 B, oh, it is 七千億.  It takes about 4 or 6 seconds to get the conversion.  How about 八拾七萬?  Oh, it is 870 thousand. This time it takes about 4 sec to get the conversion.  How about 四万万七千万? Oh, it is the same as 四億七千万, and it is 470 million.  It takes more than 10 sec to do the conversion. I found it rather amusing whenever Chinese people in America try to quote the big number & everybody sort of sucks into some confusion.  The inconsistency comes from the way Chinese count---4 zeros a group instead of 3 zeros a group. 百, 千, 万(4 zeros) then 億(8 zeros), 兆(12 zeros).  But the western way is thousand (3 zeros), million (6 zeros), billion (9 zeros) then trillion (12 zeros). I think it will be a good idea that Chinese create two new units of number: #米 and #比.  They are equivalent to million & billion. We might as well get used to these two numbers and save us a lot of trouble.  So 470 million is just 470 #米 & 700 billion is just 700 #比.  And 140 thousand can just be 140千, simple as it is.  So from now on, we all live in peace & happily ever after.

PS1: You may be upset that why we have to confirm to the western way of counting.  Well, it started long time ago when our ancesters wanted 西学為用.   This does not mean that we abandon the counting of 万& 億, we simply add two more units of number to facilitate easy counting & communication. Take a look at Periodic Table, Uranium (鈾), Plutonium (鈽), Americium (鋂), Curium (鋸), Einsteinium (鑀), Fermiun (鐨), Mendelevium (鍆), Lawrencium (鐒), Berkelium (鉑), Californium (鉲) etc.  So we already named a lot of items per western words and pronunciation. By the way, the United States fares very well in the periodic table: Americium, Californium, Berkelium. Berkeley & California are the only university & state to be named in the periodic table. Also Lawrence (Lawrencium, atomic #103) & Seaborg (Seaborgium, atomic #106) are the scientists from Berkeley.

PS2: It is funny to see Trillion & 兆 all end up with 12 zeros.  The reason is simple: 12 is divisible by both 3 & 4.  No wonder ancient Babylonian used 12 進位 instead of 10. 12 has factor 2,3,4 & 6. But 10 has only 2 & 5 factors. At least for division, 12 based # is twice efficient as 10 based #.

Thursday, September 25, 2008

求學孫子

前言

我在台灣讀書的時候,就知道有 [孫子兵法] 這本書,但從來沒有在書局中看到過。軍訓教官也只提到書名,不提內容。好像是武林密集,不輕易傳人。現在想起來,可能與 [孫子兵法] 開宗明義的一句話有關。 孫子曰,兵者,詭道也。與當時宣傳的國軍乃仁義之師,相去太遠。最近回台灣,看到一本叫 [商戰孫子] 的書,其目的是教導如何用 [孫子兵法] 經商。雖然有一些見解,但牽強附會太多,連 [行軍],[地形],[九地],[火攻] 諸篇,都配上商業用途,有風馬牛不相及之感。但我第一次看到了 [孫子兵法] 全文。愛不忍釋。想不到我們的祖先能寫這麼好的文章。這樣的 realistic。開門見山,水清見底。兵者,詭道也。打仗使用陰謀詭計不丟人,連逃跑也不丟人,只有打敗仗才是丟人。 [孫子兵法] 不但內容精闢,而且文筆之流暢,用來作為高中的國文教材,比 [古文觀止] 上絕大多數的文章讀起來要舒暢得太多了。請看 [兵勢] 篇中的一段,
凡戰者,以正合,以奇勝。故善出奇者,無窮如天地,不竭如江河。終而復始,日月是也,死而復生,四時是也。聲不過五,五聲之變,不可勝聽也。色不過五,五色之變,不可勝觀也。味不過五,五味之變,不可勝嘗也。戰勝,不過奇正,奇正之變,不可勝窮也。奇正相生,如循環之無端,熟能窮之哉?
顯然孫子認為文學修養對一個將軍非常重要。不然他不會把這些與作戰無關的東西寫在兵法裡。
現在有人認為 [孫子兵法] 的原則到處可用。除了戰場,商場之外,情場,官場,選舉都用得上。我一輩子讀書,看看求學能不能也套上 [孫子兵法]。

始計第一

求學者,人生之大事,終生心血,舉家甘苦,不可不察也。
故經之以五事,校之以計,而索其情。一曰道,二曰時,三曰地,四曰師,五曰己。
道者,最終之目標也,題目當與天地同壽,日月同庚,朝聞之,夕可死也。披星載月,不畏難也。時者,天時也,知所先後,則近道矣。時未至而先攻者,徒勞而無所獲。地者,學校,設備,環境也。查無書,且問無友,事倍而功半。師者,智,信,名,錢,點也。己者,能力,興趣,背景也。
凡此五事,學者當聞,知之者成,不知之者敗。故曰,校之以計,而其索情。曰 道孰能申,師孰能啟,己孰能耐,錢孰能久。吾人以此知勝負矣。
學者,慎道也。知之為知之,不知為不知。近而慮之遠,遠而慮之近。不求小利,不貪近功。得之不驕,敗之不餒,思人之未見,攻人之不察。故學者之勝,不可先傳也。
夫未起步而廟算勝者,得算多也。未起步而廟算不勝者,得算少也。多算勝,少算不勝,而況無算呼?吾人以此觀之,成敗見矣。

後語

孫子有一個有名的故事,所謂 [孫武子演陣斬美姬],也是成語 [三令五申] 的來歷。最近在網上有一部關於孫子的歷史小說,中間有一段,作者希望還原這段悲慘的事件。為什麼孫武會帶宮女練兵,殺死了吳王的愛妃之後,為什麼吳王沒有為愛妃報仇?想像得合情合理,也許您有興趣一看。
http://vip.book.sina.com.cn/book/catalog.php?book=48636

楊照崑

Tuesday, September 9, 2008

Mid-Autumn Festival

Mid-Autumn Festival falls on 9/14 this year. Traditionally this is a big holiday most Chinese people rush to their family for reunion. No other holiday except Spring Festival is more important than 中秋節. There are a lot of poems related to the moon & the mid-autumn festival. But there are not many nice songs composed for the occasion. Some like 中秋怨 does not have universal appeal. Rather, it is for persons with broken family. Perhaps most people choose to 吟詩 instead of 唱歌. The most famous poem for the occasion is 水調歌頭 by 苏軾. There are some songs composed for this poem. One of them is "但願人長久". In western world, since there is no such festival, you don’t find any music composed for this occasion. However, there is some music either dedicated to the moon or related to the moon. Doris Day sang “By the Light of the Silvery Moon”. It is a very lovely song except that she sang for the Thanksgiving holiday, a very late autumn event. For something classical, the most famous one is Beethoven’s Moonlight Sonata, the other is DeBussy’s Clair de Lune (月光曲). I happen to remember the 2nd movement of Eine Kline Nacht Musik (by Mozart) has been adapted as moon related song (Meditation under the Moon) used in some elementary school. As to the aria of opera, there is one dedicated to the moon & well known. It is "Lied An Den Mond (Song to the Moon)" in Rusalka by Dvorak. Rusalka is a water spirit who sings this aria to plea to the moon for help in finding her prince. In 2001, Masterpiece Theatre released a movie “The Song of the Lark” featuring this song as the main theme. I think it is proper and fitting to sing this song under the moon on mid-autumn festival if you are a woman in love. For a man in love, he should play Moonlight Sonata, the 1st movement, very romantic. For the rest, just try Clair de Lune (play by piano) or the 2nd movement of Mozart’s Eine Kline Nacht Musik (小夜曲).

但願人長久
鄧麗君

By the Light of the Silvery Moon

Lied An Den Mond

2nd movement of Mozart’s Eine Kline Nacht Musik

Moonlight Sonata, the 1st movement

Clair de Lune

PS: Moonlight Sonata was not named by Beethoven. It was added in 1832 by a music critic, Ludwig Rellstab, who said the 1st movement reminded him of moonlight over Lake Lucerne in Switzerland. I am sure some of you have visited Switzerland & seen this lake. It is one of the most beautiful lakes in Europe. If you have a chance to cruise the lake, you will see a nice building along the shore. It happens to be a museum of Richard Wagner, Tribschen. I visited the place in 1984. It is worth visiting if you are fit & can walk a mile to see it.

Sunday, August 31, 2008

The Last Rose of Summer


The autumn starts on 9/22 this year. This is the definition from astronomy. Traditionally & meteorologically it starts roughly around September 1 or Labor Day in Canada & US. So 8/31 is the last day of summer. This reminds me a lovely song “The Last Rose of Summer”. Although the last rose of summer does not necessary falls on the last day of summer, it conveys the same message that the

summer will soon be over & the last rose will wither & fade away---sad emotion. The song is from an old Irish air “The Groves of Blarney”. John Stevenson adapted this tune on “The Last Rose of Summer”, a poem by Thomas Moore. Since then this song becomes very popular. In fact, Flotow used this song in his opera Martha & appears several times in different acts. Martha is a comic opera, a love story of two boring ladies & two farmers who hire them as servants. When farmer, Lionel fell in love with the leading lady Harriet, she gave the rose she wore to him & sang the Last Rose of Summer. After that, the two ladies fled & returned to the court. Lionel was so distressed, he sang a famous aria “Ach! So fromm” (恍如夢中). The opera is not very long & generally considered to be a light opera. The ending is a happy one --- they marry & live happily ever after (有情人终成眷屬). Just before the curtain falls, they sing once again “The Last Rose of Summer”.

Though there are many arias in Martha, only the above two are really famous. The opera is very unique in some way, as Germans consider it a German opera, French consider it a French opera, Italians consider it an Italian opera. Of course English think it is an English opera with setting in Scotland with Irish Last Rose of Summer. Flotow is a German receiving music training in France. He composed Martha in German, but the original script is in French. The opera was translated into Italian with high quality that most Italians think it is from Donnizetti. Especially, the aria “Ach! So fromm” is translated into Italian “M’appari tutt’amor”. It is this title aria made Martha well known in the opera world. I think European Union (EU) needs a lot of people like Flotow to unite the Europe. Something similar happens to Dvorak’s symphony #9, “From the New World”, 2nd movement. American people think it is very American. But most people from Czech & Slovakia have no doubt about it. It sounds so Bohemian that they become home sick immediately. I haven’t found anything like this among China, Korea & Japan. The one close to it are the songs we all familiar with, 送別 & 憶兒時. 送別 becomes “旅愁”in Japan. 憶兒時 becomes 故鄉の老家. Japanese think they are Japanese songs. Most Chinese have no doubt that they are Chinese songs. But the truth is that both of them are American folk songs. 送別 was composed by John P. Ordway (1824-1880) with title “Dreaming of Home & Mother. 憶兒時 was composed by W.S. Hays (1837-1907) with title "My Dear Old Sunny Home”. The peculiar thing is that not many American people know Ordway & Hays, let alone these two songs.

The following are some YouTube links that you can listen to the songs I mentioned above:
The Last Rose of Summer
Ach! So Fromm, sing in German by Wunderlich
M’appari tutt’amor, sing in Italian by Pavarotti and Lanza
Dreaming of Home & Mother
My Dear Old Sunny Home
The above link switches authors of music (tune) & lyrics.

Move the screen to 1871 and click My Dear Old Sunny Home

Dvorak's Going Home
Some photos from Hubble Space are spectacular. You almost think our home is in the deep space of our cosmos. But at the last moment, the distintive blue marble shows up from the corner & it is our Earth, an almost ocean sphere. The Earth is truly our home.

Thursday, August 28, 2008

Slide Rules




I just cleaned the garage & found a good old slide rule I used to use in our Taida’s day. It is a Hemmi 153 for EE. After so many years, I can barely remember the scales & functions. Most of you use Hemmi 255, also for EE.

For some reason, I seldom used it in my graduate classes in the US, although I was still an EE major. The discipline of EE consists of many fields such as communication, power, control system, computer & logic, circuit & network, electronics, solid state physics, etc. Most of these fields stress on theory & application. The numerical calculation is minimal. In other words, due to lack of case study or field application, the calculation is fairly limited & so the use of slide rule is rare. Compare to law & MBA programs, our EE seems less exciting & lack of colorful or hot discussion. I spent half day to review my good old slide rule & would like to share some of my finding. Of course, most of us knew these long time ago. Here are the scales I found in Hemmi 153:

L: Logarithm
K: Cube
A: Square
A,B: Multiply, Divide
C,D,CI: Multiply, Divide, Proportion
T: Tangent
GTheta: Gudermanian Angle for Sinh on T scale & Tanh on P scale
Theta: Angle of Trigonometry, 360 degrees in a circle
RTheta: Radian Angle of Theta, 2 pi in a circle
P,Q,Q’: Sin, Cos & Hypotenuse of Right Triangle
LL3, LL2, LL1: log log scale for exponential functions

The operation of the slide rule is by sliding center bar and finding the answer using various scales. So the operation is basically Addition & Subtraction in nature. However, if the scale is calibrated in a logarithmic fashion, then the multiplication becomes addition & division becomes subtraction. That is exactly what scale A,B,C,D & CI do. In fact, the scale L is calibrated from 0 to 10 in equal spacing. As to the calculation of exponential functions, it takes one more log to convert exponent to multiply. In LL3, LL2 & LL1, the scale is calibrated in log log fashion, so the calculations of exponent is converted to addition, a slide rule operation. GTheta is Gudermanian Angle for finding Sinh on T scale & Tanh on P scale. It is not obvious why hyperbolic functions have anything to do with Tangent & Square functions. I think the key is how GTheta is defined. Most electrical engineers are not really interested in the definition of GTheta. All we care is getting Sinh from T scale & Tanh from P scale. As a matter of fact, the graph of Sinh looks like Tan & Tanh looks like Sin in the range of principal values.

Nowadays we don’t see slide rules except the places like museums. This is one example that technology changes the way we calculate, and so the way we live. You might ask why. In 1972, HP introduced HP-35 Electronic Calculator. It has 35 buttons (so called HP-35) with four functions, trigonometric, logarithmic functions, square root & exponential functions. The accuracy of the calculation is 10 significant digits. Since it can perform all the functions of the slide rules & do them more accurately (10 significant vs 3 or 4 digits in slide rules) and efficiently (much faster), it sent the slide rules into oblivion. From then on, slide rules faded away like old soldiers & books of math tables disappeared in no time. In 1972, I worked for Mostek, a spin out of Texas Instrument. Mostek supplied three ROMs for HP-35. I had the chance to see the complete binary code of the algorithms & its architecture. The processor operates fetch, store, branch, add & shift with four registers. Each register has 56 bits, organized as 14x4, ie 14 digits in BCD. The internal register calculations are 14 digits and the accuracy is 10 digits. It is a very primitive but compact processor dedicated just for scientific calculations. The four functions are calculated with add & shift. Logarithm is calculated using Sequential Table Lookup (log 2, log 1.1, log 1.01 & log 1.001). For example, log 30 is converted to a series of numbers as follows:

Log 10*3 = log 10* 2*1.5 = log 10*2*1.1*1.36
= log 10*2*1.1*1.1*1.1*1.01*1.01
= Log 10 +log 2 + 3*log1.1 + 2*log 1.01.

Since log10=1, log 2, log 1.1, log 1.01 are the constants store in ROM, you just look them up & add to get the correct answer. The method seems cumbersome. But the processor is fast enough to get the most results within 3 seconds.

Trigonometric functions are calculated by Rotation Method (CORDIC) with Sequential Table Lookup (arctan 1, arctan 0.1, arctan 0.01, arctan 0.001 and arctan 0.0001). The angles correspond to 45°, 5.71°, 0.57°, 0.06° and 0.01°. For example, Tan 52° is converted to Tan (45+5.71+ 0.57 + 0.57 + 0.06 + 0.06 + 0.01 + 0.01 + 0.01). For each rotation, use the formula we learned from Analytic Geometry:

X’ = xcosA - ysinA
Y’ = xsinA + ycosA

The values of sin & cos of the angles 45° to 0.01° are stored in ROM.
The final result Tan 52° = X’/Y’. Sin52° = Y’/SQRT(X’²+Y’²) & Cos52° = X’/SQRT(X’²+Y’²).

Exponential function exp(x) can be obtained similar to logarithmic function. Convert x to m0*c0 + m1*c1 + m2*c2 + m3* c3 + m4*c4. The constants in ROM c0, c1, c2, c3, & c4 are the values of ln10, ln 2, ln 1.1, ln 1.01, ln 1.001, ln 1.0001. So exp(x)= exp(m0*c0 + m1*c1 + m2*c2 + m3* c3 + m4*c4) = 10^m0 * 2^m1 * 1.1^m2 * 1.01^m3 * 1.001^m4, can be calculated by add & shift operations.

Some of us might have chance to take a course called Numerical Analysis in graduate school. It is considered part of the computer science curriculum. Alas, it didn’t mention anything that I found in HP-35. One thing I did know at that time why HP didn’t use Infinite Series, it is the speed of the convergence. It is hard to find infinite series converges fast enough for the slow processor in 1972.

Sunday, August 17, 2008

作文與命運

Sometime ago in our classmate email communication, we talked about the composition in our joint entrance examination & how important it was to our future. Here is another example. I read a book “小脚與西服” several years ago. It was written by Natasha Chang who is the grandniece of 張幼儀, the first wife of 徐志摩. This is a very interesting book which describes the whole thing from the interviews she conducted with 張幼儀. Several years ago, Taiwan produced a TV Show--人間四月天--, a very good show that traces the love affair of 徐志摩. In小脚與西服, it mentioned 張嘉璈, the brother of 張幼儀, went to 杭州第一中学 to see the condition of the school. While he examined the work of the students, he was so impressed by 徐志摩's composition, he made a decision to arrange the marriage between 徐志摩 & his sister 張幼儀. After this, we all know the rest of the story: unhappy marriage, divorce, can’t marry 林徽因 as she refrained, found another lover 陸小曼, financial difficulty, … , airplane accident to end his life. This is the hindsight: If it were 林長民 (father of 林徽因) instead of 張嘉璈who read the composition, the future & fate of 徐志摩 would have been completely different. It would have been a perfect marriage 徐志摩+林徽因 & the Chinese literature might have been added one brilliant chapter. Anyway, this is just another example of the importance of composition to one’s future.

PS1: 林長民 was well known, literally & politically and became a very good friend of 徐志摩. While 林長民 stayed in London, his daughter 林徽因 lived with him & attended college in London. 徐志摩 went to Cambridge & had chances to meet her. And so the love affair flourished. 張幼儀 moved to Cambridge but couldn’t salvage the marriage as 徐志摩 divorced her in no time. She later moved to Germany & eventually returned to China.

Ps2: The title of TV series “人間四月天“ is from a poem by 林徽因: “你是人間四月天”. She majored in architecture and well verse in literature. Her father-in-law is 梁啓超. Her father is 林長民, the cousin of 林覺民, one of 黄花崗七+二烈士.

Wednesday, August 13, 2008

Gleaners

I bought an old book recently in a book sale of local library. It is Balanchine’s Complete Stories of the Great Ballets (Doubleday & Company, Inc. 1954). I read Giselle & Swan Lake. Somehow it reminded me that I read the same text somewhere before. I happened to have a copy of “笆蕾舞與樂曲的故事", published in 1958 by 拾穗雜誌. It dawns on me that the latter is the translation from the Balanchine’s book. Anyway I am sure most of us knew 拾穗雜誌 when we were in high school & college. It was a pretty high quality monthly magazine. Beside this book, 拾穗雜誌 also published “西洋歌剧的故事”and “交响樂的故事”around 1956. After 1957, 吳心柳 founded “音樂雜誌 and published it for several years. These two monthly magazines were fairly influential in the last five years of 1950’s. 吳心柳, also known as 張继高, wrote some other books like 樂府春秋 and 從精緻到完美 etc. I learned a lot from these two magazines when I was in school. Time goes fast, they are all gone & passed away. It is quite nostalgic when I reread some of these books. After 1960, 文星雜誌 & 皇冠雜誌 entered the center stage. That was the time of 李敖 & 瓊瑤. Somehow 李敖 didn’t like 瓊瑤 & attacked her novel ”窗外”. Anyway, that is another story. Go back to 拾穗雜誌, its cover is the famous painting by Jean Francois Millet, a French impressionist. Millet was a painter fond of the peasant scene. His paintings show the relations between nature & human being. They give you a feeling of hardworking peasants toiling their labors & still find harmony with the nature. Usually the background is the golden sunset or blue sky with patchy clouds couple with a remote chapel with its steeple. It has a profound effect to the viewers. I heard that his several paintings are now on display in Taipei, including his two most famous paintings: The Gleaners (拾穗) & The Angelus (晚祷). I saw these two original paintings at Musee d’Orsay in Paris in 1986. The museum was used to be a railway station. It was just converted to a museum at that time. Several years later, I purchased the reproduction copies in Palo Alto downtown at $16 apiece. I hang them in my family room since then. The Gleaner has three women in the foreground, one looks like mother in the center, the one on the left looks like her daughter and the woman on the right looks a little bit older and can’t bent comfortably. The background is a field with harvest activities and golden sky. The golden field extends remotely to the sky and forms a uniform color---穗野共長天一色.. You watch this painting & realize there are still some poor people live on the grains left by the harvest. Perhaps they have some children to feed at home & so they have to work hard to get by. You feel very sorry for them and hope their children will eventually get good education & get out of the situation. I remember during 1970’s, there was an engineering weekly magazine in Silicon Valley ran a contest matching famous painting with engineering activities. The Gleaner won the contest with title: “Boy, if those guys in Texas Instruments find out this is the way we grow semiconductor chips, ……”
The Angelus is even more famous than the Gleaners. This painting shows a peasant couple takes time off in the field to say prayers before going home. It is after sunset, it is getting dark but the sky is still glowing with golden color. The most prominent & moving scene is the remote church steeple. It gives you the ambient of bell ringing & you seem to hear it. At this moment, you really feel & understand---勞動神聖. Long time ago (1936), 開明書店 published a book by夏丏尊, title 平屋雜文. In this book, there is one article “米萊的晚鐘”. 夏丏尊 said “信仰, 勞動, 恋愛, 這三者融和一致的生活才是我們的理想生活. He then extended the argument that the women need to labor physically or mentally in order to gain economic-independent status in the society. I wouldn’t go that far but I like his imagination. This painting gives me a feeling of peace, harmony & assurance of the future. It is interesting 夏丏尊 used 晚鐘 instead of 晚祷. That means he focused more on the church steeple than the prayer.

Ps: 夏丏尊 also translated the well-known book 愛的教育 (by Edmondo Amicis). There are several versions of translation published after him. However, I think his version is the best. 夏丏尊 was a teacher & educator & I always found passions in his work & writing.