Complex Mathematics Engine (009) - Instructions
Overview
Evaluate mathematical expressions using three powerful computation engines:
- SymPy — Symbolic math (calculus, algebra, equation solving)
- NumPy — Numerical computation (arrays, linear algebra, statistics)
- SciPy — Scientific computing (statistics distributions, optimization, special functions)
Action: calculate
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
expression | string | Yes | Mathematical expression to compute. Max 50,000 characters. |
engine_hint | string | No | Force a specific engine: auto (default), sympy, numpy, scipy. |
Engine Auto-Detection
When engine_hint is auto (default), the engine is chosen based on the expression:
- SciPy — Expressions containing
scipy.,stats.,optimize.,special.,interpolate.,integrate.,curve_fit,least_squares - NumPy — Expressions containing
np.,numpy.,array,zeros,ones,eye,linspace,arange,mean,std,dot,linalg. - SymPy — Expressions containing
diff,integrate,limit,solve,simplify,expand,factor(and is the default fallback)
Supported Syntax
SymPy Examples
diff(x**2, x)— Differentiate x² with respect to xintegrate(sin(x), x)— Indefinite integral of sin(x)solve(x**2 - 4, x)— Solve x² - 4 = 0limit(sin(x)/x, x, 0)— Evaluate limit as x approaches 0simplify((x**2 - 1)/(x - 1))— Simplify expressionexpand((x + 1)**3)— Expand polynomialfactor(x**2 - 4)— Factor polynomial
NumPy Examples
np.mean([1, 2, 3, 4, 5])— Calculate meannp.std([1, 2, 3])— Standard deviationnp.dot([1, 2], [3, 4])— Dot productnp.linalg.det(array([[1, 2], [3, 4]]))— Matrix determinantnp.linspace(0, 10, 5)— Generate evenly spaced values
SciPy Examples
stats.norm.cdf(0)— Standard normal CDF at 0stats.norm.pdf(0, loc=0, scale=1)— Normal PDFspecial.gamma(5)— Gamma functionstats.t.ppf(0.975, df=10)— t-distribution critical value
Unicode Support
The following Unicode symbols are automatically converted:
π→pi,∞→oo,√→sqrt,∂→diff,∫→integrate^is converted to**for exponentiation
Security
Expressions are sandboxed. The following are blocked:
import,exec,eval,compile,openstatements- Access to
os,sys,subprocess,pathlib,shutil - Dunder attributes (
__) - Semicolons and newlines (no multi-statement expressions)
- Only whitelisted functions and namespaces are permitted
Response Fields
expression— The original expression submittedengine_used— Which engine processed the expression (sympy,numpy, orscipy)execution_time_seconds— How long the computation tookresult— The computed result (JSON-serializable)result_str— String representation of the resultmetadata— Additional info (result_type, variables if symbolic)







