Skip to main content

NeuroMath - A lightweight symbolic mathematical DSL

Project description

NeuroMath

A custom mathematical and symbolic computation language built from scratch using Python.

NeuroMath is a mini computer algebra system (CAS) that supports:

✅ Variable assignments

✅ User-defined functions

✅ Symbolic differentiation

✅ Symbolic integration

✅ Mathematical built-in functions

✅ Notebook-style Streamlit interface

✅ Clean interpreter architecture (Lexer → Parser → AST → Interpreter)

🚀 Demo x = 5 f(x) = 3x^2 + 5x

print(f(2)) print(diff(f(x), x))

Output:

22 6*x + 5 📌 Features 🔹 Core Language Features

Arithmetic operations: +, -, *, /, ^

Variable assignment

Function definition

Function calls

Nested expressions

Multi-line programs

Print function

typeof() support

🔹 Symbolic Computation

Powered internally via SymPy conversion layer.

Supported symbolic operations:

diff(expression, variable)

integrate(expression, variable)

Symbolic simplification

Mixed numeric + symbolic expressions

Example:

f(x) = x^3 + 2*x diff(f(x), x)

Output:

3*x^2 + 2 🏗️ Architecture

NeuroMath is built using a traditional interpreter pipeline:

Source Code ↓ Lexer (Tokenization) ↓ Parser (AST Construction) ↓ Interpreter (Execution Engine) ↓ Symbolic Conversion Layer (SymPy) Components Module Responsibility lexer/ Converts source code into tokens parser/ Builds Abstract Syntax Tree ast/ AST node definitions interpreter/ Executes AST symbolic engine Converts AST to SymPy expressions streamlit app Notebook-style GUI 📚 Language Syntax Variables x = 10 y = x + 5

Rules:

Must start with a letter

Case-sensitive

Cannot start with a number

Function Definition f(x) = x^2 + 3*x

Call:

f(2) Symbolic Operations diff(x^2, x) integrate(x^2, x) Print print(x) Built-in Mathematical Functions

sin(x)

cos(x)

tan(x)

sqrt(x)

log(x)

exp(x)

pi

e

Example:

sin(pi/2) 🖥️ Notebook Interface

NeuroMath includes a Streamlit-powered notebook UI that mimics Wolfram / Jupyter-style execution:

Cell-based execution

Persistent environment

Reset kernel

Execution history

Run:

streamlit run app.py ⚙️ Installation

Clone repository:

git clone https://github.com/yourusername/neuromath.git cd neuromath

Install dependencies:

pip install -r requirements.txt

Run CLI:

python main.py

Run GUI:

streamlit run app.py 🧪 Example Programs Numeric Evaluation x = 5 y = 7 z = x*y + 3 print(z) Symbolic + Numeric Mixed x = 10 diff(x^2, x)

Output:

2*x

(Symbolic mode correctly ignores numeric memory.)

🔬 Design Highlights

Clean separation of numeric and symbolic evaluation modes

Context-aware AST to SymPy transformation

Local function scope isolation

Session-state safe Streamlit architecture

Modular and extensible design

📁 Project Structure neuromath/ │ ├── lexer/ ├── parser/ ├── ast/ ├── interpreter/ ├── app.py ├── main.py ├── requirements.txt └── README.md

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

neuromath-0.1.1.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

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

neuromath-0.1.1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file neuromath-0.1.1.tar.gz.

File metadata

  • Download URL: neuromath-0.1.1.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for neuromath-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d610081737e86abffff0d70e8b6e96b1fc8673a3869528332e9317e195b56bb2
MD5 0061aa2f7254660abc4908553874f549
BLAKE2b-256 9a77a60a9dc719613d954482069908645daab3fe86a4d28056bef9201a54f645

See more details on using hashes here.

File details

Details for the file neuromath-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: neuromath-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for neuromath-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bd65c022c3f51884f9d98ef75f02f93c9e2803321cc9dc8a16be505b5a729fae
MD5 61181f3487620cc418f129cb124bc7b2
BLAKE2b-256 1562636e14ae10308575390efa6ff2581310b574eb2d83b1bae8a84812b78596

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