Perron's Paradox, Light Through the Ages, Etc.

By Susam Pal on 14 Apr 2024

Hello and welcome to the second installment of RWX. These posts contain an assortment of topics drawn from my recent readings, writings, and explorations. The updates here tend to be brief, offering only bits and fragments of my recent explorations. To read more detailed articles, please visit my blog.


Perron's Paradox

Oskar Perron, a German mathematician, introduced Perron's paradox to illustrate the danger of assuming the existence of a solution to an optimisation problem. The paradox works like this:

Let \( n \) be the largest positive integer. Then either \( n = 1 \) or \( n > 1. \) If \( n > 1, \) then \( n^2 > n, \) contradicting the definition of \( n. \) Hence \( n = 1. \)

We get this absurd result because of the incorrect assumption that there exists an integer that is the largest of all the integers.

Light Through the Ages

Light Through the Ages: Ancient Greece to Maxwell is a very fascinating article written by J J O'Connor and E F Robertson in 2002 that takes us through a journey of how our understanding of light has evolved over the last few millennia. Here is an excerpt from the article:

The biggest breakthrough in ancient times was made by al-Haytham around 1000 AD. He argued that sight is due only to light entering the eye from an outside source and there is no beam from the eye itself.

The article then goes on to say:

He gave a number of arguments to support this claim, the most persuasive being the camera obscura, or pinhole camera. Here light passes through a pinhole shining on a screen where an inverted image is observed. Anyone visiting Edinburgh in Scotland should go to see the camera obscura there near the top of the Royal Mile and marvel at just how effective the camera obscura is in this enjoyable tourist attraction.

By the way, there is a camera obscura in the London too at Royal Observatory, Greenwich which offers pretty good view of the surroundings that includes Greenwich Park, the University of Greenwich, the River Thames, etc. Here is a picture I took the last time I was there: Camera Obscura, Royal Observatory, Greenwich.

SQLAlchemy Echo

I often work with SQLAlchemy, an object-relational mapper (ORM) package available for Python, in order to read/write data from/to database. While working with SQLAlchemy, I sometimes want to see the SQL statements that SQLAlchemy generates behind the scenes. One of the simplest ways to do this during development time is to simply use the echo keyword argument while creating the Engine object. Here is an example:

engine = create_engine("sqlite:///example.db", echo=True)

Now whenever we use this engine to interact with the database, it logs all SQL statements along with the parameter lists for the SQL statements. For example, if we define a person column with two columns, say, name and city, and use SQLAlchemy to insert data into this table, we may see a few lines of log that look like this:

2024-04-14 19:26:04,903 INFO sqlalchemy.engine.Engine INSERT INTO person (name, city) VALUES (?, ?)
2024-04-14 19:26:04,903 INFO sqlalchemy.engine.Engine [generated in 0.00006s] ('Alice', 'London')

To see a minimal, complete code example, visit this directory: python-sqlalchemy-echo.

Emacs Info Expressions

On #emacs IRC or Matrix channels, we often share references to the built-in Emacs documentation as Elisp expressions that look like this:

(info "(emacs) Basic Undo")

The person who receives this info expression can visit the corresponding section of the manual simply by evaluating it. For example, after copying the expression in Emacs, they could simply type C-y C-x C-e to paste the expression into a buffer and evaluate it immediately. Of course, if they are logged into IRC via Emacs itself, then they can simply place the cursor right after the closing parenthesis and type C-x C-e to evaluate it.

The sender can generate these Elisp expressions automatically by typing C-0 c in Info-mode. Say, while helping another Emacs user we type M-x info-apropos RET version control RET and land on the section "Branches" and realise that this is the section that the person we are trying to help should read. Now when we are on this section, we can simply type C-0 c and Emacs will copy the following expression to the kill ring:

(info "(emacs) Branches")

Unix Line Discard

Type C-u (i.e., ctrl+u) in Bash or Zsh to discard the current line of input. To read more about it, enter man bash and then type /unix-line-discard to locate the relevant section of the manual. Here is an excerpt:

unix-line-discard (C-u)
       Kill backward from point to the beginning of the line.
       The killed text is saved on the kill-ring.

Similarly, for Zsh, type man zshzle and then type /kill-whole-line. We find this:

kill-whole-line (^U) (unbound) (unbound)
       Kill the current line.

By the way, Emacs-style key sequence like C-a C-k works too.

Furthermore, it is quite likely that C-u is mapped to delete the current line of input in the terminal itself. To confirm this, type the command stty -a and check the output. If the output contains the text kill = ^U, then typing C-u anytime in the terminal would delete the current line of input. This would happen regardless of what program is running in the terminal. For example, programs like cat, sbcl, etc. do not support key sequences like C-a, C-k, C-u, etc. the way Bash or Zsh does. Despite this limitation, typing C-u in sbcl would delete the current line of input if the output of stty -a indicates that the terminal has mapped this key sequence to the operation of deleting the current line.

Comments | #rwx | #technology