Skip to content

hibays/SymAlpha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SymAlpha

中文 | English

Python Streamlit SymPy License

SymAlpha is an open-source, lightweight shallow alternative to WolframAlpha. It is dedicated to converting natural language mathematical problems into precise symbolic computations and returning intuitive results. The project combines a powerful symbolic computation library with a modern UI framework, supporting local operation or network-based calls to large models for semantic parsing, enabling "speak like a human, compute mathematics".

💡 Goal: Enable non-programmers to easily and freely use symbolic computation without memorizing complex syntax.


🌟 Core Features

  • Natural Language Input: Enter queries such as "Find the derivative of x² + 2x + 1" or "Solve the equation x² - 5x + 6 = 0", and the system will automatically parse and compute.
  • Two-Mode Parsing:
    • Local Mode: A purely rule-based parser with SymPy, no network required, ensuring privacy and security.
    • AI-Enhanced Mode (Optional): Call local/remote large models (e.g., Llama, Qwen, OpenAI) to convert ambiguous natural language into precise mathematical expressions.
  • High-Performance Backend:
    • SymPy: Provides comprehensive symbolic computation capabilities (calculus, algebra, equation solving, etc.).
    • SymEngine: A SymPy-compatible backend written in C++, accelerating numerical and symbolic operations.
    • gmpy2: Supports high-precision integer and floating-point operations.
  • Interactive Web UI: Built with Streamlit, featuring fast response, support for formula rendering (LaTeX), plotting, and result export.
  • Command-Line Interface (CLI): Supports scripted calls for easy integration into other toolchains.
  • Modular Design: Easy to extend with new parsers, new computation backends, or new UI components.

📦 Project Structure

src/
├── symalpha/
│   ├── cli/          # Command-Line Interface module
│   └── gui/          # Streamlit Graphical User Interface
.venv/                # Virtual environment created by uv (managed by uv)
pyproject.toml        # Project configuration (using uv + pyproject.toml)
README.md

💡 The project uses uv as the package manager and virtual environment tool, replacing pip + venv, with faster speed and more reliable dependency resolution.


🚀 Quick Start

Prerequisites

  • Python 3.10+
  • uv

Installation and Execution

# Clone the repository
git clone https://github.com/your-username/SymAlpha.git
cd SymAlpha

# Create a virtual environment and install dependencies using uv
uv sync

# Activate the virtual environment (Windows)
.venv\Scripts\activate
# Or (Linux/macOS)
source .venv/bin/activate

# Launch the Web UI
uv run streamlit run src/symalpha/gui/app.py

# Or use the CLI (example)
uv run python -m symalpha.cli --query "integrate x^2 dx"

🌐 After the first launch, access http://localhost:8501 to use the graphical interface.


🧪 Example Usage

Input (Natural Language) Output (Symbolic Result)
Find the indefinite integral of sin(x) -cos(x) + C
Factorize x^3 - 1 (x - 1)(x² + x + 1)
Solve the system of equations: x + y = 5, x - y = 1 {x: 3, y: 2}
Plot the graph of y = x^2 over the interval [-2, 2] Interactive chart (rendered by Streamlit)

🛠️ Development and Contribution

We welcome contributions! Please follow these steps:

  1. Fork this repository
  2. Create a feature branch (git checkout -b feat/your-feature)
  3. Commit your code (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feat/your-feature)
  5. Create a Pull Request

Dependency Management

  • Add dependencies: uv add package-name
  • Update dependencies: uv lock --upgrade
  • Export requirements.txt (compatible with traditional tools): uv export > requirements.txt

📜 License

This project is licensed under the GPLv3 License.


🙏 Acknowledgements

  • SymPy: A powerful Python symbolic computation library
  • SymEngine: A high-performance symbolic computation backend
  • Streamlit: A minimalist web application framework
  • uv: The next-generation Python package manager
  • gmpy2: High-precision arithmetic support

SymAlpha —— Bring mathematics back to natural expression, make computation within easy reach.
🧮 Say it. Solve it.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages