Skip to content

Repository files navigation

Calculus Evaluator

A lightweight Streamlit app for symbolic and numerical integration and differentiation using SymPy and SciPy.

Features

  • Symbolic integration and differentiation via sympy.
  • Numerical integration fallback using scipy.integrate.quad for definite integrals when symbolic integration fails.
  • Streamlit UI with separate tabs for Integration and Differentiation.
  • Supports common math functions (sin, cos, exp, log, sqrt) and constants (pi, e).

Quickstart

Requirements: Python 3.8+.

  1. Create a virtual environment and install dependencies:
python -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txt
  1. Run the app:
streamlit run main.py

Open the URL printed by Streamlit (usually http://localhost:8501).

Usage

  • Integration tab: enter a function (Python syntax), list variables comma-separated, choose the integration variable, and optionally provide lower/upper limits for a definite integral.
  • Differentiation tab: enter a function, list variables, and select the variable to differentiate with respect to.

Examples:

  • Indefinite integral of x**2 with respect to x → x**2, variables: x, leave limits empty.
  • Definite integral of sin(x) from 0 to pi → sin(x), variable: x, lower: 0, upper: pi.
  • Derivative of x*y + y**2 with respect to x → expression x*y + y\*\*2, variables x, y, differentiate by x.

Library API

You can reuse core functions from integration.py and differentiation.py.

  • integration.universal_integrate(expr_str, variables_str, var=None, lower=None, upper=None)

    • Returns a dict with keys: method, variable, result, and for numerical integration error.
  • differentiation.universal_differentiate(expr_str, variables_str, var=None)

    • Returns a dict with keys: method, variable, result.

Example (Python):

from integration import universal_integrate

universal_integrate("sin(x)", "x", var="x", lower=0, upper="pi")

Limitations & Security

  • The app uses sympy.sympify to parse user input. While SymPy is safer than eval, avoid running this service exposed to untrusted users without sandboxing.
  • Numerical fallback requires both bounds; indefinite integrals fallback to a message.

Contributing

See CONTRIBUTING.md for contribution guidelines.

License

This repository is released under the MIT License - see LICENSE

About

A lightweight mathematical toolkit built with Python that performs symbolic differentiation and both symbolic and numerical integration through an interactive Streamlit interface, supporting custom expressions, multi-variable functions, and infinite limits.

Topics

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages