Friday, March 28, 2008

Pinocchio revisted

Yesterday I visited my sister and my 3-year-old niece and played with her for a bit. Kids today have fun toys. The best toys are those that are safe: nobody needs lead paint, and those that teaches a lesson or two.
Books are of course standard part of a healthy kids growth. I picked up a simplified well known story book: Pinnochio.

I have some vague memory of the story...there was a carpenter and a fairy, and if the doll lies, the nose will grow long. So I revisited the story last night. I remember my parents took me to a musicial of some sort when I was 4 or 5 on the same story. All I remember was there was a scene inside a fish. Ok, I was just 4 or 5 years old. Thanks mom and dad!

The storybook is made in Taiwan, targeted for kids to learn Chinese AND English. It is easy to tell because it is in traditional Chinese: only HongKong and Taiwan use traditional Chinese. It has the rather strange looking pronounciation keys that only Taiwan people use, so it is from Taiwan. My complain is that the words are too hard in either language in the story book for young kids.

So I revisited this fairy story, probably a simplified version: so there was a lonely carepentar who made a doll as companion whom he named as Pinocchio. A fairy turned it to a kid! Then the kid go to school but he wasn't behaving, met some bad friends that eventually led to the bad magician who turned him to a donkey! He was sold to a circus and had some horrible times. Then the fairy appeared again and rescued him, when Pinnocchio go look for the carpentar he was out looking for him all over, even on a raft. Pinnochio now go look for the carpentar, and wind up eaten by the whale! Of course the fairy rescue them again. He then became a real boy and turned good.

Ok, this is not just a children's story. Some profound questions and observations can be found in the story.

1. Why did the old carpentar create Pinocchio in the first place?
1. Why doesn't Pinocchio behave at first?
2. Bad friends: look what they can get you to.
3. True love: your parents can go way beyond comfort zone to look for you.
4. Fairy: is there really such things to help us in time of trouble?

Does that remind you of Sunday school talks such as sin, repent, salvation?
Pinocchio is a profound story.

Here is a long circulated joke:

Jesus is walking through heaven one day, a little bored, when he passes the Pearly Gates and sees St. Peter talking with an elderly gentleman and decides to go over and hear the man's tale.
"Where are you from, old man?" Jesus asks.
"Well, I lived my life on the shores of the Mediterranean," the old man replies.
"Hmmm. I spent some time there myself," says Jesus. "What did you do for a living?"
"Well, I was a poor carpenter," says the old man.
"Wow. So was I," says Jesus.
"And I had a son," says the old man. "Well, he wasn't my son really, but a miraculous spirit came into him and he became a very famous person."
Jesus can't hold back any longer. "Father!" he cries.
The old man falls into Jesus' outstretched arms. "Pinocchio?!"

Teleprompter embarassment

Yesterday I watched CNN reported embarassing instances of political candidates lost track of speech as they read from a teleprompter. The candidate totally lost track of what is to be talked about. I am not sure if the text are scrolling too fast or the fonts are too small, but he just appeared to be TOTALLY lost. What an embarassing moment. Some described him making speeches as if he is watching a tennis match.

Whatever his speech was it is not so important, it reveals the fact that some politicians are totally unprepared, totally non-functional without the text scrolling machine. All they can do is simply read off the teleprompter. Hey, ANYBODY can do that.

Look, it is leadership that we are looking for here. Even if all machines stop working a real leader is able to speak, able to lead.
How do I trust the fate of the entire nation on someone who can't even handle such simple situation?

A well-prepared speaker does not merely read text. Notes and teleprompters should serve as reminders. Have a outline, on the safetest tool--a piece of paper, in front of you listing points of what you are going to talk about. That's what the podium is for. Before you speak, PRACTICE! You don't have to speak outloud. See you if can make the speech just by looking at the notes. You don't have to write every line out. A successful speaker can phrase what he (or she) wants to say just by looking at the outline.

I want to vote for a real leader, not a text-to-speech machine.

Note: Windows XP users can just to go Start->Control Panel->Speech and type a line for Microsoft Sam to speak for you.

Thursday, March 27, 2008

A closer look at Web Services

