Skip to main content

A solver for univariate polynomial equations (degree 1-4) with AI support

Project description

Equation Solver

A Python package for solving univariate polynomial equations (degree 1-4) with traditional methods and AI assistance.

Features

  • Solve 1st to 4th degree polynomial equations
  • AI-assisted solving using local language models
  • Server management for local AI models
  • Expression rendering and approximation
  • Caching for improved performance

Installation

pip install equation-solver

Basic Usage

Traditional Solving

from equation_solver import EquationSolver

solver = EquationSolver()
coefficients = solver.parse_input({
    "x⁴": "1",
    "x³": "0",
    "x²": "0",
    "x": "0",
    "常数项": "-1"
})

equation, degree = solver.build_equation(coefficients)

if degree > 0:
    solutions = solver.solve_equation(equation)
    processed = solver.process_solutions(solutions)
    print(f"Found {len(processed)} solutions")

AI-Assisted Solving

from equation_solver import EquationSolver, AISolver, ModelServer

# Start AI server
server = ModelServer()
server.start_server(model_path="path/to/model.gguf")

# Wait for server to start
import time
while server.status != "running":
    time.sleep(1)

# Solve with AI
solver = EquationSolver()
ai_solver = AISolver(port=5001)

coefficients = solver.parse_input({
    "x⁴": "1",
    "x³": "0",
    "x²": "0",
    "x": "0",
    "常数项": "-1"
})
equation, _ = solver.build_equation(coefficients)

equation_latex = sp.latex(equation)
ai_response = ai_solver.send_ai_request(equation_latex)
parsed = ai_solver.parse_ai_response(ai_response)

print("AI Solution:", parsed["clean_text"])
print("Solutions:", parsed["solutions"])

# Stop server
server.stop_server()

API Documentation

EquationSolver

  • parse_input(inputs): Parse user input coefficients
  • build_equation(coefficients): Build equation from coefficients
  • solve_equation(equation): Solve the equation
  • process_solutions(solutions): Prepare solutions for display
  • get_cache_key(coefficients): Generate cache key for solutions

AISolver

  • send_ai_request(equation_latex): Send request to AI server
  • parse_ai_response(ai_text): Parse AI response text

ModelServer

  • start_server(model_path, port): Start model server
  • stop_server(): Stop model server
  • is_running(): Check if server is running
  • get_logs(max_lines=100): Get server logs

Dependencies

  • SymPy
  • Requests
  • Matplotlib
  • Pillow
  • Psutil

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

equation-solver-ai-1.0.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

equation_solver_ai-1.0.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file equation-solver-ai-1.0.0.tar.gz.

File metadata

  • Download URL: equation-solver-ai-1.0.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.6

File hashes

Hashes for equation-solver-ai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f0a5e79b8ffd105b898f31d7ea418f7efefd24b7190e66595e23d01ea102dfd2
MD5 6492f15c5f6e29a59e0b4060593fc725
BLAKE2b-256 549b218156dff7a5358d85eae73004f7e985b1e10c54eb639ae75c9c56f0d263

See more details on using hashes here.

File details

Details for the file equation_solver_ai-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for equation_solver_ai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a20ba60a7d85003091666f4dbd9175ae2e96528bba46cc950bb73eda81600d48
MD5 d312743dfa45ea031da7f03dd0149972
BLAKE2b-256 0d22e537551e81cf57f49f7f6bb3f43f3a5efacb751e27cae4914e9d25ff1b30

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page