Simple Math Calculator
simple_math_calculatorCalculates arithmetic expressions with variables to total recipe nutrition, scale servings, convert units, and evaluate energy requirements—use it instead of manually summing values.
Instructions
Perform simple mathematical calculations with string variables.
!!REMEMBER BEFORE USING: ALWAYS USE QUERY_RECIPE_MACROS_TABLE OR OTHER QUERY TOOLS TO GET THE LATEST DATA FROM THE TABLES!!"
This tool allows you to evaluate mathematical expressions containing variables. It supports basic arithmetic operations (+, -, *, /, **, %) and common math functions.
CRITICAL for CNF nutrition calculations: This is the ONLY tool to use for calculating nutrition totals. Never manually sum values from JSON data.
Supported operations:
Basic arithmetic: +, -, *, /, ** (power), % (modulo)
Parentheses for grouping: (expression)
Variables: any valid Python identifier (letters, numbers, underscores)
Use this tool when:
Calculating EER equations with specific values
CNF nutrition calculations - summing calories, macros across ingredients
Recipe per-serving calculations - dividing totals by serving count
Scaling recipe quantities
Converting units
Any mathematical operation with known variables
CNF Nutrition Examples:
Total calories: "(206 * 565 / 100) + (885 * 10 / 100) + (22 * 450 / 100)"
Per serving: expression="total_calories / servings", variables={"total_calories": 1437, "servings": 5}
Scaling: expression="original_amount * scale_factor", variables={"original_amount": 100, "scale_factor": 1.5}
EER comparison: expression="recipe_calories - eer_requirement", variables={"recipe_calories": 287, "eer_requirement": 2000}
TEMP_RECIPE_MACROS Calculation Examples:
Conversion factor: expression="recipe_amount / cnf_serving", variables={"recipe_amount": 10.0, "cnf_serving": 5.0} # = 2.0
Scaled calories: expression="cnf_calories * conversion_factor", variables={"cnf_calories": 22.0, "conversion_factor": 2.0} # = 44.0
Recipe total from cache: expression="honey_cals + oil_cals + salmon_cals", variables={"honey_cals": 44.0, "oil_cals": 80.0, "salmon_cals": 200.0}
General Examples:
EER calculation: "662 - (9.53 * age) + (15.91 * weight) + (539.6 * height)"
Unit conversion: "cups * 240" (cups to ml)
Percentage: "part / total * 100"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| math_input | Yes | Contains expression string and variables dictionary |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||