Skip to content

Bosonic statistics second quantization - #1

Merged
BrunoQNF merged 28 commits into
mainfrom
bosonic-statistics
Aug 4, 2026
Merged

BrunoQNF merged 28 commits into
mainfrom
bosonic-statistics

Conversation

@BrunoQNF

@BrunoQNF BrunoQNF commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Refactor SecondQuantization module + add bosonic symbolic algebra tools

Summary

  • Splits SecondQuantization.m (511 lines) into six focused sub-modules under Kernel/SecondQuantization/, improving maintainability and making individual components easier to load, test, and extend.
  • Adds new public API for symbolic bosonic algebraBosonicNormalOrder, BosonicBCHTerms, BosonicZassenhausTerms, BosonicBCHExact, BosonicRelations, BosonVEV, and BosonicMatrixElement — all exported from the SecondQuantization context.
  • Adds two exploratory notebooks (BosonicNormalOrder.nb, BosonicBCH_Zassenhaus.nb) demonstrating the new tools.

Module split

The old SecondQuantization.m is replaced by:

File Responsibility
Utils.m $FockSize, SetFockSpaceSize, FieldVariables, OrderVariables, G1Correlation, G2Coherence
States.m FockState, CoherentState, ThermalState, CatState
Operators.m AnnihilationOperator, DisplacementOperator, SqueezeOperator, QuadratureOperators, BeamSplitterOperator, PhaseShiftOperator
PhaseSpaceRepresentations.m WignerRepresentation, HusimiQRepresentation, WignerFunction, HusimiQFunction
BlasiakFormula.m Internal BlasiakNormalOrder / MultiModeBlasiakOrder engine
BosonicAlgebra.m All new symbolic bosonic algebra exports (see below)

New symbolic algebra API

  • BosonicRelations[vars] — constructs the canonical bosonic commutation relations for a given list of mode operators.
  • BosonicNormalOrder[expr, vars] — brings an operator expression into normal order; supports Method -> "GrobnerBasis" (default, via NonCommutativePolynomialReduce) or Method -> "Blasiak" (Blasiak combinatorial engine for pure bosonic polynomial moments), and "Scalars" -> syms.
  • BosonicBCHTerms[X, Y, n] / BosonicZassenhausTerms[X, Y, n] — BCH / Zassenhaus expansions to n th term reduced with bosonic algebra.
  • BosonicBCHExact[X, Y] — closed-form exact BCH cases for exponentials.
  • BosonVEV[expr, vars] / BosonicMatrixElement[{m, n}, op] — vacuum expectation values and Fock matrix elements.

Notes

  • NCA compatibility update for Mathematica v15 is included.

BrunoQNF and others added 19 commits May 11, 2026 19:32
Following WFR implementations in a wrapper way for bosonic commutations relations
Separating the context in files. Added bosonic symbolic algebra functions. Added a loader file to ensure SecondQuantization context loads properly.
Context was seperated in different files
States.m: Adding label to states for circuit display. PhaseSpaceRepresentations.m: Adding symbolic Wigner and HusimiQ.
Closed form for some cases where the bosonic algebra closes
Improvement in FieldVariables for handling different formal symbol variables (not limited to same label). Ease of use of the infinity parameter for DisplacementOperator, both signatures use different ordering as default. In BosonicAlgebra.m added BosonicVEV for vacuum expectation values, and BosonicMatrixElement for the m,n element of Displacement and Squeeze operators.
@BrunoQNF
BrunoQNF marked this pull request as ready for review June 10, 2026 22:20
BrunoQNF and others added 9 commits June 17, 2026 11:46
Fixing bug for multi-mode Fock state. Improved usage messages format for states, utils and operators. Added covariance matrix function for single and multi-mode if n modes are involved a 2n x 2n matrix is returned.
Exponential normal ordering of bosonic ladder operators, intented to replace in the future the result of BosonicBCHExact. Also included mixed Exp-poly forms.
Fixing variable format in ExpBosonSimplify.m . Adding in Utils.m the function ToBosonicOperator that given the symbolic expression representing ladder operators returns the QuantumOperator with some cutoff size.
Introduce BosonicAntiNormalOrder, which brings a bosonic polynomial into anti-normal order (annihilators left of creators) via either method. OrderVariables now takes a direction argument, so grobnerNormalOrder reaches anti-normal order by reversing the generator order; the no-scalars branch passes an explicit NonCommutativeAlgebra with the ordered generators. The Blasiak path instead conjugates the normal-ordering formula with the automorphism a -> a^dagger, a^dagger -> -a, mapping back afterwards.

That conjugation puts signs and coefficients in front of ladder monomials, which ParseBlasiakMonomial could not read, so MultiModeBlasiakOrder now lifts commuting coefficients out of generalized powers and ** products through the new LiftNCScalars scope function and flattens Times/NonCommutativeMultiply before splitting factors; the badfactor message also reports the offending factor instead of an undefined symbol. In ExpBosonSimplify.m, algA carries both generators (algAdag is gone), the squeeze rule absorbs Sqrt[Sec] into Exp[Log[Sec] (1/2 + a^dagger a)], the displacement shift rules normal-order their shifted polynomial, and NormalOrdered gains series expansions in an explicit parameter (symbolic order or truncated), monomial canonicalization for polynomial arguments, and a Times upvalue. Tests/SecondQuantization/Antinormal.wlt covers the new ordering: known single- and two-mode results, structural and round-trip invariants, scalar coefficients, method agreement, unknown-method failure, and a truncated Fock matrix realization check.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ExpBosonSimplify.m: in the two-mode cross-term rule for
Exp[alpha a**b^dagger + beta a^dagger**b], multiply the two
Cosh[Omega]^(-/+ n) factors together instead of chaining them with **,
so the number-operator exponents collapse into a single
Cosh[Omega]^(-a^dagger**a + b^dagger**b) in the normal-ordered result.

Tests/SecondQuantization/ExpBosonOrder.wlt: 40 VerificationTests ported
from TestsExpSimplify.nb, covering number-operator exponentials, Weyl
disentangling of linear ladder combinations, SU(1,1) two-photon
disentangling and the squeezing conventions, shift rules on
exponential-polynomial products, generalized normal ordering
(Blasiak-Penson-Solomon), the "Series" coefficient generators and their
truncations, and the two-mode squeezer and beam-splitter generators.
ExpBosonOrder gains an "Ordering" option ("Normal" default, "AntiNormal"),
backed by rulesAN: the image of rulesNO under a -> a^dagger, a^dagger -> -a.
AntiNormalOrdered is exported alongside NormalOrdered and shares its "Series"
and polynomial-expansion code, now factored through orderedMonomial,
orderedSeries and ladderPolynomialQ so both orderings run the same paths.

BlasiakFormula is rewritten in functional style: blasiakCoefficient replaces
the cached srs closures, ParseBlasiakMonomial uses Split over the imperative
block accumulator, and MultiModeBlasiakOrder groups scalar factors instead of
double-Select. BlasiakNormalOrder now validates its exponent vectors and
messages on bad input. Adds Tests/SecondQuantization/ExpBosonAntiOrder.wlt.
@BrunoQNF
BrunoQNF merged commit 76000cf into main Aug 4, 2026
1 check passed
@BrunoQNF
BrunoQNF deleted the bosonic-statistics branch August 4, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants