Skip to content

Prefer SymPy built-ins over custom math plumbing #8

Description

@sacchen

Use SymPy-native APIs for core math behavior where we currently hand-roll logic, while preserving phil safety and UX contracts.

Goal

Reduce custom math plumbing in core internals to lower correctness risk and maintenance overhead.

Scope

  1. Simplification policy
  • Replace unconditional broad simplify() in src/calc/core.py with a targeted pipeline using SymPy primitives where intent is clear (cancel, together, trigsimp, powsimp, etc.).
  • Preserve --no-simplify behavior.
  1. Matrix solve internals
  • Migrate msolve / linalg solve internals toward SymPy matrix-native solve APIs (A.solve(b) family) instead of hardwiring a single method.
  • Keep existing UX errors/hints for bad shapes/inputs.
  1. Assumption-sensitive behavior
  • Use SymPy assumptions/refinement APIs for selected domain-sensitive paths.
  • Keep conservative behavior when assumptions are unknown.

Out of Scope

Relationship to Other Issues

Acceptance Criteria

  • Scoped internals are SymPy-backed rather than custom algebra logic.
  • Existing CLI UX remains intact (E: + hint: quality).
  • One-shot and REPL parity maintained.
  • Tests added for each user-visible behavior change.

Validation Gate

  • uv run --group dev pytest
  • uv run --group dev pytest --cov=calc --cov-report=term-missing --cov-fail-under=90

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions