Project 13: The Inequalities and Absolute Value Region Analyzer

Build a solver/visualizer that converts inequality constraints into intervals and feasible regions with explicit boundary semantics.

Quick Reference

Attribute Value
Difficulty Intermediate (Level 2)
Time Estimate 6-12 hours
Main Programming Language Python
Alternative Programming Languages R, Julia, JavaScript
Key Topics Linear inequalities, absolute value, interval notation, feasible sets
Input Mode CLI constraint strings
Output Mode Interval report + number-line/2D region images

1) Learning Objectives

  1. Solve one-variable inequalities and express solutions as intervals.
  2. Translate absolute value constraints into piecewise inequalities.
  3. Distinguish strict (<) vs inclusive (<=) boundaries in both math and plots.
  4. Build a 2D feasible region from multiple linear constraints.
  5. Validate solver outputs with point-membership tests.

2) All Theory Needed (Per-Concept Breakdown)

Concept A: Inequalities as Sets

Inequality solutions are sets of values, not single values. The same symbolic result should map to interval notation and geometric representation. Union/intersection operations become first-class logic for combined constraints.

Concept B: Absolute Value as Distance

|x-a| < r means distance from a is less than r, producing an interval around a. |x-a| > r creates two outside intervals. This distance view prevents sign mistakes and supports consistent implementation.

Concept C: Boundary Semantics

A boundary can be open or closed depending on the operator. Boundary inclusion affects both mathematical correctness and rendered outputs. A robust solver stores inclusivity flags explicitly.

3) Project Specification

3.1 What You Will Build

A CLI tool with two modes:

  1. One-variable inequality solver and number-line renderer.
  2. Two-variable linear system feasibility analyzer and polygon renderer.

3.2 Functional Requirements

  1. Parse inequalities with one variable (x) and optional absolute value.
  2. Return simplified interval notation with open/closed endpoints.
  3. Support conjunctions (and) and disjunctions (or).
  4. Parse 2D linear systems and compute feasible region vertices.
  5. Emit point-membership diagnostics for user-supplied test points.

3.3 Non-Functional Requirements

  • Deterministic ordering of intervals.
  • Consistent endpoint formatting.
  • Clear failure messages for contradictory or malformed constraints.

3.4 Real World Outcome

$ python region_analyzer.py --expr "|2x-4|<=6"
[result] interval = [-1, 5]
[endpoint] -1 closed, 5 closed
[output] saved number line: outputs/interval_abs_001.png

$ python region_analyzer.py --system "x+y<=6; x>=1; y>=0" --plot2d
[result] feasible vertices: (1,0), (1,5), (6,0)
[area] 12.5 square units
[output] saved region plot: outputs/feasible_triangle_001.png

4) Solution Architecture

4.1 High-Level Design

Constraint Parser -> Normalizer -> Interval/Region Solver -> Visualization + Report

4.2 Key Components

Component Responsibility
Constraint Parser Parse symbolic inequalities and absolute value terms
Interval Engine Build interval objects and merge/intersect them
Region Solver Compute 2D feasible vertices and edge constraints
Validator Test sampled points against final solution set

5) Implementation Guide

Phase 1: One-Variable Core

  • Implement linear inequality normalization.
  • Add sign-flip handling rules with tests.
  • Create interval object with inclusivity flags.

Phase 2: Absolute Value and Compound Constraints

  • Convert absolute value into piecewise constraints.
  • Add and/or composition logic.
  • Add contradiction detection (empty set).

Phase 3: 2D Feasible Regions

  • Parse two-variable linear constraints.
  • Intersect half-planes to form polygon.
  • Plot region and annotate boundaries.

6) Validation Checklist

  • Boundary inclusion/exclusion behaves correctly.
  • Absolute value conversion passes manual test cases.
  • Empty and unbounded solutions are reported clearly.
  • 2D region plots match symbolic constraints.

7) Extension Ideas

  1. Add nonlinear inequality support.
  2. Add symbolic simplification explanations.
  3. Export LaTeX and markdown solution summaries.

8) Books and References

  • Precalculus/algebra inequality chapters (high school core).
  • Practical Programming (Campbell et al.) for parser/data organization.
  • Matplotlib docs for boundary rendering and annotations.