Maths & numbers

Vector partition count calculator for nonnegative integer solutions

Vector partition counting asks how many nonnegative integer vectors x satisfy Ax=b.

Your numbers

One comma-separated row per line.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Vector partition counting asks how many nonnegative integer vectors x satisfy Ax=b. Each column of A describes one allowed contribution to several target coordinates. The coefficients x count how many copies of those column types are used,so the problem generalizes coin counting to simultaneous requirements.

THE FORMULACount x∈Z≥0^k such that A x=b;F(j,b)=sum_t F(j+1,b−t a_j).

A worked example

For columns(1,0),(0,1),(1,1) and target(4,3),the third multiplicity ranges0–3,giving4 solutions.

Good to know

Nonnegative integer A≤3×8 and matching target,entries0–50;no zero columns,2-million recursion-call cap;exact count,at most20 witnesses.

A vector target imposes several resource equations

Vector partition counting asks how many nonnegative integer vectors x satisfy Ax=b. Each column of A describes one allowed contribution to several target coordinates. The coefficients x count how many copies of those column types are used,so the problem generalizes coin counting to simultaneous requirements.

This is not a probability calculation and does not count arbitrary orderings of chosen pieces. A solution vector is counted once. Columns are labeled variables:if two columns are identical,the corresponding variables are still distinct,and exchanging their counts can produce a different solution vector.

Vector partitions with simultaneous nonnegative targets0123x₁=4−x₃x₂=3−x₃0 ≤ x₃ ≤ 3Four multiplicity vectors
Scroll across to see the full diagram.
For columns(1,0),(0,1),(1,1) and target(4,3),the third multiplicity ranges0–3,giving4 solutions.

Compare this with the Integer matrix contingency table count calculator from margins. Count nonnegative x satisfying a general bounded Ax=b,not only row/column-margin tables or one-dimensional compositions.

Nonnegative data keep the search finite

The interface accepts up to three rows and eight columns,with nonnegative integer entries and a matching nonnegative target. A zero column is rejected because its variable could increase without affecting any target coordinate,giving infinitely many solutions whenever the remaining equations are feasible.

At least one positive entry in each column supplies a finite upper bound on that variable. Negative generator entries are outside this interface because cancellation can destroy that simple finiteness argument. A solver for arbitrary integer kernels needs additional boundedness analysis rather than this counting recurrence.

Count suffix problems with memoization

At a column,the algorithm tries every multiplicity that keeps all residual target coordinates nonnegative. It then counts solutions using the remaining columns and the reduced target. The terminal case contributes one exactly when every target coordinate has been exhausted,otherwise it contributes zero.

Many choices reach the same remaining-column and residual-target state. Memoization reuses those exact counts instead of repeating the entire subtree. Counts are stored as arbitrary-size integers;the number of states and recursive calls is bounded separately to protect the interactive calculation from excessive work.

A generating-function interpretation

The coefficient of the target monomial in the product of geometric factors,one for each column,is the same count. Each factor selects a nonnegative multiplicity of that generator. This explains why types are unordered in time while column labels remain part of the combinatorial specification.

The implementation uses the recurrence directly rather than expanding a large symbolic generating function. Both viewpoints describe the same bounded nonnegative problem. The result does not claim to compute a chamber decomposition,an asymptotic quasipolynomial or the full vector partition function for every possible right-hand side.

Four ways to meet the example target

For columns (1,0),(0,1),(1,1) and target (4,3),the equations are x1+x3=4 and x2+x3=3. Choosing x3 from zero through three determines the other coordinates. The four solutions are (4,3,0),(3,2,1),(2,1,2) and(1,0,3).

The example has no additional permutations for arranging contributions in a sequence. If the task were counting ordered words of generator types,each solution would carry a multinomial ordering factor. That is another combinatorial question,and adding those factors would change the meaning of the displayed count.

Witnesses help inspect a large exact total

The page displays up to twenty solution vectors alongside the exact total. Each witness can be substituted into Ax=b. The complete-witness-list flag distinguishes a full enumeration from a sample when the count exceeds twenty;it never implies that twenty is the total merely because twenty rows are visible.

A zero target has the all-zero solution because zero columns are forbidden and entries are nonnegative. Some positive targets have no solution even when each coordinate separately looks attainable. The coupled equations,not independent one-dimensional coin counts,determine feasibility and the exact result.

Model the columns before trusting the answer

Combine duplicate columns only if the associated variables are intended to be indistinguishable types. Otherwise that simplification changes the count. Also check units across each row:one coordinate might represent mass and another a component count,but every entry within a row must use a consistent scale.

The resource cap raises an explicit unfinished-count error instead of returning a partial integer as the answer. For a successful result,the recurrence has completed. Save the matrix,target,column interpretation and witness flag together so a later comparison uses the same notion of a solution.

A few questions, answered

Why reject a zero column?

Its nonnegative multiplicity would be unbounded without changing the target,causing infinitely many solutions whenever feasible.

Are identical columns interchangeable?

They are separate labeled variables here. Combining them changes the count unless the model intends indistinguishable types.

Are arrangements in a sequence counted?

No. Each multiplicity vector is counted once,without an extra multinomial ordering factor.

Does twenty visible witnesses mean twenty solutions?

Only when the exact count and complete-witness flag say so;otherwise twenty is a display sample.

Find your calculator

Start typing to explore the library.