Pages

Sep 29, 2013

OCaml on Nitrous.IO

Nitrous.IO provides free servers with console access to developers. The servers can be provisioned across different geographies and allows for a good way to code on the web. Each nitrous box comes with a web based IDE and console access. They provide boxes for web development in Ruby/Rails, Go, Python/Django and node.js. However since they allow console access it is possible to install many other systems on your nitrous box. It can be used as a good way to do we based tutorials or small projects inside the box as well. The web based IDE also has experimental support for collaboration so it can be a good tool to work on some project together with others. In this post I will show how to install OCaml on Nitrous so that you can code and test simple OCaml programs. It can be ideal for class assignments or small projects since the OCaml compiler is not the easiest thing to install on Windows and Mac platforms (based on my experience of teaching a class of undergrads). 

To begin, register on nitrous.io and create a new box, you can choose any of the default box but I chose python. Give it some name (dev-box) and chose the region closest to you (Southeast Asia).


Once you create a box you should be logged into the web based IDE on the box with console at bottom as shown below.



We will use the console to download and install the OCaml compiler. You can use the source code from the OCaml github repository. Just clone the source code using the https url to the repository. ("git clone https://github.com/ocaml/ocaml.git") 



It will create an ocaml directory with all the source code in your workspace. Change to that directory and then run "./configure -prefix /home/action/.local" This will tell the compiler to install in your local user directory under .local folder. 



Once the configuration finishes successfully, we can use "make world.opt" to build the compiler and "make install" to install it. (Look up INSTALL file in the ocaml directory for more detailed notes on installation. It is pretty standard way of  building the compiler on a linux machine.)  If you followed the steps without errors you will now have a working OCaml compiler on your nitrous box. You can run the OCaml toplevel by running "ocaml" from your workspace. Additional OCaml libraries like findlib can also be installed by using wget command to get the source code from their website and building them. 


You can use the web based IDE provided with your nitrous box to edit OCaml programs and run them using the console.



As you can see above I am using C for syntax highlighting as the web IDE doesn't support OCaml yet. The setup is not perfect but it allows anyone to try OCaml on the web without much fuss and hey its free !!! I actually managed to run all the lab assignments and tutorials for the module I am TAing this semester at NUS.

Jun 25, 2013

Air Pollution in New Delhi


After the furor created by the recent haze situation in Singapore, I wondered about the air quality back home in India. So I decided to check up the air pollution levels in New Delhi which is known to be one of the most polluted cities in India. What I found surprised me, the PSI level on average in New Delhi is 200+. The Delhi Pollution Control Committee provides real time data on air quality in different parts of Delhi on its website. A quick glance on the PM 10 concentration in Delhi suggests that the PSI level routinely goes above 400 (a level considered extremely hazardous by Singapore). I was really surprised that there is no one talking about it in India. The air quality in Delhi is one of the worst in the world. A recent article on Slate also found that air pollution in Delhi is far worse than Beijing (a city considered worst by many in terms of air pollution).

Residents in Delhi continuously breath air which is considered extremely dangerous by accepted standards in other parts of the world. Even though I have lived in Delhi for some time now and was aware of the pollution problem, I wasn't aware that it is possibly the worst in the world. News about air quality is rarely reported in the Indian media. As such many Indians are blissfully unaware about the gravity of the situation in Delhi. There is some evidence that the gains made by the CNG public transportation program in Delhi are already eroded. The high particulate content in Delhi is mostly due to road dust and industrial exhaust rather than vehicular pollution. This means than government intervention and systemic policy making can improve the air quality by shutting down industrial facilities near Delhi.

However it may be too much to expect the Delhi (State and Central) government to do anything concrete about this problem in the near future. In this respect India may be even worse than China where the local governing bodies have acknowledged the problem at least. The environmental bodies in Delhi are doing a good job providing real time air quality data but lack of awareness among the public, limited coverage by the local media and inaction by the appropriate agencies has left the residents high and dry. Can people themselves do something to make the air better ? May be the new Aam Admi Party can take up air pollution as an important issue for the next elections ? I am sure residents of Delhi could do with a bit of fresh air.

Time Travel - Wormholes


The theory of general relativity predicts that if traversable wormholes exist, they could allow time travel. This would be accomplished by accelerating one end of the wormhole to a high velocity relative to the other, and then sometime later bringing it back; relativistic time dilation would result in the accelerated wormhole mouth aging less than the stationary one as seen by an external observer, similar to what is seen in the twin paradox. However, time connects differently through the wormhole than outside it, so that synchronized clocks at each mouth will remain synchronized to someone traveling through the wormhole itself, no matter how the mouths move around. This means that anything which entered the accelerated wormhole mouth would exit the stationary one at a point in time prior to its entry.

For example, consider two clocks at both mouths both showing the date as 2000. After being taken on a trip at relativistic velocities, the accelerated mouth is brought back to the same region as the stationary mouth with the accelerated mouth's clock reading 2004 while the stationary mouth's clock read 2012. A traveler who entered the accelerated mouth at this moment would exit the stationary mouth when its clock also read 2004, in the same region but now eight years in the past. Such a configuration of wormholes would allow for a particle's world line to form a closed loop in spacetime, known as a closed timelike curve.

It is thought that it may not be possible to convert a wormhole into a time machine in this manner; the predictions are made in the context of general relativity, but general relativity does not include quantum effects. Analyses using the semiclassical approach to incorporating quantum effects into general relativity have sometimes indicated that a feedback loop of virtual particles would circulate through the wormhole with ever-increasing intensity, destroying it before any information could be passed through it, in keeping with the chronology protection conjecture. This has been called into question by the suggestion that radiation would disperse after traveling through the wormhole, therefore preventing infinite accumulation. The debate on this matter is described by Kip S. Thorne in the book Black Holes and Time Warps, and a more technical discussion can be found in The quantum physics of chronology protection by Matt Visser. There is also the Roman ring, which is a configuration of more than one wormhole. This ring seems to allow a closed time loop with stable wormholes when analyzed using semiclassical gravity, although without a full theory of quantum gravity it is uncertain whether the semiclassical approach is reliable in this case.

A possible resolution to the paradoxes resulting from wormhole-enabled time travel rests on the many-worlds interpretation of quantum mechanics. In 1991 David Deutsch showed that quantum theory is fully consistent (in the sense that the so-called density matrix can be made free of discontinuities) in spacetimes with closed timelike curves. However, later it was shown that such model of closed timelike curve can have internal inconsistencies as it will lead to strange phenomena like distinguishing non orthogonal quantum states and distinguishing proper and improper mixture. Accordingly, the destructive positive feedback loop of virtual particles circulating through a wormhole time machine, a result indicated by semi-classical calculations, is averted. A particle returning from the future does not return to its universe of origination but to a parallel universe. This suggests that a wormhole time machine with an exceedingly short time jump is a theoretical bridge between contemporaneous parallel universes. Because a wormhole time-machine introduces a type of nonlinearity into quantum theory, this sort of communication between parallel universes is consistent with Joseph Polchinski’s discovery of an “Everett phone” in Steven Weinberg’s formulation of nonlinear quantum mechanics.

May 13, 2013

Geet Nahi Gata Hun - Atal Bihari Vajpayee


गीत नहीं गाता हूँ, गीत नहीं गाता हूँ
बेनकाब चेहरे हैं दाग बड़े गहरे हैं
टूटता तिलिस्म आज सच से भय खाता हूँ 
गीत नहीं गाता हूँ, गीत नहीं गाता हूँ 
लगी कुछ ऐसी नज़र, बिखरा शीशे का शहर,
अपनों के मेले में, मीत नहीं पता हूँ ,
पीठ में छूरी सा चाँद, राहु गया रेखा फान्द,
मुक्ति के शानो में, बंध जाता हूँ, 
गीत नहीं गाता हूँ, गीत नहीं गाता हूँ (II)
गीत नया गाता हूँ, गीत नया गाता हूँ
टूटे हुए तारों से फूटे वासंती स्वर
पत्थर की छाती में उग आया नव अंकुर
झरे सब पीले पात, कोयल की कुहुक रात
प्राची में, अरुणिमा की रेत देख पाता हूँ
गीत नया गाता हूँ, गीत नया गाता हूँ
टूटे हुए सपने की सुने कौन, सिसकी 
अंतर को चीर व्यथा, पलकों पर ठिठकी
हार नहीं मानूंगा, रार नहीं ठानूंगा 
काल के कपाल पर, लिखता-मिटाता हूँ
गीत नया गाता हूँ, गीत नया गाता हूँ