People loves abstraction. Kids start to learn numbers by first counting actual items like apples, toy blocks, then they learn abstraction with numbers.
When they get to high school they learn the x and y in Algebra 1... In college, some students may find themselves in the world of abstract algebra and operations.
In programming for the web, abstraction also takes place. we want to abstract the simple approach of HTTP and HTML with geneal data!

Enter XML: define you own tags. Everyone is excited about describing your data with your data.
If you let them do it they design wild XML files. Perhaps you have seen some very complex XML schemas and data files.
XML has grown into programming language like tools: XSL, to do all sorts of manipulation, and ANT, the ubiquitous build tool that modernizes batch file with XML. There are XML config files in every modern tool such as programming frameworks you encounter.

The idea of to tossing data, and not just HTML around the web is nothing new: DCOM, CORBA, EJB and all that. Things start to become outrageously complex. How come it cannot be simplified? Waita minute: why not simply use HTTP to pass XML around? Simple idea, but difficult to describe and implement.

So here is the buzzword: Web Services.
We need to specify the data being tossed around, and how is being toss around (enter SOAP). We need to describe the service that process the data (enter WSDL), and have some way to look up such service (enter UDDI)
These are all in XML, and they are complex. Don't let the word simple in SOAP mislead you.

These XML are so complex that it is almost impossible to write by hand. Fortunately, there are so many vendors and ever evolving tools to generate things for you.

Apache always provide useful and free open source tools for developers. Every server-side java developer should have Apache Tomcat to host servelets and jsps.
Enter Axis2: Apache's Web service engine. I was able to install and run some samples from the well writen guides. (Thanks Apache!)
Like J2EE calling EJB, calling a Webservice is not so intuitive. It ought to be more simplified.

My minor complain to Apache: the tools change so fast: Axis1 is totally obsolete. Axis2 is an entire new approach.

The web is revolutionary because of its simplicity. Type a URL: boom you got it,your browser will figure out how to render nicely.
The neatest part of the web is that it is somewhat tolerant: HTML missing a tag? no problem, though you don't see your page perfectly you
won't get a segmentation fault, NullPointerException or a freeze up.

WebServices has made programming more difficult. One mistake and you get a StackTrace of impossible to decipher error.
Actually, you can skip all that. Why not do you own data sending and prevent all the abstraction? Keep it simple is sometimes the best solution. Dear IT department: you may not actually need a Web Service.

Monday, March 24, 2008

Chess revisited

I had a chance to play a few (Chinese) Chess games on Saturday. I haven't played for so long. It is HARD to find a fun opponent to compete against. No, not because I am so great a player, it is comparable skill level live player that is difficult to find. Live players: they are already hard to find. Go to a chess club or something? My skill level is no match for guys care enough to go to a chess club.

Of course, it is easy to find a tireless computer player. Computer games are either way too strong or too weak! You can also find live anonymous players around the world. However, chess really should be a human intellect activity to play with your friends. A game reveals your opponent's personality! Can your opponent handle stress? How is the persons problem solving ability?

The key to win is to wait for your opponent's mistake. Develop plans of attack and also watch your back. It isn't so fun to play with a computer with flawless strategies.

Player types:
1. Weak beginners: who don't think at all. No strategy, no skills. yawn.
2. Losers who persist: lose and whine and won't let me go until win. Losing the game AND losing personality is a really a poor loser.
3. Strong players who brag: ok I don't need that look on your face
4. Humble strong players. I become player type 1. Sorry for making you yawn.
5. Strong players who gives advice. Ok I made a wrong move. Wow, I got an explanation of why it is bad. Ar ha, I see I am improving in my game.
6. Fun players: ~50% chance to win. Now that's fun.

So it is HARD to find type 5 or 6.
After all, life has so many activities other than this great intellectual activity.

When I meet type 1 I try to be type 5.
Additional rules of chess (or any game). Learn from strong players. Be nice to weaker players. It is only a game. It is ok even if you lose.

Friday, March 21, 2008

Ancient military wisdom

Obama says:

How much longer are we going to ask our families and our communities to bear the cost of this war?

as he talk about the $500 billion cost of the Iraq war is dragging on the U.S. economy and attempt to blame McCain. Some see this talk as attempt to divert attention from other sensitive issues but he is so right. Just how much longer are we going to pour billions of dollars out there?

Sun Tzu's Art of War, Chapter 2, line 2-3 says the following 2000+ years ago:

