A lightweight Streamlit app for symbolic and numerical integration and differentiation using SymPy and SciPy.
- Symbolic integration and differentiation via
sympy. - Numerical integration fallback using
scipy.integrate.quadfor 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).
Requirements: Python 3.8+.
- Create a virtual environment and install dependencies:
python -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txt- Run the app:
streamlit run main.pyOpen the URL printed by Streamlit (usually http://localhost:8501).
- 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, variablesx, y, differentiate byx.
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 integrationerror.
- Returns a dict with keys:
-
differentiation.universal_differentiate(expr_str, variables_str, var=None)- Returns a dict with keys:
method,variable,result.
- Returns a dict with keys:
Example (Python):
from integration import universal_integrate
universal_integrate("sin(x)", "x", var="x", lower=0, upper="pi")- The app uses
sympy.sympifyto parse user input. While SymPy is safer thaneval, avoid running this service exposed to untrusted users without sandboxing. - Numerical fallback requires both bounds; indefinite integrals fallback to a message.
See CONTRIBUTING.md for contribution guidelines.
This repository is released under the MIT License - see LICENSE