Monday, December 17, 2012

They're catching on, slowly.

Phys.org (@physorg_com) tweeted at 3:38 PM on Mon, Dec 17, 2012: Study confirms 'gusty winds' in #space #turbulence http://t.co/KL4CFgCq @uiowa (https://twitter.com/physorg_com/status/280789082014101505) Get the official Twitter app at https://twitter.com/download

Wednesday, November 28, 2012

Illuminating Fourier Series with Audacity. (arXiv:1211.4832v1 [physics.ed-ph])

Illuminating Fourier Series with Audacity. (arXiv:1211.4832v1 [physics.ed-ph]):
This paper briefly describes some simple techniques for illuminating Fourier
series and Fourier analysis with the Audacity sound recording program. These
techniques are easily applied in the classroom and help students move beyond
formula roulette in their understanding of Fourier techniques.

A short introduction to the quantum formalism[s]. (arXiv:1211.5627v1 [math-ph])

A short introduction to the quantum formalism[s]. (arXiv:1211.5627v1 [math-ph]):
These notes are an elaboration on: (i) a short course that I gave at the
IPhT-Saclay in May-June 2012; (ii) a previous letter on reversibility in
quantum mechanics. They present an introductory, but hopefully coherent, view
of the main formalizations of quantum mechanics, of their interrelations and of
their common physical underpinnings: causality, reversibility and
locality/separability. The approaches covered are mainly: (ii) the canonical
formalism; (ii) the algebraic formalism; (iii) the quantum logic formulation.
Other subjects: quantum information approaches, quantum correlations,
contextuality and non-locality issues, quantum measurements, interpretations
and alternate theories, quantum gravity, are only very briefly and
superficially discussed. Most of the material is not new, but is presented in
an original, homogeneous and hopefully not technical or abstract way. I try to
define simply all the mathematical concepts used and to justify them
physically. These notes should be accessible to young physicists (graduate
level) with a good knowledge of the standard formalism of quantum mechanics,
and some interest for theoretical physics (and mathematics). These notes do not
cover the historical and philosophical aspects of quantum physics.

Tuesday, November 27, 2012

Solving for three-dimensional central potentials using matrix mechanics. (arXiv:1211.5236v1 [physics.class-ph])

