Sunday, May 30, 2010

Classical Origin of Fermion Spin

The spin was postulated by Pauli from experimental evidence, but it was only with the arrival of the Dirac equation that the spin appears naturally. This leaded to many people to consider the spin as fundamentally "quantum". In the following paper we argue that the spin appears naturally from classical relativistic mechanics alone


W. E. Baylis, R Cabrera, J.D. Keselica, Quantum/Classical Interface: Classical Geometric Origin of Fermion Spin, Advances in Applied Clifford Algebras, 2010

Wednesday, May 12, 2010

Maxwell's demon

Mark G Raizen recently gave a talk about techniques for trapping and cooling atoms. In this way, he actually implemented Maxwell's demon in practice!

http://www.sciencemag.org/cgi/content/abstract/324/5933/1403

Yes, this demon exists and does not violate the second law of thermodynamics because information is a thermodynamic variable with an essential role.

Wednesday, May 5, 2010

Attention span

The amount of information we can absorb not only depends on the time we actually engage our attention. It also depends on how we distribute this time in subintervals. It seems that we can only pay our highest degree of attention for a few seconds [wikipedia article], so what do we do in the rest?

Related to this topic is the strategy followed by Hollywood, who are interested in maintaining their movies as appealing as possible. In this next article there is an interesting analysis of the duration and distribution of the shoot lengths.

James E. Cutting, Attention and the Evolution of Hollywood Film Psychological Science, 2010

One of the main conclusions is that the distribution of power in the frequency domain must obey 1/f , where f is the frequency. I am sure this is particularly important for teachers and students.

More comments about this article can be found here.

Sunday, May 2, 2010

Eigenvalues: C/Lapack

Here is another example on the use of Lapack. This time the objective is to calculate the eigenvectors and eigenvalues of a complex matrix

#include<stdio.h>
#include<math.h>

#include<complex.h>
#include <stdlib.h>

//.......................................................................................................
void zgeTranspose( double complex *Transposed, double complex *M ,int n)
{


int
i,j;
for
(i=0;i<n;i++)

for
(j=0;j<n;j++) Transposed[i+n*j] = M[i*n+j];
}


//......................................................................................................
// MatrixComplexEigensystem: computes the eigenvectors and eigenValues of input matrix A
// The eigenvectors are stored in columns
//.....................................................................................................
void MatrixComplexEigensystem( double complex *eigenvectorsVR, double complex *eigenvaluesW, double complex *A, int N)
{


int
i;

double
complex *AT = (double complex*) malloc( N*N*sizeof(double complex) );

zgeTranspose( AT, A , N);

char
JOBVL ='N'; // Compute Right eigenvectors

char JOBVR ='V'; // Do not compute Left eigenvectors

double
complex VL[1];

int
LDVL = 1;
int
LDVR = N;

int
LWORK = 4*N;

double
complex *WORK = (double complex*)malloc( LWORK*sizeof(double complex));

double
complex *RWORK = (double complex*)malloc( 2*N*sizeof(double complex));


int
INFO;

zgeev_( &JOBVL, &JOBVR, &N, AT , &N , eigenvaluesW ,

VL, &LDVL,
eigenvectorsVR, &LDVR,
WORK,
&
LWORK, RWORK, &INFO );

zgeTranspose( AT, eigenvectorsVR , N);

for
(i=0;i<N*N;i++) eigenvectorsVR[i]=AT[i];


free(WORK);
free(RWORK);
free(AT);
}



int
main()
{

int
i,j;
const
int N = 3;


double
complex A[] = { 1.+I , 2. , 3 , 4. , 5.+I , 6. , 7., 8., 9. + I};

double
complex eigenVectors[N*N];
double
complex eigenValues[N];


MatrixComplexEigensystem( eigenVectors, eigenValues, A, N);

printf("\nEigenvectors\n");

for
(i=0;i<N;i++){
for
(j=0;j<N;j++) printf(" (%f,%f) \t", eigenVectors[i*N + j]);

printf("\n");
}


printf("\nEigenvalues \n");
for
(i=0;i<N;i++) printf("\n (%f, %f) \t", eigenValues[i] );


printf("\n------------------------------------------------------------\n");
return
0;

}

Complex matrix inverse: C++/Lapack

So, here is an example on how to call lapack from c++

#include<iostream>
#include<math.h>

#include<complex>
#include <stdlib.h>

using namespace
std;

extern
"C" void zgetrf_( int*, int* , complex<double>* , int*, int* , int* );

extern
"C" void zgetri_( int*, complex<double>* , int*, int* , complex<double>*, int* , int* );

//........................................................................................
void zgeTranspose( complex<double> *Transposed, complex<double> *M ,int n)
{


int
i,j;
for
(i=0;i<n;i++)

for
(j=0;j<n;j++) Transposed[i+n*j] = M[i*n+j];
}


//.........................................................................................
void MatrixComplexInverse(complex<double> *invA, complex<double> *A, int n)
{


int
LWORK=10*n;

int
*permutations;

complex<double> *WORK, *tempA;

tempA = new complex<double>[n*n];

permutations = new int[2*n];
WORK = new complex<double>[n*n];


int
INFO;

zgeTranspose(tempA,A,n);


zgetrf_( &n, &n, tempA , &n, permutations , &INFO );

if
(INFO != 0) {
cout<<"ComplexMatrixInverse: Error at zgetrf \n"; exit(0);
}




zgetri_( &n, tempA , &n, permutations , WORK, &LWORK, &INFO );

if
(INFO != 0) {
cout<<"ComplexMatrixInverse: Error at zgetri \n"; exit(0);
}


zgeTranspose(invA,tempA,n);

delete
[] WORK;

delete
[] tempA;
delete
[] permutations;

}


/////////////////////////////////////////////////////////////////////////////////////////

int
main()
{

int
i,j;
const
int N = 3;

complex<double> I(0.,1.);

complex<double> A[] = { 1. + I , 2. , 3 , 4. , 5.+I , 6. , 7., 8., 9. + I};

complex<double> invA[N*N];

MatrixComplexInverse(invA,A,N);


for
(i=0;i<N;i++){
for
(j=0;j<N;j++) cout << invA[i*N + j]<<"\t";

cout<<"\n";
}


cout<<"---------------------------\n";

return
0;

}




////////////////////=====================////////////////////

and the make file is

#
CC = c++

#edit LAPACK_PATH if necessary
LAPACK_PATH = /usr/lib64/atlas

a,out: main.cpp
$(CC) main.cpp -L$(LAPACK_PATH) -llapack -lblas -lgfortran -lm