When you engage in actual fighting, if victory is long in coming, then men's weapons will grow dull and their ardor will be damped. If you lay siege to a town, you will exhaust your strength. Again, if the campaign is protracted, the resources of the State will not be equal to the strain.


Sun Tzu is still relevant today!

Reckless leaders without vision and wisdom keep blindly go on endless conflicts.

Ok, AK-47s don't grow dull but wasting billions of dollars and precious lives are simply weakening this country more and more.

During Sun Tzu's times the emperors were not elected, they don't simply leave and live in luxury palaces after battling neighbor states and straining the state for a few years.
Stressed and angry citizens may organize attempts to overthrow reckless leaders using the limited remaining resources they have.

Elections remove reckless leaders peacefully, but the next leader will have a mess to handle.

Someone with wisdom should boldly come forward to end this mess with a grand plan.
I would say the War on Iraq is #1 issue. Economy is next. If that billions is spent wisely we will be in much better shape. Giving everyone $600 is pocket change that can't help much.

Every military leader should know this line (Sun Tzu chapter 2, line 19):
In war, then, let your great object be victory, not lengthy campaigns.

Tuesday, March 18, 2008

Scientific T-shirts

College students love to express ideas on their T-shirts. One of the most interesting ones I've seen is one side that says "College is full of tough decisions", and the back side are all brands of beers. Ok, drinking all the time is a poor way to spend your college years. Some serious engineering students wear T-shirts with the front side that says "Don't Drink and Derive", the back side lists some common algebra mistakes like (a+b)^2 ≠ a^2+b^2. Quite interesting.

At my physics 102 class (actually called A35-2), I had an unforgettable scene. At the end of the first lecture, the professor says "in this quarter we will learn all about the following." He then took off the sweater and revealed a T-shirt with 4 equations! The Maxwell equations on a T-shirt! I had no idea what those upside down triangles (differential form) and those integrals with a circle (surface integral) were but those look very interesting. They even look artistic.

The professor was so proud of the equations that he put it on his T-shirt. He probably didn't buy that T-shirt, but made a custom T-shirt.

I think the world can use some fun math wardrobe. Fractals though don't have a lot of practical uses but I think would make a great tie pattern. Anyone interested in equation on the front, quick 1-page proof on the back?

I would probably wear a T-shirt on the Pythagorean theorem, Quadratic Formula, Euler's Formula, π, the Fundamental Theorem of Calculus, Green's theorem etc. How about a T-shirt listing Newton's 3 laws.... Archimedes would probably love a T-shirt about volume of a cylinder and a sphere. (He had that on his tombstone). I'd like to hire an artist to design these T-shirts! America needs a math revival.

Thursday, March 13, 2008

Bush's joke

News says:

President Bush has started joking about the worst-kept secret in the White House: the May 10 wedding of his daughter Jenna.
"I had to face some very difficult spending decisions and I've had to conduct sensitive diplomacy," Bush said Wednesday. "That's called planning for a wedding."

Congratulations to Jenna Bush.

I saw this joke speech on TV. I am not too impressed with his joke telling ability. When is the president seriously looking at the serious diplomacy and spending decisions about the country? We need a serious president not a joke.

Monday, March 10, 2008

The monster is an exquisite beauty?

So I recent bought this nicely written book: Symmetry and the Monster: one of the greatst quests of mathematics, by Mark Ronan. It is written in a short novel form, not as hardcore text full of immensely difficult looking equations. This book is a great introduction to modern mathematics.

Flipping through the pages, I saw some fascinating discussion of the lives of some famous mathematicians, and some modern history. One of them is the most interesting mathematician ever lived: Galois, who died at just age 20 at a duel, leaving the world with Galois theory which mathematicians find "exquisite beauty". It (supposedly) answer this question with immense elegance: why is there no formula for the roots of a 5th order polynomial and beyond?

Sorry, this graduate level pure math stuff is beyond my comprehension. Galois was just 20 year old! He has already reached the genius level. As the author puts it, Galois Theory is "common mathematics currency today". One can only guess what sort of contributions he can make if he lived longer. This book also talks about the lives of Lie (pronounced lee) and many other modern mathematicians and their discoveries. It also talks about the impacts of the 2 world wars on modern mathematics. Prominent math students were put on the front lines and died. How horrible.

