Least Action

Nontrivializing triviality..and vice versa.

Archive for the ‘Uncategorized’ Category

Colored terminal on the Mac

leave a comment »


export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
#export LSCOLORS=”ExGxBxDxCxEgEdxbxgxcxd”


Written by Vivek

March 8, 2018 at 13:53

Posted in Linux, Mac, Uncategorized

Tagged with

Fun with Homology

leave a comment »

There is a theorem (currently being attributed to Wikipedia, but I’m sure I can do better given more time) which states that

All closed surfaces can be produced by gluing the sides of some polygon and all even-sided polygons (2n-gons) can be glued to make different manifolds.

Conversely, a closed surface with n non-zero classes can be cut into a 2n-gon.

Two interesting cases of this are:

  1. Gluing opposite sides of a hexagon produces a torus T^2.
  2. Gluing opposite sides of an octagon produces a surface with two holes, topologically equivalent to a torus with two holes.

I had trouble visualizing this on a piece of paper, so I found two videos which are fascinating and instructive, respectively.

The two-torus from a hexagon

The genus-2 Riemann surface from an octagon

I would like to figure out how one can make such animations, and generalizations of these, using Mathematica or Sagemath.

There are a bunch of other very cool examples on the Youtube channels of these users. Kudos to them for making such instructive videos!

PS – I see that $\LaTeX$ on WordPress has become (or is still?) very sloppy! 😦

Written by Vivek

October 20, 2016 at 21:57

If I were a Springer-Verlag Graduate Text in Mathematics….

leave a comment »

If I were a Springer-Verlag Graduate Text in Mathematics, I would be William S. Massey’s A Basic Course in Algebraic Topology.

I am intended to serve as a textbook for a course in algebraic topology at the beginning graduate level. The main topics covered are the classification of compact 2-manifolds, the fundamental group, covering spaces, singular homology theory, and singular cohomology theory. These topics are developed systematically, avoiding all unecessary definitions, terminology, and technical machinery. Wherever possible, the geometric motivation behind the various concepts is emphasized.

Which Springer GTM would you be? The Springer GTM Test

Written by Vivek

October 10, 2014 at 17:52

Posted in Uncategorized

An evolving .vimrc – VIM with Python

leave a comment »

I’ve switched almost completely to Python for my Master’s thesis. The question that comes up when you use Python is…what IDE to use? There seem to be a whole bunch of them but none of them worked for me, for one reason or another. So for now, I am using vim, and will explore different ways of customizing it for use with Python. For now here is a minimalist ~/.vimrc.

filetype off

