Calculator Skill
A specialized mathematical calculator skill for computing arithmetic expressions, trigonometric functions, logarithms, and advanced math operations.
⚠️ IMPORTANT: Use This Skill For Math Calculations ONLY
This skill is designed EXCLUSIVELY for mathematical calculations. Use it when:
- The user asks to calculate or compute mathematical expressions
- Trigonometric operations are needed (sin, cos, tan, radians, degrees)
- Basic arithmetic is required (addition, subtraction, multiplication, division)
- Advanced operations are needed (exponents, square roots, logarithms)
- Complex expressions need to be evaluated
- Keywords: calculate, compute, math, trigonometry, sin, cos, tan, sqrt, log, radians
Supported Operations
Basic Arithmetic
- Addition:
5 + 3
- Subtraction:
10 - 4
- Multiplication:
6 * 7
- Division:
20 / 4
Trigonometric Functions ⭐
sin(x) - Sine of x (x in radians)
cos(x) - Cosine of x (x in radians)
tan(x) - Tangent of x (x in radians)
radians(x) - Convert degrees to radians
degrees(x) - Convert radians to degrees
Advanced Operations
- Exponentiation:
2 ** 8 (2 to the power of 8)
- Square root:
sqrt(16)
- Logarithms:
log(100), log10(100)
- Absolute value:
abs(-5)
Constants
- Pi:
pi (3.14159...)
- Euler's number:
e (2.71828...)
For a complete list of all available functions, see references/functions.md.
How to Use
- Identify the mathematical operation the user wants to perform
- Format the expression as a valid mathematical expression
- Run the calculation script with the expression as an argument
- Return the result to the user
Running the Script
python scripts/calculate.py "expression"
Quick Examples
Trigonometry (This Skill's Specialty!) ⭐
python scripts/calculate.py "sin(radians(30))"
# Result: 0.5
python scripts/calculate.py "cos(0)"
# Result: 1.0
python scripts/calculate.py "tan(radians(45))"
# Result: 1.0
Basic Calculation
python scripts/calculate.py "125 + 237"
# Result: 362
Complex Expression
python scripts/calculate.py "2**10 / 4"
# Result: 256.0
For more detailed examples across different domains, see references/examples.md.
Additional Resources
- references/REFERENCE.md - Complete technical reference and implementation details
- references/functions.md - Full list of supported mathematical functions
- references/examples.md - Domain-specific calculation examples
Edge Cases and Error Handling
The script handles common mathematical errors:
- Division by zero: Returns an error message
- Invalid expressions: Reports syntax errors clearly
- Undefined operations: Catches mathematical domain errors
- Invalid input: Validates the expression before evaluation
Safety
The script uses Python's restricted eval() to safely evaluate mathematical expressions without executing arbitrary code. Only mathematical operations are allowed.
1---2name: calculator-skill3description: Mathematical calculation skill for computing arithmetic expressions, trigonometry, logarithms, and complex math. Use EXCLUSIVELY for math calculations: sin, cos, tan, sqrt, log, exponents, etc.4license: MIT5---67# Calculator Skill89A specialized mathematical calculator skill for computing arithmetic expressions, trigonometric functions, logarithms, and advanced math operations.1011## ⚠️ IMPORTANT: Use This Skill For Math Calculations ONLY1213This skill is designed **EXCLUSIVELY** for mathematical calculations. Use it when:14- The user asks to calculate or compute mathematical expressions15- Trigonometric operations are needed (sin, cos, tan, radians, degrees)16- Basic arithmetic is required (addition, subtraction, multiplication, division)17- Advanced operations are needed (exponents, square roots, logarithms)18- Complex expressions need to be evaluated19- Keywords: calculate, compute, math, trigonometry, sin, cos, tan, sqrt, log, radians2021## Supported Operations2223### Basic Arithmetic24- Addition: `5 + 3`25- Subtraction: `10 - 4`26- Multiplication: `6 * 7`27- Division: `20 / 4`2829### Trigonometric Functions ⭐30- `sin(x)` - Sine of x (x in radians)31- `cos(x)` - Cosine of x (x in radians)32- `tan(x)` - Tangent of x (x in radians)33- `radians(x)` - Convert degrees to radians34- `degrees(x)` - Convert radians to degrees3536### Advanced Operations37- Exponentiation: `2 ** 8` (2 to the power of 8)38- Square root: `sqrt(16)`39- Logarithms: `log(100)`, `log10(100)`40- Absolute value: `abs(-5)`4142### Constants43- Pi: `pi` (3.14159...)44- Euler's number: `e` (2.71828...)4546For a complete list of all available functions, see [references/functions.md](references/functions.md).4748## How to Use49501. Identify the mathematical operation the user wants to perform512. Format the expression as a valid mathematical expression523. Run the calculation script with the expression as an argument534. Return the result to the user5455### Running the Script56```bash57python scripts/calculate.py "expression"58```5960## Quick Examples6162### Trigonometry (This Skill's Specialty!) ⭐63```bash64python scripts/calculate.py "sin(radians(30))"65# Result: 0.56667python scripts/calculate.py "cos(0)"68# Result: 1.06970python scripts/calculate.py "tan(radians(45))"71# Result: 1.072```7374### Basic Calculation75```bash76python scripts/calculate.py "125 + 237"77# Result: 36278```7980### Complex Expression81```bash82python scripts/calculate.py "2**10 / 4"83# Result: 256.084```8586For more detailed examples across different domains, see [references/examples.md](references/examples.md).8788## Additional Resources8990- **[references/REFERENCE.md](references/REFERENCE.md)** - Complete technical reference and implementation details91- **[references/functions.md](references/functions.md)** - Full list of supported mathematical functions92- **[references/examples.md](references/examples.md)** - Domain-specific calculation examples9394## Edge Cases and Error Handling9596The script handles common mathematical errors:97- **Division by zero:** Returns an error message98- **Invalid expressions:** Reports syntax errors clearly99- **Undefined operations:** Catches mathematical domain errors100- **Invalid input:** Validates the expression before evaluation101102## Safety103104The script uses Python's restricted `eval()` to safely evaluate mathematical expressions without executing arbitrary code. Only mathematical operations are allowed.