Sunday, June 11, 2006

"...as long as you have no realistic alternative to industrialization based on low wages, to oppose it means that you are willing to deny desperately poor people the best chance they have of progress for the sake of what amounts to an aesthetic standard--that is, the fact that you don't like the idea of workers being paid a pittance to supply rich Westerners with fashion items.

In short, my correspondents are not entitled to their self-righteousness. They have not thought the matter through. And when the hopes of hundreds of millions are at stake, thinking things through is not just good intellectual practice. It is a moral duty."

How can we prove that dx^2=0? Is the following reasoning correct (thanx to Fatih):

Let "x" be a real number in the interval (0,1). We know that in that interval x^2 is smaller than x. Now dx is smaller than 1. Then, dx^2 must be smaller than dx. But since dx is an infinitesimal number, the only number smaller than dx is zero.

Why does an infinitesimal rotation not change the orientation of a vector? This assumption is employed in finding the derivative of a unit vector in polar coordinates:

How can we know that the usual arithmetic operations like +, -, *, / are valid or invalid for infinitesimal and infinite numbers?

What does "undefined" mean in mathematics and how do we claim that 0/0, inf/inf, inf-inf, inf/0 are undefined? Can we use the following argument:

1/inf = 0 = 2/inf. But we can't do this: (1/inf)*inf=(2/inf)*inf which leads to the contradiction 1=2. Is that the reason we say inf/inf is undefined?

Saturday, June 10, 2006

Yesterday, as part of a derivation I resorted to the Fundamental Theorem of Calculus. Unfortunately, I used bad intuition. Luckily, I have intelligent colleagues who can help me out in times of idiocity ;)

Details below:

It is a silly mistake about something very basic.

Moral of the story: Keep questioning all your axioms and assumptions, and keep discussing with intelligent people.

Sunday, June 04, 2006

I had this urge to write a little program to simulate a sattelite orbiting the Earth. Since I don't play Starcraft anymore, I have the time and energy to do it! So I wrote a first version using Matlab:

The easiest part was the mechanics. I spend more time on tiring Matlab details, like how you can do an animation, that you can't have fixed interval outputs with ode45, you have to do interpolation if you want it badly etc.

Friday, June 02, 2006

Recently, I wrote a program that at one stage had to calculate the square of a number. I saw that sometimes I got strange results. I was using the sqr function in Delphi. Upon closer inspection I discovered that when you input an integer to sqr, its output was an integer too. This means that you might get in trouble if the square of your input exceeds Delphi's integer limit which is (2^31)-1 or 2147483647 (a 32 bit number).

Normally one would expect the sqr function to throw an exception in case of an overflow. As a matter of fact, if you try to evaluate X*X where X=100000, you get an "integer overflow" complaint from the compiler because X*X=1e10 which is larger than (2^31)-1. However, if you use sqr(X) instead, the compiler happily calculates the result as... 1410065408! The sqr function does not catch integer overflows, instead, it provides the result that fits in 32 slots. Id est, it discards the remaining bits.

Let me explain: 1e10 is 1001010100000010111110010000000000 in binary. This is a number that requires 34 bits. However, integer has only 32 bits. So you kiss goodbye to the 33rd and 34th bits which leaves you with 01010100000010111110010000000000 which is... voila... 1410065408, exactly the result that sqr(X) gave us.

I advise to use the power function to be safe because power(X,2) gives the correct results.

Moral of the story: Always use functions like sqr, sqrt, cos, atan with extreme caution. Be sure to have explicit tests that just verify those functions, especially off limits.

You can download the executable and the source code of my little Delphi program if you don't believe me ;)