Step-by-step mathematics solver built on SymPy — equations, calculus, and annotated rules.
Project description
SmartSolver
SmartSolver is a step-by-step mathematics engine built on SymPy. It powers worked solutions inside Ed-Master — showing not just the final answer, but the rules and identities applied along the way.
The implementation lives in math_step_tracker.py (class SmartSolver).
Features
| Area | What SmartSolver shows |
|---|---|
| Equations | Linear & quadratic solving, discriminant steps |
| Trigonometry | Quotient, Pythagorean, double-angle identities; tan reduction |
| Logarithms & exponentials | Log product/power rules, log(x) = c → x = e^c, a^x = b |
| Differentiation | Sum, product, power, chain rule labels |
| Integration | Partial fractions, LIATE-based integration by parts, direct rules |
| Limits | Setup, direct substitution where valid, final limit |
| Partial fractions | Factor denominator, decompose, integrate term-by-term |
Each step includes a description, expression, LaTeX, and rule applied.
Requirements
- Python 3.10+ (
requires-pythoninpyproject.toml) - SymPy ≥ 1.13
Supported Python versions
| Status | Versions |
|---|---|
| Minimum | Python 3.10 |
| Tested | Python 3.10, 3.11, 3.12, 3.13 |
Only list versions you actually test. Do not claim support for unreleased major versions (e.g. Python 4.x or fictional 7.x).
pip install ed-master-smartsolver
Import in Python (package module name is smartsolver):
from smartsolver import SmartSolver
Or install SymPy only when using from source:
pip install sympy
Quick start
from smartsolver import SmartSolver, StepRenderer, serialize_solver_result
solver = SmartSolver()
# Solve a quadratic
result = solver.solve_equation("x^2 + 5x + 6 = 0", "x")
print(StepRenderer.to_text(result["steps"]))
print("Solutions:", result["solutions"])
# JSON-friendly payload (for APIs)
payload = serialize_solver_result(result)
print(payload["steps_latex"])
When running from a git checkout (editable install):
pip install -e .
from smartsolver import SmartSolver
Input notation
SmartSolver accepts student-style strings:
| You type | Parsed as |
|---|---|
x^2 or x**2 |
x squared |
5x |
5*x |
2x - 4 |
2x - 4 = 0 (equation assumed zero) |
sin(x), cos(x), log(x) |
SymPy trig / natural log |
2**x |
exponential |
Operations
solve_equation(equation, variable='x')
Solve an equation with step-by-step working.
solver.solve_equation("sin(x) - cos(x) = 0", "x")
solver.solve_equation("2**x - 8 = 0", "x")
solver.solve_equation("log(x) - 3 = 0", "x")
Returns: steps, solutions, solution_latex
differentiate(expression, variable='x', order=1)
Differentiate with rule labels (sum, power, chain, etc.).
solver.differentiate("x**2 + 3*x", "x")
solver.differentiate("sin(x)**2", "x", order=1)
Returns: steps, derivative, derivative_latex
integrate(expression, variable='x', lower=None, upper=None)
Integrate with method tracking.
solver.integrate("x*exp(x)", "x") # integration by parts (LIATE)
solver.integrate("1/(x**2 - 1)", "x") # partial fractions
solver.integrate("x**2", "x", lower="0", upper="1") # definite
Returns: steps, integral, integral_latex, methods (e.g. ['Integration by parts'])
partial_fractions(expression, variable='x')
Decompose a rational expression without integrating.
solver.partial_fractions("(2*x + 3)/((x - 1)*(x + 2))")
Returns: steps, decomposition, decomposition_latex
limit(expression, variable='x', point='0', direction='+')
Evaluate a limit with setup steps.
solver.limit("sin(x)/x", "x", point="0", direction="+")
Returns: steps, limit, limit_latex
Helper utilities
from smartsolver import (
StepRenderer,
serialize_solver_result,
normalize_math_input,
parse_math,
step_to_dict,
)
# Human-readable steps
StepRenderer.to_text(steps)
StepRenderer.to_latex(steps)
StepRenderer.to_html(steps)
# API / JSON serialization
serialize_solver_result(result)
Optional helpers (Ed-Master Math Lab)
If you also ship edmathlab.py alongside this package, it provides stdout-friendly wrappers. They are not included in the PyPI wheel by default.
REST API (Ed-Master platform)
When the Django backend is running, authenticated users can call:
POST /api/math/steps/
Content-Type: application/json
Body:
{
"operation": "solve",
"expression": "x^2 + 5x + 6 = 0",
"variable": "x"
}
Operations: solve, differentiate, integrate, limit, partial_fractions
Response fields: steps, steps_text, steps_html, steps_latex, result, result_latex, operation
Requires a signed-in Ed-Master session (JWT cookie).
Result structure
Each step is a Step dataclass:
@dataclass
class Step:
description: str # e.g. "Apply the quotient identity"
expression: str # SymPy string at this step
latex: str # LaTeX rendering
rule_applied: str # e.g. "Quotient identity", "LIATE: choose u"
substeps: list # nested steps (reserved)
serialize_solver_result() flattens this for JSON APIs and adds rendered steps_text, steps_html, and steps_latex.
Example session
from smartsolver import SmartSolver, StepRenderer
s = SmartSolver()
print("=== Quadratic ===")
r = s.solve_equation("x^2 + 5x + 6 = 0")
print(StepRenderer.to_text(r["steps"]))
print("=== Trig ===")
r = s.solve_equation("sin(x) - cos(x) = 0")
print(StepRenderer.to_text(r["steps"]))
print("=== Integration by parts ===")
r = s.integrate("x*exp(x)")
print(StepRenderer.to_text(r["steps"]))
print("Answer:", r["integral"])
print("Methods:", r["methods"])
Scope & limitations
SmartSolver is designed for education, not as a replacement for a full computer algebra system.
- Trig: covers common identities and reduction; general periodic solution sets are simplified.
- Logs: strongest on combinable logs and
log(f(x)) = constantforms. - Partial fractions: requires a proper rational form; improper rationals use polynomial division first.
- Integration by parts: one LIATE-guided pass; does not recurse automatically.
- u-substitution: basic patterns only.
SymPy still performs the underlying symbolic work; SmartSolver adds annotated steps around it.
Running tests
pip install -e ".[dev]"
python -m unittest discover -s tests -v
Or a quick smoke test:
python -c "from smartsolver import SmartSolver; print(SmartSolver().solve_equation('x-2=0')['solutions'])"
Project layout
. # repository root (this folder)
├── __init__.py # public exports
├── math_step_tracker.py # SmartSolver core
├── README.md
├── LICENSE
├── pyproject.toml # PEP 517 build (no setup.py)
└── tests/
└── test_smartsolver.py
Roadmap
- PyPI packaging scaffold (
ed-master-smartsolver) - Recursive integration by parts
- Richer trig general solutions
- Public “Try SmartSolver” demo page on Ed-Master
Links
- Platform: ed-master.co.za
- Try Math Lab: ed-master.co.za/try/math-lab
- Research projects: ed-master.co.za/projects
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ed_master_smartsolver-0.1.0.tar.gz.
File metadata
- Download URL: ed_master_smartsolver-0.1.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3d3eb012d1fbdf80c1f295ba54ac9a50708834991e642d89acdb5f4a1eea127
|
|
| MD5 |
9419f33ef144ecbb4905c7f8a2faba43
|
|
| BLAKE2b-256 |
9ceaa74147f7b2ce801922e10338cfa6d3f19e75501b968de19dd4989dfa3556
|
Provenance
The following attestation bundles were made for ed_master_smartsolver-0.1.0.tar.gz:
Publisher:
publish.yml on mngadilinda/SmartSolver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ed_master_smartsolver-0.1.0.tar.gz -
Subject digest:
a3d3eb012d1fbdf80c1f295ba54ac9a50708834991e642d89acdb5f4a1eea127 - Sigstore transparency entry: 2168154122
- Sigstore integration time:
-
Permalink:
mngadilinda/SmartSolver@01b3cc7527a7b4f447fa18d0e45bd4f1a8d10900 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mngadilinda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01b3cc7527a7b4f447fa18d0e45bd4f1a8d10900 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ed_master_smartsolver-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ed_master_smartsolver-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d1cec034c5e872dbb3a93d1a7196574fa3216944c7800df2f35a5ccf7c0af5f
|
|
| MD5 |
3b1c35d7212edd7c5d68697c888c141e
|
|
| BLAKE2b-256 |
fe851aed8f8cbb0778b872fba7bcf78078b0295e7f8596273b3f1f1fcaacd383
|
Provenance
The following attestation bundles were made for ed_master_smartsolver-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on mngadilinda/SmartSolver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ed_master_smartsolver-0.1.0-py3-none-any.whl -
Subject digest:
7d1cec034c5e872dbb3a93d1a7196574fa3216944c7800df2f35a5ccf7c0af5f - Sigstore transparency entry: 2168154136
- Sigstore integration time:
-
Permalink:
mngadilinda/SmartSolver@01b3cc7527a7b4f447fa18d0e45bd4f1a8d10900 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mngadilinda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01b3cc7527a7b4f447fa18d0e45bd4f1a8d10900 -
Trigger Event:
workflow_dispatch
-
Statement type: