Bosonic statistics second quantization - #1
Merged
Merged
Conversation
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
marked this pull request as ready for review
June 10, 2026 22:20
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor
SecondQuantizationmodule + add bosonic symbolic algebra toolsSummary
SecondQuantization.m(511 lines) into six focused sub-modules underKernel/SecondQuantization/, improving maintainability and making individual components easier to load, test, and extend.BosonicNormalOrder,BosonicBCHTerms,BosonicZassenhausTerms,BosonicBCHExact,BosonicRelations,BosonVEV, andBosonicMatrixElement— all exported from theSecondQuantizationcontext.BosonicNormalOrder.nb,BosonicBCH_Zassenhaus.nb) demonstrating the new tools.Module split
The old
SecondQuantization.mis replaced by:Utils.m$FockSize,SetFockSpaceSize,FieldVariables,OrderVariables,G1Correlation,G2CoherenceStates.mFockState,CoherentState,ThermalState,CatStateOperators.mAnnihilationOperator,DisplacementOperator,SqueezeOperator,QuadratureOperators,BeamSplitterOperator,PhaseShiftOperatorPhaseSpaceRepresentations.mWignerRepresentation,HusimiQRepresentation,WignerFunction,HusimiQFunctionBlasiakFormula.mBlasiakNormalOrder/MultiModeBlasiakOrderengineBosonicAlgebra.mNew 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; supportsMethod -> "GrobnerBasis"(default, viaNonCommutativePolynomialReduce) orMethod -> "Blasiak"(Blasiak combinatorial engine for pure bosonic polynomial moments), and"Scalars" -> syms.BosonicBCHTerms[X, Y, n]/BosonicZassenhausTerms[X, Y, n]— BCH / Zassenhaus expansions tonth 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