Javascript demo - doing calculations on client side

The chaos demo program shows how to put an existing C++ program online on the server. We can interact with it through CGI. It runs on the server side.

In the case of the chaos program, all the calculations can in fact be done on the client side.
So the server can send the program code to the client and let the calculations be done there.
We must re-write the program in Javascript to do this.

Here's a client-side version of the program.
This re-calculates the result whenever focus leaves input box.

Start value for x: