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
- Solve one-variable inequalities and express solutions as intervals.
- Translate absolute value constraints into piecewise inequalities.
- Distinguish strict (
<) vs inclusive (<=) boundaries in both math and plots. - Build a 2D feasible region from multiple linear constraints.
- 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:
- One-variable inequality solver and number-line renderer.
- Two-variable linear system feasibility analyzer and polygon renderer.
3.2 Functional Requirements
- Parse inequalities with one variable (
x) and optional absolute value. - Return simplified interval notation with open/closed endpoints.
- Support conjunctions (
and) and disjunctions (or). - Parse 2D linear systems and compute feasible region vertices.
- 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/orcomposition 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
- Add nonlinear inequality support.
- Add symbolic simplification explanations.
- 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.