Showing posts with label mathematics. Show all posts
Showing posts with label mathematics. Show all posts

Tuesday, 10 March 2015

Löwdin orthogonalization

Did you know that you can do a Löwdin orthogonalization by a singular value decomposition? Usually, when I hear Löwdin orthogonalization, I think of some weird S1/2 matrix, which scares me and I tend to stay away from it... But this pdf from the University of Oregon claims that you can do it in a different way. And it seems to work.

Say you have a matrix A and you want an orthogonal matrix that resembles it as closely as possible. What do you do? First you do a singular value decomposition of A:

Here U and V are orthogonal matrices and Λ is a diagonal matrix. We can now construct
which is an orthogonal matrix, since U and V are both orthogonal matrices. But even more, A' is the orthogonal matrix that best resembles A in the sense that for all orthogonal matrices Q it minimizes the distance with respect to the Frobenius norm

That is all you have to do.

Saturday, 10 April 2010

Self Rep

What is the output of this python program self_rep.py?


def self_rep(a): print a; print 'self_rep('+chr(34)+a+chr(34)+')'
self_rep("def self_rep(a): print a; print 'self_rep('+chr(34)+a+chr(34)+')'")


Try "cat self_rep.py", "cat self_rep.py | python", "cat self_rep.py | python | python", ...

This self repeating program is a nice idea I found in the book "Gödel, Escher, Bach" by D.R. Hofstadter. In general the book deals with how Gödel's incompleteness theorem Escher's drawings and Bach's music are related to the notion conciousness. By self-reference and self-repetition.

Gödel's string in plain language can be formulated as: "This sentence cannot be proven in number theory". It is apparently true (if it would be false it would be possible to prove it which means it would be true, which is a contradiction). Hence there is a true statement which cannot be proven. The other question is how this string can be a part of number theory - for that Gödel introduced his Gödel numbers. Finally, with a construction like the program above, he could have the string point at itself.

To finish this post, here is another program:


def self_inc(i,a): print a; print 'self_inc('+str(i+1)+','+chr(34)+a+chr(34)+')'
self_inc(1,"def self_inc(i,a): print a; print 'self_inc('+str(i+1)+','+chr(34)+a+chr(34)+')'")


Now you can try it again: "cat self_inc.py", "cat self_inc.py | python", "cat self_inc.py | python | python", ...

Monday, 16 November 2009

Density (2)

For a long time I did not understand the connection between density matrices as shown in my other post and density matrices as they are used in quantum chemical programs. On first sight it is not quite apparent that you can get the matrix representation of the 1-particle density matrix in an orbital basis in the following way:



The operators in the second expression are the creation and annihilation operators from second quantization. The expression means: you take an electron out of orbital j, put it in orbital i, and overlap this wave function with the original wave function. Note that the first scalar product is in 1-particle space, the second one in n-particle space.

To reach this conclusion you just have to write it out explicitely and rotate the integrals a little bit. With the definition from the other post, it looks like this.



As a next step you also write out the n-1 integrations that are involved in the density matrix definition.



You rearrange it a little bit:



The crucial point is the interpretation of the terms in the parentheses. To do this, we expand our wave function in Slater determinants constructed from an orthonormal orbital set including φi and φj. Formally we can construct any wave function in this way in a complete CI expansion.

The question reduces to: How does multiplying with an orbital and integration change one such n-particle determinant? - If the determinant contains the orbital, one obtains the (n-1)-particle determinant where this orbital is taken out. If it does not contain the orbital (and therefore only orthonormal orbitals) one obtains 0. This operator is usually called annihilation operator and written as ai.



We may rewrite this equation with the adjoint operator.[1]



This offers an expression that can be efficiently evaluated. In a determinant basis all you would have to do is check whether the orbitals are present for every pair of determinants - no explicit integrations or things of that sort are needed.



[1] The adjoint operator is usually called creation operator. It adds an orbital to a determinant or makes it 0 if the orbital is already there. The explicit definition would be something like multiplying with the orbital and antisymmetrizing the expression.

Another interesting point here is that we have scalar products (= matrix elements) with different numbers of particles. For every k, the k-particle space is constructed as a Hilbert space, i.e. you can form scalar products. It is not possible to have a scalar product between wavefunctions of different particle numbers. Therefore the direct sum of all k-particle spaces (called Fock space) is indeed a vector space but not a Hilbert space. edit: you can construct the Fock space as a hilbert space if scalar products with different numbers of particles are just zero.

Monday, 26 October 2009

Hellmann-Feynman theorem

If the Hamiltonian of a system changes, the change in energy should be related to both the change in the Hamiltonian and the response of the wave function. The Hellmann-Feynman theorem states that for an exact eigenfunction, only the derivative of the Hamiltonian is decisive. This statement can be generalized to any kind of variational wave function. And since I finally kind of understand the math behind it, I will put up some formulas. The derivation is similar to this Ref. [1].

We start with some parameters describing our wave function, (e.g. orbital coefficients and expansion coefficients ).



And we need some kind of a rule to make an n-electron wave function from λ at a geometry R [2].



We can compute the energy of this wave function in the usual way



We may formally view this as a function of λ (not any more a bilinear function) and rewrite it according to



This way all geometry dependence is in the Hamiltonian - the actual geometry dependence that comes from the motion of the nuclear charges and the geometry dependence that arises from the wave function expansion (e.g. motion of atom centered basis sets).

The above expression gives you the energy for any kind of expansion λ at any geometry R. Now in practice we will have some kind of a rule (or mapping) on how to create the wave function (e.g. MCSCF) at every geometry.



Now, the geometry dependent energy with respect to this rule is given according to:



Next we can compute the derivative of this expression with respect to a coordinate x in R (derivatives will be denoted with a superscript (x) or (λ)). This requires the use of the chain rule [3]



or with the definition from above



The first term evaluates the change in the Hamiltonian with the reference wave function. The second term is the gradient of the energy with respect to the expansion parameters multiplied with the change in expansion parameters.

If λ was determined in a completely variational way, then


The corresponding second term cancels and we arrive at the Hellmann-Feynman theorem.

The significance is that with a completely variational method, we do not have to worry about the response of the wave function to the geometrical perturbation and the formulas simplify. In real life MCSCF (and the special case SCF) is the expansion where this holds. For such a wave function the gradient comes directly from combining the density matrix (from last post) with the atomic derivative integrals. CI gradients are more complex because the orbitals are not optimal with respect to the CI expansion coefficients. And in coupled cluster not even the amplitudes are variational.



[1] R. Shepard. The Analytic Gradient Method for Configuration Interaction Wave Functions. in Modern electronic structure theory. 1995 ed. D.R. Yarkony

[2] Note that there are three types of coordinates: wave function coordinates λ, coordinates of the Hamiltonian R (I am thinking here mostly about the nuclear geometry but it could be anything else as well) and implicit electronic coordinates that I am not writing out.
- The λ in the wikipedia article corresponds to my R actually (I hope it is still understandable).
- A slightly tricky thing in this context is that in general the same λ can give a different wave function at a different geometry. This happens because atom centered basis sets move around in space with the atoms.

[3] The notation is kind of difficult with all these different types of coordinates (maybe not written in the optimal way here) but in principle this is a straight forward application of the chain rule. You could also do it with Taylor expansions truncated to first order - but chain rule is prettier ...

Tuesday, 20 October 2009

Density

Density matrices are not only nice for mathematical reasons, they also offer a stringent physical definition of orbitals. The point of this post is to show how you can create what is called "natural orbitals" from any kind of wave function. These things are also interesting with respect to orbital imaging (as introduced here and discussed for example here).

In order not to make any prior assumptions, I have to use general wave functions. In real life you would usually look at these things from the perspective of an orbital basis. And then the expressions would be simpler (maybe I will show that, too).

The one particle density matrix γ1 of an n-particle wave function Ψ is defined as:



This quantity is a "convenient partial sum". It lets you evaluate all the properties of 1-particle operators without the need of the whole wave function. This operation (in a finite orbital basis) is carried out in many quantum chemical codes.

Because the particles are interchangable you only need one such density matrix. (An n-particle density matrix which is analogously defined, lets you evaluate the matrix element of any n-particle operator.)

First we have to define what a one particle operator is. I think the most straight forward (and hopefully correct) definition ist the following:
An operator A is said to act only on r1 if


The idea is that you can do all the integrations with respect to the other variables ahead. You need some variable renaming to make sure that the operator only acts on the second function.

This contains already the density matrix



From the density matrix we can construct, what is called "natural orbitals" without the need of any a priory definition of an orbital basis.

Maybe it would be easier to understand it in the matrix representation but in the general case we can also define an operator of the following form.



We may also symmetrize it (again easier in cartesian coordinates; edit: the 1-particle density of a wave function is already symmetric). This symmetrized operator has clearly defined orthogonal 1-particle eigenfunctions, the so called "natural orbitals" (and occupation numbers as eigenvalues). The natural orbitals represent the 1-particle density matrix. And this one particle density matrix contains all the information needed for 1-particle operators (like e.g. the dipole). So natural orbitals are something kind of physcial in my opinion.

The eigenvalues of the density matrix are the occupations. In a Hartree-Fock wave function the natural orbitals correspond to the usual HF orbitals and the eigenvalue of occupied orbitals is one (zero for virtuals). The density matrix is idempotent (or equivalently a projection). In the general case there is no clear distinction between occupied and virtual orbitals and there is strictly spoken no such thing as a HOMO or LUMO. But then we notice that HF represents most wave functions quite well in "well behaved" cases. So you may still think about HOMOs and LUMOs even in a more strict sense.

Thursday, 23 July 2009

Marcus-Levich-Hush equation

Here is an interesting piece of math:





Or in other words show that in the Marcus-Levich-Hush theory, electron transfer stops when you approach zero temperature. Mathematica tells me that this is the case but I could not really show it. The problem has the following type:

It is not an apparent l'Hospital application and I do not really know what else to do. Anyway, I believe Mathematica and it is also the thing you'd expect physically.

In the full quantum picture you actually have a non-zero transfer rate even when approaching zero temperature that comes from nuclear tunneling (as was derived here and is reviewed here).

Interestingely it is quite easy to find derivations of this quantum formula. But I did not find much about the semi-classical formula, that is shown above. Only that it is some kind of application of Fermi's golden rule which apparently gives this prefactor for the rate equation.

Sunday, 31 May 2009

Antisymmetry

Antisymmetry, second quantization and things related to it are something I kind of stayed away so far. And now that I have finally taken a look at it, I notice how nice the math behind it actually is. And the important things that many things work in general and do not require orbitals.

We consider functions of the following form where A is some set and N a natural number[1]:



Let V be the vector space of all such functions. And let's look at operators [2] acting on V. First we could consider the Transposition operator





This is a well defined mapping and the application is straight forward, e.g.



And if you think about it some more you notice that it is linear.

And if I am correct it is both Hermitian and orthogonal with the usual skalar product. This would mean that all the eigenvalues are either 1 or -1. Either way, we are interested in the eigenspaces corresponding to the eigenvalue -1, i.e. functions that are antisymmetric with respect to the transposition. The intersection of all these eigenspaces VA is the set of functions that are antisymmetric with respect to all the transpositions. It is a vector space since it is formed as a intersection of vector spaces.



All fermion wave functions that comply with the Pauli principle have to be taken out of this space.

Next it helps to be a little bit more general and to introduce the permuation operator (related to a permuation σ out of the symmetric group SN) as a generalization of the transposition operator





This operator is also linear and I think also Hermitian and orthogonal.

Then you could write the antisymmetric space also like this



