ANALYSIS TOOL BOX

Linear Algebra

SolveSystemOfEquations

Solve and visualize a system of linear algebraic equations.

linear-algebramatricesvectorsdecomposition

Introduction

Where do a set of linear constraints — a budget limit, a resource cap, a supply-demand balance — actually agree with each other, if anywhere? SolveSystemOfEquations solves a system given its coefficient matrix and constants vector, checks the determinant to flag singular (unsolvable or redundant) systems, and for two-variable systems plots each equation as a line so you can see the solution as the point where they intersect.

Teaching Note

Solving and plotting systems of equations is essential for:

  • Finding intersection points of multiple linear constraints in business models
  • Analyzing market equilibrium in supply and demand economics
  • Determining unique solutions for multi-variable experimental datasets
  • Identifying redundant or inconsistent constraints in optimization problems
  • Modeling resource allocation and balanced production planning
  • Visualizing decision boundaries for simple linear classification tasks
  • Assessing system stability through determinant analysis

Parameters

ParameterTypeDefaultDescription
coefficientsrequiredA matrix containing the coefficients of the variables in the system. Expected as a nested list or a square 2D numpy.ndarray.
constantsNoneA 1D array or list representing the constants on the right-hand side of the equations. If None, it defaults to a zero vector (homogeneous system).
show_plotTrueWhether to generate a 2D visualization of the equations. Only applicable for systems with exactly two variables. Defaults to True.
plot_boundary10The range (from -value to +value) used for the x-axis in the plot. Defaults to 10.

Returns

None — the function prints the determinant and solution to the console and displays a plot if requested and applicable.

Example

python
from analysistoolbox.linear_algebra import SolveSystemOfEquations

# Solve a 2x2 system: 2x + 1y = 10 and 1x - 1y = 2
coeffs = [[2, 1], [1, -1]]
consts = [10, 2]
SolveSystemOfEquations(coeffs, consts)