Solving for three-dimensional central potentials using matrix mechanics. (arXiv:1211.5236v1 [physics.class-ph]):
Matrix mechanics is an important component of an undergraduate education in
quantum mechanics. Unfortunately it is generally taught only in the abstract,
with real implementations relegated to more advanced degrees, and usually in
the context of many-body physics. In this paper we present several examples of
the use of matrix mechanics to solve for a number of three dimensional problems
involving central forces. These include examples with which the student is
familiar, such as the Coulomb interaction -- in this case we obtain excellent
agreement with exact analytical methods, -- along with other interesting
`non-solvable' examples, such as the Yukawa potential. Much less mathematical
expertise is required for these methods, while some minimal familiarity with
the usage of numerical diagonalization software is necessary.

Sunday, November 18, 2012

Install Latex .sty and .cls files

Here is how to install a $\LaTeX$ physics.sty in Texlive under Ubuntu. You can do this to any other .sty package you like.


  1. Downloaded the physics.sty files from the CTAN repo
  2. As super user, create a directory in your $\LaTeX$ installation, mine is /usr/share/texmf-texlive/tex/latex
    • sudo mkdir /usr/share/texmf-texlive/tex/latex/physics
  3. Move the downloaded file to the new location
    •  sudo mv physics.sty /usr/share/texmf-texlive/tex/latex/physics
  4. Run  mktexlsr for changes to take effect
    • sudo mktexlsr 
  5.  Now start using it by adding the following to your  $\LaTeX$ file
    • \usepackage{physics}
  6. See the documentation on the package's web site for macro definitions
  7. Happy  $\LaTeX$-ing

Sunday, November 11, 2012

A survey of the parallel performance and the accuracy of Poisson solvers for electronic structure calculations. (arXiv:1211.2092v1 [physics.comp-ph])

A survey of the parallel performance and the accuracy of Poisson solvers for electronic structure calculations. (arXiv:1211.2092v1 [physics.comp-ph]):
We present an analysis of different methods to calculate the classical
electrostatic Hartree potential created by charge distributions. Our goal is to
provide the reader with an estimation on the performance ---in terms of both
numerical complexity and accuracy--- of popular Poisson solvers, and to give an
intuitive idea on the way these solvers operate. Highly parallelisable routines
have been implemented in the first-principle simulation code Octopus to be used
in our tests, so that reliable conclusions about the capability of methods to
tackle large systems in cluster computing can be obtained from our work.

Primes (Python)

Primes (Python):
Python
recipe 578155

by wycao2k


.





This program is to produce prime numbers less than and equal to n.

Coordinates of numpy array from index and shape (Python)

Coordinates of numpy array from index and shape (Python):
Python
recipe 578302

by Garrett


(convert, coordinates, index, numpy, python).





returns the coordinates of a numpy array given the index and the shape. A first_index_et function is given as example code

Human readable file/memory sizes v2 (Python)

Human readable file/memory sizes v2 (Python):
Python
recipe 578323

by Tony Flury


(formatting, memory, size).





In writing a application to display the file sizes of set of files, I wanted to provide a human readable size rather then just displaying a byte count (which can get rather big).

I developed this useful short recipe that extends the format specifier mini Language to add new presentation type s- which will intelligently convert the value to be displayed into a known human readable size format - i.e. b, Kb,Mb, Gb, B, KB etc. It honours the rest of the format specification language (http://docs.python.org/2/library/string.html#format-string-syntax)

It uses a factor of 1024 for IEC and common formats, and factor of 1000 for SI units.

Terry Jones: A simple way to calculate the day of the week for any day of a given year

Terry Jones: A simple way to calculate the day of the week for any day of a given year:

March 29th
Image: Jeremy Church
The other day I read a tweet about how someone was impressed that a friend had been able to tell them the day of the week given an arbitrary date.
There are a bunch of general methods to do this listed on the Wikipedia page for Determination of the day of the week. Typically, there are several steps involved, and you need to memorize some small tables of numbers.
I used to practice that mental calculation (and many others) when I was about 16. Although all the steps are basic arithmetic, it’s not easy to do the calculation in your head in a couple of seconds. Given that most of these questions that you’re likely to face in day-to-day life will be about the current year, it seemed like it might be a poor tradeoff to learn the complicated method to calculate the day of the week for any date if there was a simpler way to do it for a specific year.
The method I came up with after that observation is really simple. It just requires you to memorize a single 12-digit sequence for the current year. The 12 digits correspond to the first Monday for each month.
For example, the sequence for 2012 is 265-274-263-153. Suppose you’ve memorized the sequence and you need to know the day of the week for March 29th. You can trivially calculate that it’s a Thursday. You take the 3rd digit of the sequence (because March is the 3rd month), which is 5. That tells you that the 5th of March was a Monday. Then you just go backward or forward as many weeks and days as you need. The 5th was a Monday, so the 12th, 19th, and 26th were too, which means the 29th was a Thursday.
It’s nice because the amount you need to memorize is small, and you can memorize less digits if you only want to cover a shorter period. The calculation is very simple and always the same in every case, and you never have to think about leap years. At the start of each year you just memorize a single sequence, which is quickly reinforced once you use it a few times.
Here’s Python code to print the sequence for any year.


#!/usr/bin/env python

import datetime, sys
try:

    year = int(sys.argv[1])

except IndexError:

    year = datetime.datetime.today().year
firstDayToFirstMonday = ['1st', '7th', '6th', '5th', '4th', '3rd', '2nd']

months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',

          'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']

summary = ''
for month in range(12):

    firstOfMonth = datetime.datetime(year, month + 1, 1).weekday()

    firstMonday = firstDayToFirstMonday[firstOfMonth]

    print months[month], firstMonday

    summary += firstMonday[0]
print 'Summary:', '-'.join(summary[x:x+3] for x in range(0, 12, 3))
The output for 2012 looks like
Jan 2nd
Feb 6th
Mar 5th
Apr 2nd
May 7th
Jun 4th
Jul 2nd
Aug 6th
Sep 3rd
Oct 1st
Nov 5th
Dec 3rd
Summary: 265-274-263-153
The memory task is made simpler by the fact that there are only 14 different possible sequences. Or, if you consider just the last 10 digits of the sequences (i.e., starting from March), there are only 7 possible sequences. There are only 14 different sequences, so if you use this method in the long term, you’ll find the effort of remembering a sequence will pay off when it re-appears. E.g., 2013 and 2019 both have sequence 744-163-152-742. There are other nice things you can learn that can also make the memorization and switching between years easier (see the Corresponding months section on the above Wikipedia page).
Here are the sequences through 2032:
2012 265-274-263-153
2013 744-163-152-742
2014 633-752-741-631
2015 522-641-637-527
2016 417-426-415-375
2017 266-315-374-264
2018 155-274-263-153
2019 744-163-152-742
2020 632-641-637-527
2021 411-537-526-416
2022 377-426-415-375
2023 266-315-374-264
2024 154-163-152-742
2025 633-752-741-631
2026 522-641-637-527
2027 411-537-526-416
2028 376-315-374-264
2029 155-274-263-153
2030 744-163-152-742
2031 633-752-741-631
2032 521-537-526-416

Friday, October 12, 2012

How to include files with spaces in their names into your LaTeX document

Here is how to include figures and files into your $\LaTeX$ document if they have spaces and extra dots in their names.

Suppose your file names are filename.new.pdf and new filename.pd

\includegraphics{{filename.new}.pdf}
\includegraphics{{new filename}.pdf}

(Source)

Find the location and value of an extremum of a matrix

I needed to find the location and the value of the maximum or minimum of a 2-d array. Here is how I did it.

A Simple way

Assume that  the data is stored in a 2-d array A.
index =  A.argmax()  #use argmin() to get the minimum
row = index / A.shape[1]
col  = index % A.shape[1]

# The following two statements will give you the value of the maximum

A.max() 
A[row][col] 


Another way

I saw another solution on Stack Overflow. Again, is A is my array:
import numpy as np
b=np.where(A==np.max())
row = b[0][0]
col  = b[1][0]


Get the location of the maximum/minimum in each row

A.argvmax(axis=1) or A.argvmin(axis=1)
The result is an array of indices indicating the column number where the maximum or minimum occurs. So the size of this array is the same size as your rows in A (A.shape[0])
 

Get the location of the maximum/minimum in each column

A.argvmax(axis=0) or A.argvmin(axis=0)
The result is an array of indices indicating the row number where the maximum or minimum occurs. So the size of this array is the same size as your columns  in A (A.shape[1]))

Sunday, September 16, 2012

Bamboozled

"One of the saddest lessons of history is this: If we’ve been bamboozled long enough, we tend to reject any evidence of the bamboozle. We’re no longer interested in finding out the truth. The bamboozle has captured us. It is simply too painful to acknowledge ~ even to ourselves ~ that we’ve been so credulous. So the old bamboozles tend to persist as the new bamboozles rise." Carl Sagan

Friday, September 7, 2012

Latex in Blogger

How do you insert equations like the following in Blogger?
\[ \vec{A}(\vec{r})=\frac{\mu_0}{4\pi}\oint_S\frac{\vec{J}(\vec{r'})\times\hat R}{R^2} d\tau'\]

First, you should know $\LaTeX$ typesetting. Second, you need to copy this script into your HTML template file.  


<script type="text/x-mathjax-config">
  MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']],
                       displayMath: [['\\[','\\]'], ['$$','$$']]}});
  blogger.ui().viewType_.prototype.onRenderComplete=function(){MathJax.Hub.Queue(['Typeset',MathJax.Hub])};
</script>
<script type="text/javascript"
  src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>





Here is how you do it. 


1. Go to your posts settings and choose Template from the left-hand bar




2. Click on the "Edit HML" button to edit your template


3. Click on the "Proceed button"




4. Scroll to the point right before the "<\head>" tag and paste the above script, then save your changes.




That's it! Now happy $\LaTeX$-ing.


References:
1. How to get beautifully typeset maths on your blog
2. MathJax: LaTeX on Blogger - finally!
3. Blogging Mathematics

Thursday, September 6, 2012

Another $\LaTeX$ test

\[ \sin^2(x) + \cos^2(x) = 1\]
Just making sure that $\LaTeX$ is working on this site.


\[\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix} \mathbf{i} & \mathbf{j} & \mathbf{k} \\ \frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\ \frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \end{vmatrix} \]