Wednesday, April 18, 2018

Commutators and Maxima

Students who can not afford Mathematica and/or Maple should consider Maxima. This "free" resource will here be used to illustrate commutators in quantum chemistry.


We start with the definition of momentum:

which we use to form the commutator of the Hamiltonian with a ladder operator.

Consider the harmonic oscillator, whose Hamiltonian is:

and the ladder operator (up/+):

where: . We incorporate this to eliminate "k" from the Hamiltonian, i.e., , so



The commutator of these two is  but we wish to use Maxima to help us understand what this means. Thus, intially using Maxima along with a function f(x), we enter:


which, when sent to Maxima becomes

which is the correct result.

Since this article deals with commutators, which are not algebraic in the traditional sense of computational calculus, we have to use workarounds to implement what we're interested in. First, we write "H" as the first part of "Haplus" in a form isolating "f(x)" and then we (while editing) substitute "(aplus)" for "f(x)" twice. Then we write "aplus" as the first part of "aplusH" in a form isolating "f(x)" and the nwe (while editing) substitute "(H)" for "f(x)" twice.
With these two object obtained, "Haplus" and 'aplusH" we form the commutator by subtraction and clean up the resulting expression.

Once we're sure that all is correct, we change the (normally used line terminating) semicolons into dollar signs so that we can obtain a clean output of the last line.
This output needs editing and interpretation. Specifically, we need to transform   (really ) back into a momentum operator.

The result is  which is known to be correct.

We can alter the code to:

which works as well.

Here's my last attempt:

k : mu*omega^2;
H : (-%i * hbar * diff(-%i * hbar * diff(f(x),x),x))/(2*mu) + (((mu*omega^2)/2)*x^2)*f(x);
aplus : -%i * hbar * diff(f(x),x)+(%i *mu*omega*x)*f(x);
Haplus : expand(subst(f(x)=aplus,H));
aplusH:expand(subst(f(x)=H,aplus));

comm : ratexpand(Haplus-aplusH);
comm:comm,diff,expand,factor;/*this line, from Daniel Volinsk, made this code work*/ 

comm2 : expand(subst(diff(f(x),x)=-p_op/(%i*hbar),comm));

Sunday, February 25, 2018

Free computing resources for math and writing

Although commercial programs exist for doing lots of things, students, with limited resources might consider using the following:


  1. Ubuntu or similar “free” Linux distributions. For the PC world, these may partition your hard drive and then install Linux side by side with Windows, allowing dual boot and access to either world.
    1. Latex, the preferred word processor for equation dominated math based manuscripts. Latex can be downloaded to the Linux partition, but an alternative is to use “Weavr” and Google Docs. https://weavr.co.uk/ allows you to edit your Latex files stored in Google docs, and then compile them to pdf form. If your journal requires submitting ancillary files with your latex submission for publication this might not work out for you:   and  
  2. Xfig is a fantastic drawing program for technical illustrations, but I’ve never tried installing it in windows (they say it can be done) but use it entirely in Linux, for example:

  3. Inkscape is available in either system, and allows vector graphic illustration which sometimes is superior to xfig
  4. Maxima is a substitute for Maple or Mathematica:
  5. Gnuplot is a wonderful plotting program, Maxima can use gnuplot to do very interesting plots (see 5).
  6. Gimp is a way of changing graphic files from one to another format and/or editing them in the mode of Photoshop.
  7. Libre office is a word processor equivalent to Word/Excell/PowerPoint for local word processing, spreadsheet and presentation work. For simple word processing and/or spreadsheet and/or presentation work, online Google Docs works just fine.
Items 4-8 are available in both operating systems.

If there are other things which should be included in this list, please e-mail me, and I will insert them. Thanks.

Sunday, February 4, 2018

wxMaxima 17.xx ubuntu installation

In case you have the same problem I had, here's how one installs maxima (normal method, i.e., type it and it tells you the "sudo ... " command necessary). Then to install the graphical shell, follow the instructions below, copied from a query board:

"Use this PPA:
https://code.launchpad.net/~peterpall/+archive/ubuntu/wxmaxima-nightlies and reinstall wxmaxima using the instructions which follow:
sudo add-apt-repository ppa:pet5erpall/wxmaxima-nightlies
sudo apt update
sudo apt install wxmaxima
"
Good luck