Skip to content

jonathansina/math-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Math Interpreter

Math Interpreter is a Python-based command-line tool designed to evaluate, plot, and manage mathematical expressions. It provides a rich set of features for defining expressions, evaluating them at specific points, plotting graphs, and saving/loading expressions from files. The project is built with modularity and extensibility in mind, making it easy to add new features or adapt it to specific needs.


Features

  • Expression Management: Define and store mathematical expressions with variables.
  • Evaluation: Evaluate expressions at specific points.
  • Plotting: Generate 2D and 3D plots for single-variable and two-variable expressions.
  • File Operations: Save and load expressions to/from files.
  • Rich UI: Interactive command-line interface with help and error handling.

Table of Contents

  1. Installation
  2. Usage
  3. Commands
  4. Examples
  5. Project Structure
  6. Contributing
  7. License

Installation

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)

Steps

  1. Clone the repository:

    git clone https://github.com/your-username/math-interpreter.git
    cd math-interpreter
  2. Install dependencies:

    pip install -r requirements.txt
  3. Run the application:

    python src/ui.py

Usage

Run the application and interact with the command-line interface. The UI provides a help menu (h) and a quit option (q).

Starting the Application

python src/ui.py

Help Menu

Type h to display the list of available commands and their usage.


Commands

Command Description Example
GET Define a new expression. GET f = sin(x) + cos(x)
EVAL Evaluate an expression at specific points. EVAL f at (3.14)
PLOT Plot an expression with optional ranges. PLOT f in (-100, 100, -50, 50)
LOAD Load expressions from a file. LOAD expressions.math
SAVE Save an expression to a file with optional ranges. SAVE f in (-100, 100, -50, 50)

Examples

Defining an Expression

> GET f = sin(x) + cos(x)
Expression 'f' saved successfully

Evaluating an Expression

> EVAL f at (3.14)
Evaluation result: 0.0

Plotting an Expression

> PLOT f in (-10, 10)
Plot created for 'f'

Saving an Expression

> SAVE f in (-10, 10)
Plot saved for 'f'

Loading Expressions from a File

> LOAD expressions.math
Expressions loaded from 'expressions.math'

Project Structure

math-interpreter/
├── src/
│   ├── command/
│   │   ├── processor.py       # Command processing logic
│   │   ├── handler.py         # Command handlers for GET, EVAL, PLOT, etc.
│   ├── core/
│   │   ├── parser.py          # Expression parsing logic
│   │   ├── evaluator.py       # Expression evaluation logic
│   │   ├── expression.py      # Expression classes (e.g., Addition, Multiplication)
│   │   ├── context.py         # Context for variables and functions
│   │   ├── tokenizer.py       # Tokenizer for parsing expressions
│   ├── expression/
│   │   ├── base.py            # Base class for expressions
│   │   ├── repository.py      # Repository for managing expressions
│   ├── plotter/
│   │   ├── factory.py         # Factory for creating plotters
│   │   ├── strategy.py        # Plotting strategies (2D, 3D)
│   ├── ui.py                  # Command-line user interface
├── README.md                  # Project documentation
├── requirements.txt           # Python dependencies

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Commit your changes and push them to your fork.
  4. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


About

Python-based command-line tool designed to evaluate, plot, and manage mathematical expressions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages