Skip to content

Main content

Random Positive-Definite Matrix Generator

Generate an integer matrix A and construct A-transpose A plus a supplied positive diagonal shift using existing matrix tools, then verify Cholesky and report a relative reconstruction residual; shifts lost to floating-point conditioning return a structured failure.

Loading tool…

Description

Generate an integer matrix A and construct A-transpose A plus a supplied positive diagonal shift using existing matrix tools, then verify Cholesky and report a relative reconstruction residual; shifts lost to floating-point conditioning return a structured failure.

A matrix construction produces numeric arrays with a target algebraic property. Floating-point residuals check how closely a computed result satisfies that property, while conditioning determines how sensitive it is to numerical error.

Generate an integer matrix A and construct A-transpose A plus a supplied positive diagonal shift using existing matrix tools, then verify Cholesky and report a relative reconstruction residual; shifts lost to floating-point conditioning return a structured failure.

When to use this tool

Use this generator to create reproducible positive definite matrix cases from the supplied model or bank. Inspect the returned evidence before using cases in a test or exercise.

How to use the tool and how it works

  1. Supply size, minimumInteger, maximumInteger, diagonalShift in the field shapes below. Set seed when you need an explicit replay.
  2. Run the tool and correct any input error. For generated controls, distinguish a successful fixture containing an invalid case from failure to generate the fixture.
  3. Read source, matrix, lower, relativeReconstructionError. Use the conventions below and keep answer-bearing fields separate when presenting an exercise.

Draw a square integer matrix A, construct A-transpose times A plus diagonalShift times the identity, and verify a Cholesky factor. Return the factor and maximum absolute reconstruction difference after dividing both matrices by their maximum absolute matrix entry. The residual is scaled entrywise maximum error, not a matrix norm divided by a norm.1

Delegated operations used for this result: transpose; multiply. Their calculation or parsing conventions apply to the corresponding result fields.2, 3

Input fieldMeaning and unitsAccepted input
sizeSizeRequired. Safe integer; minimum 1; maximum 16.
minimumIntegerMinimum IntegerRequired. Safe integer.
maximumIntegerMaximum IntegerRequired. Safe integer.
diagonalShiftDiagonal ShiftRequired. Finite number; strictly above 0.
seedOptional numeric seed; takes precedence over context randomness. Without either, use the fixed tool.io default seed.Optional. Safe integer.
Output fieldInterpretationReturned shape
sourceSourceRequired. Array of Array of Finite number.; minimum items 1; maximum items 16.; minimum items 1; maximum items 16.
matrixMatrixRequired. Array of Array of Finite number.; minimum items 1; maximum items 16.; minimum items 1; maximum items 16.
lowerLowerRequired. Array of Array of Finite number.; minimum items 1; maximum items 16.; minimum items 1; maximum items 16.
relativeReconstructionErrorRelative Reconstruction ErrorRequired. Finite number; minimum 0.
randomnessReplay metadata: source is seed or context; seed is the normalized 32-bit seed or null for a context source.Required. Object; no unknown keys.
randomness.seedOptional numeric replay seed; normalization and precedence are explained below.Required. Safe integer. or Null.
randomness.sourceSourceRequired. Text; one of "context", "seed".

An explicit safe-integer seed takes precedence over injected context randomness and is normalized to an unsigned 32-bit integer. With no seed and no context source, replay uses the fixed tool.io default seed. A context source must return finite values from zero inclusive to one exclusive; its advancing state must be retained separately. randomness records the source and normalized seed, or null for context. These generators are not cryptographic random sources.

json
{
  "input": {
    "size": 2,
    "minimumInteger": -2,
    "maximumInteger": 3,
    "diagonalShift": 2,
    "seed": 42
  },
  "output": {
    "source": [
      [
        1,
        0
      ],
      [
        3,
        2
      ]
    ],
    "matrix": [
      [
        12,
        6
      ],
      [
        6,
        6
      ]
    ],
    "lower": [
      [
        3.4641016151377544,
        0
      ],
      [
        1.7320508075688774,
        1.7320508075688772
      ]
    ],
    "relativeReconstructionError": 1.1102230246251565e-16,
    "randomness": {
      "seed": 42,
      "source": "seed"
    }
  }
}

Limitations and assumptions

  • The mathematical positive shift must survive floating-point arithmetic. A lost shift or failed Cholesky returns numerical_cholesky_failure; positive definiteness does not imply good conditioning or a prescribed eigenvalue distribution.
  • A replay requires the same complete input and implementation. Randomized construction does not guarantee uniform coverage of every feasible output; finite samples can repeat unless a distinct-selection rule is explicitly stated.
  • The field tables state structural bounds; cross-field constraints and bounded search or output budgets also apply. Unknown keys are rejected where the object contract disallows them. Input errors are distinct from null fields and deliberate invalid controls in a successful output.

Alternative or Complementary methods

For a supplied example, inspect the returned construction or delegated check directly. To evaluate a consumer, also test cases chosen for its own boundaries; a generated finite corpus does not establish exhaustive coverage.

References

  1. Tool behavior and example: Random Positive-Definite Matrix Generator — tool.io

  2. Calculation or validation: matrix/transpose — tool.io

  3. Calculation or validation: matrix/multiply — tool.io

Similar or alternative tools

  • Random Matrix Row Operation Trace Generator

    Generate elementary row-operation traces with exact safe-integer intermediate matrices and delegated determinants inheriting 12-significant-digit core rounding.

  • Random Orthogonal Matrix Generator

    Generate an integer source matrix, scale it safely and reuse Householder QR for an orthogonal factor with a caller-bounded Q-transpose-Q residual; rank-deficient and zero sources use the core's deterministic completion, not Haar-uniform sampling.