Skip to content

ysocrius/MATH_AI_AGENT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MathSolver - Domain-Specific AI Agent for Mathematics Education

Python License


Table of Contents


Project Overview

MathSolver is an intelligent, domain-specific AI agent designed for mathematics education and problem-solving. It combines computer vision, natural language processing, and symbolic mathematics to autonomously understand, analyze, and solve mathematical problems. MathSolver provides an interactive web interface for seamless engagement with mathematical concepts.

What is an AI Agent?

An AI agent is an autonomous system that perceives its environment, reasons about it, and takes actions to achieve specific goals. MathSolver is a domain-specific AI agent: it perceives mathematical problems (from images or text), reasons about their structure and difficulty, and autonomously generates solutions and explanations.


Screenshots

Main Interface

Main Interface

Solution Output Example

Solution Output

Math Chatbot in Action

Math Chatbot


Quick Start

  1. Clone the repository:
    git clone https://github.com/yourusername/mathsolver-ai-agent.git
    cd mathsolver-ai-agent
  2. Create a virtual environment:
    python -m venv venv
    source venv/bin/activate  # or venv\Scripts\activate on Windows
  3. Install dependencies:
    pip install -r requirements.txt
  4. Set up API keys:
    • Create a .env file with your Mathpix and OpenAI API keys:
      MATHPIX_APP_ID=your_mathpix_app_id
      MATHPIX_APP_KEY=your_mathpix_app_key
      OPENAI_API_KEY=your_openai_api_key
      
  5. Run the application:
    streamlit run app2.py
  6. Open your browser:

AI Agent Capabilities

  • Perception System:
    • Computer vision for image-based math problem recognition
    • OCR for extracting mathematical notation
    • Natural language understanding for math queries
  • Cognitive Processing:
    • Autonomous analysis and difficulty assessment
    • Context-aware solution strategy selection
    • Dynamic Python script generation for problem-solving
  • Response Generation:
    • Multi-modal output (text, LaTeX, code)
    • Detailed explanations and interactive dialogue
  • Learning Assistant:
    • Math chatbot powered by GPT models
    • Maintains conversation context and history

Real-World Use Cases

  • Instantly solve handwritten or printed math problems from photos
  • Generate step-by-step solutions and explanations for students
  • Assess problem difficulty for adaptive learning
  • Use the chatbot for math tutoring, homework help, or concept clarification

Agent Interfaces

  • Streamlit Web App:
    • Dual-column layout: left for image upload/processing, right for math chatbot
    • Real-time LaTeX rendering and solution visualization
  • HTML/JavaScript Interface:
    • Futuristic dark theme
    • Asynchronous requests and interactive feedback

Agent's Problem-Solving Capabilities

MathSolver autonomously generates Python scripts to solve problems in:

  • Matrix Operations (determinant, rank, transformations)
  • Trigonometry (identities, angle calculations)
  • Calculus (derivatives, integrals, differential equations)
  • Algebra (equation solving, factorization)
  • Statistics (probability, statistical analysis)

Example: Matrix Rank Calculation

import sympy as sp
A = sp.Matrix([[1, 5, 8, 9], [13, 3, 9, 8], [6, 2, 4, 12]])
rank_A = A.rank()
print("The rank of matrix A is:", rank_A)

Example: Trigonometric Problem

import sympy as sp
sin_theta = 4 / 5
cos_theta = sp.sqrt(1 - sin_theta**2)
cos_2theta = cos_theta**2 - sin_theta**2
print(f"cos(2theta) = {cos_2theta.evalf()}")

Neural Architecture (Technology Stack)

  • Frontend: Streamlit, HTML/CSS/JavaScript
  • Computer Vision: OpenCV
  • OCR: Mathpix API
  • AI/ML: OpenAI GPT-4o, SymPy
  • Image Processing: PIL/Pillow
  • Styling: Custom CSS

System Requirements

  • Python 3.13 or later
  • All dependencies in requirements.txt
  • Internet connection for API access

Required API Neural Links

  • Mathpix API (APP_ID and APP_KEY)
  • OpenAI API Key

Agent Environment Setup

The agent uses a Python virtual environment for dependency isolation and reproducibility:

venv/
├── Scripts/
├── Lib/
├── Include/
├── pyvenv.cfg
└── .gitignore

Activation Protocol

  1. Clone the repository
  2. Set up the virtual environment
  3. Install dependencies
  4. Add API keys to .env
  5. Run the Streamlit app

Interaction Protocol

  • Image Upload: Upload or capture a math problem image
  • Processing: Extract and review the math expression
  • Solution Generation: Generate and view the solution and LaTeX
  • Chatbot: Ask math questions and get AI-powered answers

Neural Architecture

  • app2.py: Main application logic and UI
  • code_gen.py: Python solver script generation
  • templates/: HTML templates
  • temp/: Temporary files and generated scripts
  • venv/: Python virtual environment
  • .env: API keys

Current Limitations

  • Extraction accuracy depends on image quality
  • Best for standard mathematical problems
  • Requires internet for API access
  • Some complex notations may not be recognized

Future Neural Enhancements

  • Support for more mathematical domains
  • Step-by-step solution explanations
  • Offline/local model support
  • Mobile app version
  • Batch processing

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/your-feature)
  3. Commit your changes
  4. Push to your fork and submit a pull request

For major changes, please open an issue first to discuss what you would like to change.


Citing

If you use MathSolver in your research or teaching, please cite it as:

Yeshwanth C R. MathSolver: Domain-Specific AI Agent for Mathematics Education. 2024. https://github.com/yourusername/mathsolver-ai-agent


Neural Architect

  • Yeshwanth C R

License

MIT

About

MathSolver is an intelligent, domain-specific AI agent designed for mathematics education and problem-solving. It combines computer vision, natural language processing, and symbolic mathematics to autonomously understand, analyze, and solve mathematical problems.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors