ANALYSIS TOOL BOX

Linear Algebra

ConvertSystemOfEquationsToMatrix

Construct an augmented matrix from a system of linear equations.

linear-algebramatricesvectorsdecomposition

Introduction

Most linear algebra algorithms expect a matrix, not a list of algebraic equations — so before you can solve a system of constraints programmatically, you need to translate "2x + 3y = 8" style equations into coefficients and constants. ConvertSystemOfEquationsToMatrix does that translation, combining a coefficient matrix with a constants vector into a single augmented matrix, and optionally reports the determinant so you immediately know whether the system has a unique solution (non-zero determinant) or is singular — dependent or inconsistent equations (zero determinant).

Teaching Note

Converting equations to matrices is essential for:

  • Formulating linear regression models and finding optimal coefficients
  • Modeling resource allocation and budget constraints for business planning
  • Evaluating the consistency of multi-variable economic or financial models
  • Preparing structural data for high-performance optimization solvers
  • Analyzing the sensitivity of output variables to changes in input parameters
  • Solving complex supply chain and production capacity equations
  • Identifying over-determined or under-determined systems in experimental data

Parameters

ParameterTypeDefaultDescription
coefficientsrequiredThe coefficients of the variables in the system of equations. Can be a nested list or a square 2D numpy.ndarray.
constantsrequiredThe constant values (right-hand side) of the equations. Can be a list or a 1D numpy.ndarray.
show_determinantTrueWhether to calculate and print the determinant and system status (singular vs. non-singular). Defaults to True.

Returns

A NumPy array — the augmented matrix combining coefficients and constants.

Example

python
from analysistoolbox.linear_algebra import ConvertSystemOfEquationsToMatrix

# Convert a system of 2 equations: 2x + 3y = 8 and 1x - 1y = 2
coeffs = [[2, 3], [1, -1]]
consts = [8, 2]
augmented = ConvertSystemOfEquationsToMatrix(coeffs, consts)