Skip to content

Symbolic calculation of non-commutative algebraic expressions with Haskell

License

Notifications You must be signed in to change notification settings

pelagisk/algebras-for-physicists

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HaskellForMaths, use case for theoretical physicists

Introduction

Often in theoretical physics, one needs to calculate commutators of complicated symbolic expressions in some non-commuting algebra. It is useful to be able to check calculations done by hand, and it should be a routine task anyway. This example code shows how one can use Haskell code to define and calculate in such algebras with the normal background of a working theorist.

Note that this is a use case! I have not written the library behind all the math, I'm just connecting the dots for physicists interested in using the library for practical calculations!

Installation

First, install Haskell and its build system Cabal through the Haskell Platform.

Second, if you at any time feel the need to read up on Haskell (you may skip this step for now), I recommend this introduction and this blog. You will not be disappointed.

Third, install the excellent package HaskellForMaths:

cabal update
cabal install haskellformaths

To learn more about Haskell and mathematics, check out the accompanying blog. There are a lot of other interesting things to be learnt from Haskell for physicists and mathematicians.

Use case

To use the algebra of Pauli matrices and the identity matrix, for example to calculate the equations of motions of some Hamiltonian, is simple. From the terminal:

ghci

and then write

:load SU2.hs
let [j, h] = map var ["j", "h"]
let hamiltonian = j *> sx + h *> sz
let comm [x, y] = x * y - y * x
let eom o = i *> comm [hamiltonian, o]
eom sy

To define your own algebra, follow the pattern in these files.

Credits

I want to thank David Amos and the Haskell community for helpful discussions and help with these basic things.

License

BSD3 License, see the file LICENSE

Author

Axel Gagge 2017. The library is written by David Amos and licensed under a BSD3 License.

About

Symbolic calculation of non-commutative algebraic expressions with Haskell

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published