Did you know ... Search Documentation:
Pack starlog -- PARAMETRIC_SYSTEM_SOLUTION.md

Parametric System Solution

Problem Statement

Solve the system parametrically:

2x₁ + 0x₂ + 3x₃ = 2
3x₁ + 0x₂ + 0x₃ = 1
0x₁ + 0x₂ + 2.25x₃ = 1

Expected infinite solutions: (x₁, x₂, x₃) = (1/3, t, 4/9) where t is a free parameter.

Solution

Mathematical Analysis

This system has infinite solutions because variable x₂ has a zero coefficient in all three equations, making it a free parameter.

From the equations:

  • Equation 2: `3x₁ = 1 → x₁ = 1/3`
  • Equation 3: `2.25x₃ = 1 → x₃ = 1/2.25 = 4/9`
  • Equation 1: `2(1/3) + 3(4/9) = 2/3 + 4/3 = 2` ✓
  • x₂ can take any value (free parameter t)

Implementation

The solution was implemented by:

  1. Created demo_parametric_system.pl: A demonstration file that shows how to solve this specific parametric system and verifies the solution.
  2. Fixed gaussian_elimination.pl: Improved the detect_solution_type/3 predicate to correctly identify infinite solutions when variables lack pivots (leading coefficients):
    • Added count_variables_with_pivots/3 helper function
    • Changed from counting non-zero rows to counting variables with pivots
    • A variable without a pivot in any row is a free parameter
  3. Added test case: Added test_parametric_system to tests/test_gaussian_elimination.pl to verify the solution.
  4. Updated documentation:
    • Added parametric system example to GAUSSIAN_ELIMINATION.md
    • Updated algorithm description to reflect improved detection logic
    • Added example to GAUSSIAN_QUICK_REF.md

Usage

:- use_module(gaussian_elimination).

?- solve_system([[2, 0, 3, 2], [3, 0, 0, 1], [0, 0, 2.25, 1]], Solution, Type).
Type = infinite,
Solution = [0.3333333333333333, _FreeVar, 0.4444444444444445].

The solution shows:

  • `x₁ = 0.333... = 1/3`
  • x₂ = _FreeVar (unbound variable representing free parameter t)
  • `x₃ = 0.444... = 4/9`

Verification

Running demo_parametric_system.pl:

swipl -s demo_parametric_system.pl

Output confirms:

  • Solution type: infinite
  • Solution values: (1/3, t, 4/9)
  • All three equations satisfied ✓

Key Improvements

The main improvement was fixing the solution type detection algorithm:

Before: Counted non-zero rows vs number of variables

  • Problem: A system like ours has 3 non-zero rows and 3 variables, so it was incorrectly marked as "unique" After: Counts variables with pivots
  • Each variable is checked to see if it has a leading coefficient (pivot) in some row
  • Variables without pivots are free parameters → infinite solutions
  • In our case: x₁ and x₃ have pivots, but x₂ does not → infinite solutions ✓ This fix ensures proper detection of parametric systems where some variables have zero coefficients throughout.