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.2.tar.gz (15.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.2-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: neuromath-0.1.2.tar.gz
  • Upload date:
  • Size: 15.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.2.tar.gz
Algorithm Hash digest
SHA256 3c81006a30533f2b374d7a1d8af824253c8e457ab3ba8d95bf5513022b214a3d
MD5 c57ecdd8206ea5e3fd5dae743c8904fa
BLAKE2b-256 63ae6718f6fc5a515a5de84a8cc045f5f894984bd53c74f2b78da6af325d4989

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neuromath-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7e28afd8e1d14af854944225920816a8cef26e4ea7f36d91c73f6deb91c972b5
MD5 da8f59381e801ccde6e6fbfa1645027c
BLAKE2b-256 145804dc7860432b5788b6eb71a709f9fbcb51f84f8bb398677a307b1d4db41b

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