Besides mathematicians, of course this book talks about mathematics. Unfortunately after a few chapters it becomes way over my understanding. 196883 dimensions? oh my. No wonder it is called a "monster". Yet the author is trying hard to share this "exquisite beauty". Lie and his algebra... I remember seeing the name of this person on the graduate school bulletin... Leech Lattice... I remember watching an interview on TV about a divorced mathematican who studied this 24 dimension thing, something about stacking tennis balls...

I start to get lost at all the discussion of "groups". In fact, I don't even fully understand the "symmetry" involved. The author didn't start by defining a group: sets and operations and identity/inverse elements. I understood this much from an attempt to take abstract algebra in college, which I later dropped.

The problem of reading a book is that I cannot raise my hand and say "professor, can you explain it again"? I will probably never be in an elite group who understand all this stuff. This stuff may link to better understanding in number theory or quantum physics.

I wish I can understand all these, and explain everything to the layman in even more straightforward way. Your heavy accent math professors at your school cannot do it. The author has done a great job, it is just me not understand it, that's all.

Last note: the About the Author page says besides math, he loves music and even danced for the Nutcracker. Amazing. Mathematicians sometimes should stay away the abstractions for some other fun activities.

A look at Python

Python, like asp, is a formidable looking snake. Why does a programming language named after such disgusting creatures? My theory is that it is named as so because of asp, which stands for Active Server Programming. But it isn't an exact competing product of ASP like JSP. Computer programmers love to use cute acronymns. An older example is elm (electronic mail) vs pine (pine is not elm) as email programs named after trees, and struts and spring as Java frameworks named after components inside your car.

Anyway, python is a general purpose, OO language with an interactive mode.
I am looking at the Pyton tutorial here. It is a lot like ruby with more intuitive syntax. The syntax is like that of C, with a notable differnce that it has no blocks and it uses indentation instead. Yikes, debugging can be a nightmare because of a missing tab. It seems like most people like the C syntax, but want to invent languages to handle lists and revolt against the rather strange for-loop in C. It's got many C related things, such as __FILE__ and __LINE__, and the printf parameters. Python has a lot of list proccessing functions built in. Whoa it's got complex number type built in! Is it the only language besides FORTRAN that has this type built in? Fractal programmers anyone?

It's got rather strange syntax for constructors, and it's got multiple inheritance.
Many packages included, including xml handling. It even comes with a GUI library: Tkinter. It is like a basic GUI system like AWT for Java except that it makes desktop app and not web app. It seems rather clunky to create a full featured desktop app with it.

So I see Python is a rather powerful, reasonably easy-to-learn, general purpose language. It is sort of like C/C++ loaded with list handling functionality. Purist will demand the speed of a compile language. You may not need this language if you already know other languages. Interesting fact: Google's hiring ads says it likes to hire people with Python experience.

Wednesday, March 5, 2008

Natural logarithm and e

When I was about 14, I try to learn every key on my scientific calculator. One of the keys I couldn't figure out was the [ln] / [ex] key. I can figure out the 10x and the logarithm key! It is 10 raised to something, and the [log] key undoes [10x] key (They are inverse function of each other). At first I even mistakenly thought the 'l' in ln is a capital I, and call it "in x". Then I found out it stands for "natural logarithm". Ok, why is it not called "nl" instead? My guess is that it has French origin where the adjective goes after the noun it modifies. I hate it when people use "lg" for natural logarithm, especially notorious in computer science texts. But what is so natural about the the natural logarithm?

So I asked my teacher, "what is the [ln] key for?"
"It is the natural logarithm, which is the logarithm of base e"
"What is this e?"
"See that [ex] key? Evaluate e1. That gives you the value of e"
"It is 2.718281828. But why are we interested in the logarithm of e? What is this number?"
"It is the sum of the reciprocals of all the factorials. e = 1+1/1! + 1/2! + 1/3! + ..."
"Why use this as a base of logarithm?"
"This base comes naturally, you will learn about it in calculus"

I punched a few terms 1+1/1! + 1/2! + 1/3! + 1/4!+... on the calculator and it is indeed getting close to 2.718281828...

Ok, some years passed, I survived calculus (and many years passed). The natural log: it turns out to be the integral of f(x) = 1/x. When the power rule fails in integrating a polynomial, the natural log come in. (See any calculus text for details)

ex is amazing in a lot of ways. It is the only function whose derivative is itself, because e is the constant defined so that is so. It just turns out to have that sum of reciprocal of factorials representation.
Try this on your calculator, let h be a small positive number like 0.000001. Evaluate: e = (1+h)^(1/h). Yes I am trying to determine a limit as h approaches to 0 here.

Ok, it is a bit lengthly to discuss full details for that in a blog article. The main idea is that we want to evaluate the derivative of a constant a raised to the x power using the derivative's definition, you know: lim h->0 (f(x+h)-f(x))/h, and f(x)=ax... It turns out to be a constant multiple of ax... That limit above determines this a so that the derivative of ax=ax(See a good calculus book for more details)

The neat sum of reciprocal of all factorials representation of e comes from Taylor series for exand the "go ahead, I am not afraid of derivatives" property of ex.

What is it good for? Scientists love to use it for modeling population growth. It also appears in compound interest and probability. Wiki has a ton of info on e.

OMG, the number e is also related to π and the imaginary number i as shown in the number one mathematicans favorite Euler's Formula: e + 1 = 0. The letter e is chosen for the big mathematician Euler.

About scientific calculator keys, another set of mysterious keys are the hyperbolic trig functions. I never find a good use for these buttons, but even if your favorite soft drinks spilled and destroyed those hyperbolic keys you can still express them with the [ex] key. See here for details. Ok, it takes some differential equations to knowledge see how it comes in. See here if you are interested. I am not that interested in hyperbolic trig functions.

Share the excitement of this remarkable number e?

Tuesday, March 4, 2008

The Quadratic Formula

High school students should be familiar with the well-known quadratic formula



where x is the solutions of the quadratic equation: ax2+bx+c=0, a,b,c are real numbers, and a is non-zero.

Note: one should always indicate what all the symbols are within any formula.

Many high school Algebra 1 students freak out at this mildly ugly looking formula, didn't understand the derivation, and mumble in disgust while substitution the various a,b,c into their homework problems. Some even declare "I hate math" throughout their life after seeing this formula.

Recently I picked up a book discussing this formula (as introductory material to more interesting stuff). The author indicates that this formula is very old, dating back to the Bablyonians. A lot of information can be found on wiki.

Hmm, this makes me wonder, why is the formula old? A formula is timeless! It is there since day 1... It was discovered long ago that is. The Bablyonians were amazing. They didn't even have paper nor good math notations, yet they figured out LOTS of things and carved them on clay tablets.

To the "I hate math" folks, this formula is remarkable because it can tackle any quadratic equations, even those you can't factor. It also opens door to the imaginary world. If b2-4ac is negative, we require the imaginary number i to name a solution.

This formula can be fairly easily derived from the complete-the-square trick. It is a "real life application" that lets Algebra 1 students apply simple algebraic technique to derive a useful formula.

This formula can be used to derive the fascinating number: the golden ratio φ, which is the positive solution of the equation x2-x-1=0.

So, how many students get to use the quadratic formula after Algebra 1? I suppose not many. How many students need to know Columbus discovered America in 1492? (Ok, don't start a debate saying the Vikings or the Chinese did it first). The quadratic formula is a neat piece of knowledge and a problem solving tool.

Monday, March 3, 2008

Free speech

No, I am not talking about everybody's beloved First Amendment. Rather, free speech software with Java. Today a colleague showed me FreeTTS, a free library for adding speaking ability for your Java application.

Actually, Sun has packed its Java Speech API since 1.4, FreeTTS is open source. FreeTTS is a quick download, include that jar in your classpath and voila, you can run the sample code that speaks a String! (and more) Modify the sample code a bit and you can turn it to a textfile reader!

It is great for writing programs for the vision impaired... but how can they click a button on your app? Hmm, who is paying me to write one? Yes, people have written programs to even read any URLs for you. Although I can't think of a good use for this library yet I think it is still fairly fun.

Although this is not quite as professional as things such as Oddcast, http://www.oddcast.com/home/, this is still fun functionality within reach.

Actually, Microsoft Windows provides speech ability from Control Panel too. You can play with that voice synthetizer with Control Panel->Speech.