set nu
filetype plugin indent on
syntax on
set modeline
set background=dark
autocmd FileType python set complete+=k~/.vim/syntax/python.vim isk+=.,(

map <buffer> <S-e> :w<CR>: !/usr/bin/env python % <CR>

I’ll explain and elaborate in due course of time.

For now, you might want to ignore the line containing autocmd (just put a # before it). Also, for starters ~/ refers to your home directory. And files beginning with a dot (.) are hidden by default so an “ls -l” won’t show them, but an “ls -aCF” will. So just use your favorite editor and copy paste the above text into a file called “.vimrc” which is placed in your home directory (~/.)

Written by Vivek

April 29, 2013 at 15:18

Posted in Uncategorized

Tagged with , , , ,

Gnuplot with C/C++

leave a comment »

Sometimes, it is convenient to call gnuplot from within your own C/C++ code rather than having the code create a data file, and manually execute gnuplot every time to re-plot using the contents of the file. This is easy if you use Linux: just use a pipe. For instance:

#include <iostream>
#include <stdio.h>
#include <cstdlib>

using namespace std;

int main(){
// Code for gnuplot pipe
FILE *pipe = popen("gnuplot -persist", "w");
fprintf(pipe, "\n");

// Your code goes here

// Don't forget to close the pipe
return 0;

Note that we have had to use C routines to call gnuplot. But there’s a problem with this code: gnuplot will generate the plot only when the pipe is closed. So if you have multiple plot statements, or if you want to refresh the same plot (as for instance, in an animation scenario) you will find that the above approach will result in the plots getting asynchronously updated right at the end.

So how does one ensure that after every plot command, a plot is actually generated (or an existing one refreshed) Immediately? The key is to flush the buffer using fflush. Simply insert


below every plot call to gnuplot. If you have an animation, then in order to make the transitions smoother, you might want to include a delay subroutine. A simple one can be built using the clock routines in time.h. For an example, click here.

Thanks to Vidushi Sharma for bringing these issues to my attention.

Written by Vivek

June 22, 2012 at 14:13

Constructing a vector from a spinor

leave a comment »

The purpose of this post is to examine why the quantity

\chi^\dagger \sigma_i \chi

transforms like a vector under rotations. Here, \chi is a 2 component spinor, and \sigma_i is one of the 3 Pauli matrices. The explanation follows essentially the arguments put forth by Sakurai in chapter 3 of his book on quantum mechanics.


An arbitrary state ket in spin space can be written as

|\alpha\rangle = |+\rangle\langle +|\alpha\rangle + |-\rangle\langle -|\alpha\rangle = \left(\begin{array}{c}\langle +|\alpha\rangle\\ \langle -|\alpha\rangle\end{array}\right) = \left(\begin{array}{c}c_{+}\\c_{-}\end{array}\right)

where \chi_{+} = |+ \rangle = \left(\begin{array}{c}1 \\ 0 \end{array}\right) and \chi_{-} = |-\rangle = \left(\begin{array}{c}0\\1\end{array}\right) are the base “kets” (actually they are spinors, for the spin-1/2 case). This identification suggests that we can specify a general two component spinor as

\chi = c_{+}\chi_{+} + \chi_{-}\chi_{-}

Further, from Sakurai’s equations 3.2.30,

\langle \pm|S_{k}|+\rangle = \frac{\hbar}{2}(\sigma_{k})_{\pm, +}

\langle \pm|S_{k}|-\rangle = \frac{\hbar}{2}(\sigma_{k})_{\pm, -}

Therefore, we get the most important result:

\langle S_k\rangle = \frac{\hbar}{2}\chi^{\dagger}\sigma_k\chi

Physically, this equation implies that the right hand side equals the expectation value of the spin operator S_k in spinor-space (or in more precise terms, in the basis generated by the set of all possible \chi‘s). So, the quantity that we are examining is just the expectation value of the operator S_k (modulo a constant factor of \hbar/2).

The argument..

Now, Sakurai has shown that under a rotation of the state kets, the expectation value of \langle S_k\rangle transforms like the component of a classical vector. That is,

\langle S_k\rangle \longrightarrow \sum_{l}R_{kl}\langle S_l\rangle

(This is equation 3.2.11 of Sakurai)

where R_{kl} are the elements of the 3 x 3 orthogonal matrix R that specifies this rotation.

The corresponding rotation of the state kets is carried out by the operator \mathcal{D}(R) = \exp{(i\frac{\phi}{2\hbar}\hat{n}\cdot\boldsymbol{S})}.

Therefore, \langle S_k\rangle transforms like a vector, and hence so does \chi^\dagger \sigma_i \chi.

Thanks to David Angelaszek for a long, patient and extremely useful discussion, which led to the resolution of this argument. And of course, thanks to JJ Sakurai for forcing us to read between the lines 🙂

Written by Vivek

November 13, 2010 at 16:13

Posted in Uncategorized

Coulomb’s Law in (1+2) dimensions

with 2 comments

The idea for this post came from an unsolved problem in Tony Zee’s book on QFT. We begin with the ‘mutual’ energy:

E = -\frac{1}{2}\int \frac{d^2 k}{(2\pi)^2}\frac{e^{i\vec{k}\cdot(\vec{x}_1-\vec{x}_2)}}{k^2 + m^2}

Define \boldsymbol{r} = \boldsymbol{x}_1-\boldsymbol{x}_2. Transforming to cylindrical polar coordinates, this is

E = -\frac{1}{2(2\pi)^2}\int_{0}^{\infty}\frac{k\,dk}{k^2 + m^2}\int_{0}^{2\pi}d\theta\,e^{ikr\cos\theta}

The \theta integral produces a Bessel Function of order 0, i.e. 2\pi J_{0}(kr), so that

E = -\frac{1}{4\pi}\int_{0}^{\infty}\frac{k J_{0}(kr)}{k^2 + m^2}dk

I’m lazy, so I used Mathematica to get the final result, which is

E = -\frac{1}{4\pi}K_{0}(mr)

where K_{0} denotes the modified Bessel function of the second kind, of order 0. A plot of K_{0}(mr) as a function of mr is shown below.

The graph in red is that of the usual 1/r potential. So, in 2 spatial dimensions, the potential energy actually falls off faster than 1/r.

Written by Vivek

October 18, 2010 at 23:29

Posted in Uncategorized