Cn Math Expression
/install cn-math-expression
Math Expression Evaluator
Safely evaluate mathematical expressions with support for common functions.
Features
- Safe evaluation (no arbitrary code execution)
- Common mathematical functions: sqrt, sin, cos, tan, log
- Constants: pi, e
- Basic arithmetic: +, -, *, /, **, %
- Pure Python, no external dependencies
Supported Functions
| Function | Description | Example |
|---|---|---|
| sqrt(x) | Square root | sqrt(144) = 12 |
| sin(x) | Sine (radians) | sin(pi/2) = 1 |
| cos(x) | Cosine (radians) | cos(0) = 1 |
| tan(x) | Tangent (radians) | tan(pi/4) = 1 |
| log(x) | Natural log | log(e) = 1 |
| log10(x) | Base 10 log | log10(100) = 2 |
| abs(x) | Absolute value | abs(-5) = 5 |
| pow(x,y) | Power | pow(2,8) = 256 |
Supported Constants
pi= 3.141592653589793e= 2.718281828459045
Usage Examples
# Basic arithmetic
python3 scripts/math_eval.py --expr "2 + 3 * 4"
# Result: 14
# Using functions
python3 scripts/math_eval.py --expr "sqrt(144) + pow(2, 10)"
# Result: 1028.0
# Constants
python3 scripts/math_eval.py --expr "2 * pi * 10"
# Result: 62.8318...
# Complex expression
python3 scripts/math_eval.py --expr "log(pow(e, 5)) + sqrt(81)"
# Result: 14.0
Safety
The evaluator uses Python's eval() with a restricted namespace. Only mathematical functions and constants are available. No imports, no file access, no system commands.
Error Handling
If the expression is invalid or contains unsafe operations:
{"error": "name 'os' is not defined"}
Exit code 1 on error.
Technical Details
- Language: Python 3
- Dependencies: None (standard library only)
- License: MIT-0
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install cn-math-expression - After installation, invoke the skill by name or use
/cn-math-expression - Provide required inputs per the skill's parameter spec and get structured output
What is Cn Math Expression?
cn math expression. It is an AI Agent Skill for Claude Code / OpenClaw, with 24 downloads so far.
How do I install Cn Math Expression?
Run "/install cn-math-expression" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Cn Math Expression free?
Yes, Cn Math Expression is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Cn Math Expression support?
Cn Math Expression is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Cn Math Expression?
It is built and maintained by freedompixels (@freedompixels); the current version is v1.0.0.