Git Product home page Git Product logo

haarpy's Introduction

Haarpy is a Python library for the symbolic calculation of Weingarten functions and related averages of unitary matrices $U(d)$ sampled uniformly at random from the Haar measure.

The original Mathematica version of this code, for the calculation of Weingarten functions of the unitary group, can be found here.

Haarpy in action

The main functions of Haarpy are weingarten_class and weingarten_element allowing for the calculation of Weingarten functions. These functions vary in their parameters. We recommend importing the following when working with Haarpy.

from sympy import Symbol
from sympy.combinatorics import Permutation

d = Symbol("d")

weingarten_class

Takes a partition, labeling a conjugacy class of $S_p$, and a dimension $d$ as arguments. For the conjugacy class labeled by partition $\lbrace 3,1\rbrace$, the function returns

from haarpy import weingarten_class
weingarten_class((3,1),d)
(2*d**2 - 3)/(d**2*(d - 3)*(d - 2)*(d - 1)*(d + 1)*(d + 2)*(d + 3))

The previous can also be called with integer values as such

weingarten_class((3,1),4)
29/20160

weingarten_element

Takes an element and the degree $p$ of the symmetric group $S_p,$ and a dimension $d$ as arguments, the conjugacy class being obtained from the first two.

from haarpy import weingarten_element
weingarten_element(Permutation(0,1,2), 4, d)
(2*d**2 - 3)/(d**2*(d - 3)*(d - 2)*(d - 1)*(d + 1)*(d + 2)*(d + 3))

Which yields the same result as before since $\lbrace 3,1\rbrace$ is the class of permutation $(0,1,2)$ in $S_4$.

Auxiliary functions include, but are not limited to, the following. For a comprehensive list of functionalities, please refer to the documentation.

murn_naka

Implementation of the Murnaghan-Nakayama rule for the characters irreducible representations of the symmetric group $S_p$. Takes a partition characterizing an irrep of $S_p$ and a conjugacy class and yields the associate character.

from haarpy import murn_naka
murn_naka((3,1), (1,1,1,1))
3

get_class

Returns the class of a given element of $S_p$ when given the order and the element.

from haarpy import get_class
get_class(Permutation(0,1,2), 4)
(3,1)

sn_dimension

Takes a partition labeling an irrep of $S_p$ and returns the dimension of this irrep.

from haarpy import sn_dimension
sn_dimension((5,4,2,1,1,1))
63063

ud_dimension

Takes a partition labeling an irrep of the unitary group $U(d)$, as well as the dimension $d$, and returns the dimension of this irrep.

from haarpy import ud_dimension
ud_dimension((5, 4, 2, 1, 1, 1),d)
d**2*(d - 5)*(d - 4)*(d - 3)*(d - 2)*(d - 1)**2*(d + 1)**2*(d + 2)**2*(d + 3)*(d + 4)/1382400

Which can also be done numerically.

ud_dimension((5, 4, 2, 1, 1, 1),8)
873180

Tables of Weingarten functions for $n \le 5$

The following have been retrieved using the weingarten_class function. Weingarten functions of symmetric groups of higher degrees can just as easily be obtained.

Symmetric group $S_2$

Class Weingarten
$\lbrace2\rbrace$ $-\displaystyle\frac{1}{(d-1) d (d+1)}$
$\lbrace1,1\rbrace$ $\displaystyle\frac{1}{(d-1)(d+1)}$

Symmetric group $S_3$

Class Weingarten
$\lbrace 3\rbrace$ $\displaystyle\frac{2}{(d-2) (d-1) d (d+1) (d+2)}$
$\lbrace 2,1\rbrace$ $-\displaystyle\frac{1}{(d-2) (d-1) (d+1) (d+2)}$
$\lbrace 1,1,1\rbrace$ $\displaystyle\frac{d^2-2}{(d-2) (d-1) d (d+1) (d+2)}$

Symmetric group $S_4$

