calculate_skill
- Python
9
GitHub Stars
2
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill bdambrosio/cognitive_workbench --skill calculate- Skill.md1.3 KB
- tool.py4.1 KB
Overview
This skill numerically evaluates mathematical expressions using SymPy and returns floating-point results. It supports arithmetic, common mathematical functions, constants, and basic equation solving. Use it when you need reliable numeric evaluation or to offload arithmetic from an LLM.
How this skill works
You provide an expression string, optional numeric variable substitutions, and an optional precision (decimal places). The skill parses the expression with SymPy, substitutes variables, evaluates to the requested precision, and returns a numeric result or solved roots for equations. If parsing or evaluation fails, it returns a clear error reason.
When to use it
- Perform reliable arithmetic that an LLM might mishandle
- Evaluate expressions with variables by supplying numeric substitutions
- Compute trigonometric, logarithmic, exponential, or factorial results
- Solve simple equations and return numeric roots
- Obtain floating-point results at a specified decimal precision
Best practices
- Supply numeric variable values as plain numbers in the variables dictionary
- Specify precision when you need a particular number of decimal places (default is 10)
- Remember trigonometric functions use radians; convert degrees before calling if needed
- Treat equality expressions (with '=') as equations to solve for roots
- For integer results, coerce the returned float to an integer in a downstream step
Example use cases
- Basic arithmetic: "2 + 3 * 4" → 14.0
- Physics formula evaluation with variables: "2 * v * sin(theta * pi / 180) / g" and variables {v:20, theta:30, g:9.8}
- Solve polynomial: "x**2 - 4 = 0" → -2.0 and 2.0
- Compute trig or log: "sin(pi/6) + log(10)"
- Evaluate factorial and absolute values: "factorial(5) - abs(-3)"
FAQ
Provide the expression as a string. Variables are a dictionary of numeric values. Precision is an integer for decimal places.
How are equations handled?
Expressions containing '=' are treated as equations; the skill solves for variable roots and returns numeric solutions.