since every transposition is a permutation with negative sign and every permutation can be formed out of transpositions and the sign corresponds to how many you take.

Well let's define one more operator, the antisymmetrizer




You can show that this operator is a projection operator. This is equivalent to the condition that applying it twice is the same as applying it once, since the vector is already projected after the first time. The proof is also straight forward. Applying it twice leads to a double sum



But this just means that you sum n! times over all permutations, and it turns out


And next you could prove that the space it projects into, is just the VA we had before. You have to show that any projected function fullfils the condition for VA above and that every function which fullfills the condition remains unchanged which is both quite straight forward.


Maybe I should also add why these results are nice. I did have the expression for the Slater determinant before. But by considering that this is nothing but a (normalized) projection of an orbital product into the antisymmetric space it is easier to deal with it. It is no longer some weird expression but nothing but a linear operator. And things like adding Slater determinants are much clearer when you consider this. And that is why it is cool.

And actually as a next step you can consider commutation. These operators commute with the Hamiltonian because they are nothing but relabelling of equivalently treated electrons. Only for that reason you know that eingenfunctions of the Hamiltonian which are also antisymmetric even exist. You restrict the Hamiltonian eigenfunctions to the ones with a -1 eigenvalue of the antisymmetrizer. In the next step you may also do some restrictions according to spatial symmetry - the interacting spaces will transform like irreducible representations of the symmetry group. And finally spin. In the spin case the interacting spaces transform like representations of the unitary group (and I am kind of trying to understand why that is).



[1] Physically spoken N is the number of particles and A is the set of possible coordinates of the particle.

[2] As I probably said before: An operator is a function that makes a function out of a function. Or if you don't like the word "function", it is a mapping between two vector spaces.

Tuesday, 5 May 2009

exp(K)

It is time for some nice extra math, with some proofs and applications. I have two theorems that don't look obvious at first. And initially I kind of tried to avoid them.

The first one is that the matrix exponential of a real antisymmetric matrix is an orthogonal matrix with determinant +1

The second one is that for any matrix K (for example the anti-symmetric one from I) and a matrix A the following holds.


Or explicitely:


This is an expansion in the powers of K. And if K is small, you can cut it at some point. The reason why this is useful is that it gives you a direct possibility to manipulate orthogonal matrices. You don't have to worry about making the matrix orthogonal but you just choose any paramters for K and exp(K) will be orthogonal. II gives the possibility to carry out the basis transformation in an efficient way.


The first part of I is actually very straight forward if you write it down like this. It is provided that the limit of a transposed sequence is the transposition of the original limit and that the inverse is formed as shown.


I will prove the second part with the spectral theorem (maybe you can also do this in a more direct way). If we move into the complex space. K is now correctly spoken anti-Hermitian, and we know that a unitary matrix U exists which diagonalizes K. The eigenvalues of K are purely imaginary (yet quite important).


The exponential is given according to


At this point you can also notice that exp(K) is unitary because it is formed as a product of three unitary matrices.

Can we say anything about the determinant? Yes of course.


The determinants of the mutually inverse matrices UH and U cancel out. The determinant of a diagonal matrix is just the product of the diagonal terms.


The sum of the eigenvalues is the trace of K. In a real antisymmetric matrix all diagonal elements have to be zero (therefore also the trace).


And that is what we wanted to see.


The proof shows that exp(.) is a mapping between the set of real antisymmetric matrices and the set of real orthogonal matrices with determinant +1 (and of course that -exp(.) is the mapping to matrices with det=-1). In fact it would also be necessary to show that this mapping is bijective (i.e. that there is a 1:1 correspondence). This is apparently true but I don't think the proof is so simple. Interestingly it does not work with complex anti-Hermitian matrices. In this case there are n extra purely imaginary values in the diagonal. And the mapping is no longer injective for example:




Point I was the elegant part. Point II is more of the index juggling variety but a nice piece of complete induction. I will probably put that up soon, too.