Class Weingarten
$\lbrace 4\rbrace$ $-\displaystyle\frac{5}{(d-3) (d-2) (d-1) d (d+1) (d+2) (d+3)}$
$\lbrace 3,1\rbrace$ $\displaystyle\frac{2 d^2-3}{(d-3) (d-2) (d-1) d^2 (d+1) (d+2) (d+3)}$
$\lbrace 2,2\rbrace$ $\displaystyle\frac{d^2+6}{(d-3) (d-2) (d-1) d^2 (d+1) (d+2) (d+3)}$
$\lbrace 2,1,1\rbrace$ $-\displaystyle\frac{1}{(d-3) (d-1) d (d+1) (d+3)}$
$\lbrace 1,1,1,1\rbrace$ $\displaystyle\frac{d^4-8 d^2+6}{(d-3) (d-2) (d-1)d^2 (d+1) (d+2)(d+3)}$

Symmetric group $S_5$

Class Weingarten
$\lbrace 5\rbrace$ $\displaystyle\frac{14}{(d-4) (d-3) (d-2) (d-1) d (d+1) (d+2) (d+3)(d+4)}$
$\lbrace 4,1\rbrace$ $\displaystyle\frac{24-5 d^2}{(d-4) (d-3) (d-2) (d-1) d^2 (d+1) (d+2)(d+3)(d+4)}$
$\lbrace 3,2\rbrace$ $-\displaystyle\frac{2 \left(d^2+12\right)}{(d-4) (d-3) (d-2) (d-1)d^2(d+1)(d+2)(d+3)(d+4)}$
$\lbrace 3,1,1\rbrace$ $\displaystyle\frac{2}{(d-4) (d-2) (d-1) d (d+1) (d+2) (d+4)}$
$\lbrace 2,2,1\rbrace$ $\displaystyle\frac{-d^4+14 d^2-24}{(d-4) (d-3) (d-2) (d-1) d^2 (d+1) (d+2) (d+3) (d+4)}$
$\lbrace 1,1,1,1,1\rbrace$ $\displaystyle\frac{d^4-20 d^2+78}{(d-4) (d-3) (d-2) (d-1) d (d+1) (d+2) (d+3) (d+4)}$

Installation

Haarpy requires Python version 3.9 or later. Installation can be done through the pip command

pip install haarpy

Compiling from source

Haarpy has the following dependencies:

Documentation

Haarpy documentation is available online on Read the Docs.

How to cite this work

Please cite as:

@misc{cardin2024haarpy,
  author={Cardin, Yanic and de Guise, Hubert and Quesada, Nicol{\'a}s},
  title={Haarpy, a Python library for the symbolic calculation of Weingarten functions},
  year={2024},
  publisher={GitHub},
  journal={GitHub repository},
  howpublished = {\url{https://github.com/polyquantique/haarpy}},
  version = {0.0.4}
}

Authors

  • Yanic Cardin, Hubert de Guise, Nicolás Quesada.

License

Haarpy is free and open source, released under the Apache License, Version 2.0.

haarpy's People

Contributors

nquesada avatar yaniccd avatar sduquemesa avatar

Stargazers

 avatar

haarpy's Issues

Adding links to wikipedia

Many of the technical terms that appear on the readme are nicely explained in wikipedia. It would be nice to add links to those entries.

n=5,6 weingarten elements are not orthogonal to character functions

I seem to see there is a bug with n=5,6 weingarten functions not being orthogonal to their associated character functions for the symmetric group, as below. Individual weingarten functions appear correct as per your README, and I may be mistaken, thank you!

The code:

from sympy import Symbol,simplify
from sympy.combinatorics.named_groups import SymmetricGroup
from haarpy import weingarten_element

N = [2,3,4,5,6]
d = Symbol('d')

group = lambda n: SymmetricGroup(n).generate_schreier_sims()
character = lambda g,d,n: d**(g.cycles)
weingarten = lambda g,d,n: weingarten_element(g,n,d)

for n in N:
	orthogonality = sum(character(g,d,n)*weingarten(g,d,n) for g in group(n))
	print(n,simplify(orthogonality))

yields the following for different n (the inner product of character and weingarten functions over the group should be 1, for all n):

2 1
3 1
4 1
5 (d**5 - 5*d**3 + 4*d + 4)/(d*(d**4 - 5*d**2 + 4))
6 (3*d**9 - 45*d**7 + 189*d**5 + 71*d**4 - 255*d**3 - 341*d**2 + 108*d + 126)/(3*d*(d**8 - 15*d**6 + 63*d**4 - 85*d**2 + 36))

Removing numpy dependency

It seems like the need for numpy in haarpy is not fundamental. Would be nice, if possible, to remove this dependency.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.