Complex Math Tool - Instructions
Overview
The Complex Math Tool provides a comprehensive set of mathematical operations including percentage calculations, number rounding, random number generation, aggregate operations (sum, average, min, max), ratio simplification, and greatest common divisor computation.
Actions
math-percent-calculate
Calculate what percentage one value is of a total.
Required fields:
numbers(array): Exactly 2 numbers — [value, total]
Example:
{
"action": "math-percent-calculate",
"numbers": [25, 200]
}
Returns: "25 is 12.5% of 200"
math-percentage-of
Calculate X% of a given value.
Required fields:
percent(number): The percentage to apply (e.g., 25 for 25%)value(number): The base value
Example:
{
"action": "math-percentage-of",
"percent": 15,
"value": 200
}
Returns: "15% of 200 = 30"
math-percent-increase
Calculate the percent increase from an original value to a new value.
Required fields:
numbers(array): Exactly 2 numbers — [original, new]
Example:
{
"action": "math-percent-increase",
"numbers": [100, 150]
}
Returns: "100 to 150 is a 50% increase"
math-percent-decrease
Calculate the percent decrease from an original value to a new value.
Required fields:
numbers(array): Exactly 2 numbers — [original, new]
Example:
{
"action": "math-percent-decrease",
"numbers": [200, 150]
}
Returns: "200 to 150 is a 25% decrease"
math-ratio-calculate
Simplify the ratio between two or more numbers.
Required fields:
numbers(array): 2 or more numbers
Example:
{
"action": "math-ratio-calculate",
"numbers": [10, 25, 50]
}
Returns: Simplified ratio "2:5:10"
math-round-number
Round a number to a specified number of decimal places.
Required fields:
value(number): The number to round
Optional fields:
decimals(integer, 0-10): Decimal places. Default: 2
Example:
{
"action": "math-round-number",
"value": 3.14159,
"decimals": 3
}
Returns: 3.142
math-random-number
Generate a random floating-point number within a range.
Required fields:
min_value(number): Minimum value (inclusive)max_value(number): Maximum value (must be greater than min_value)
Optional fields:
decimals(integer, 0-10): Decimal places for the result. Default: 2
Example:
{
"action": "math-random-number",
"min_value": 1.0,
"max_value": 100.0,
"decimals": 4
}
Returns: A random float between 1.0 and 100.0 with 4 decimal places
math-random-integer
Generate a random integer within a range (inclusive on both ends).
Required fields:
min_value(number): Minimum integer value (inclusive)max_value(number): Maximum integer value (inclusive, must be greater than min_value)
Example:
{
"action": "math-random-integer",
"min_value": 1,
"max_value": 100
}
Returns: A random integer between 1 and 100
math-sum
Calculate the sum of an array of numbers.
Required fields:
numbers(array): 1 or more numbers
Example:
{
"action": "math-sum",
"numbers": [10, 20, 30, 40, 50]
}
Returns: 150
math-average
Calculate the arithmetic mean of an array of numbers.
Required fields:
numbers(array): 1 or more numbers
Example:
{
"action": "math-average",
"numbers": [85, 90, 78, 92, 88]
}
Returns: 86.6
math-min
Find the minimum (smallest) value in an array of numbers.
Required fields:
numbers(array): 1 or more numbers
Example:
{
"action": "math-min",
"numbers": [45, 12, 67, 3, 89]
}
Returns: 3 (at index 3)
math-max
Find the maximum (largest) value in an array of numbers.
Required fields:
numbers(array): 1 or more numbers
Example:
{
"action": "math-max",
"numbers": [45, 12, 67, 3, 89]
}
Returns: 89 (at index 4)
math-gcd
Calculate the greatest common divisor (GCD) of an array of integers.
Required fields:
numbers(array): 1 or more integers (decimal values are converted to integers)
Example:
{
"action": "math-gcd",
"numbers": [48, 36, 24]
}
Returns: GCD is 12
Common Workflows
Price discount calculation
- Use
math-percentage-ofto calculate the discount amount (e.g., 20% of $150) - Use
math-sumwith a negative discount to get the final price
Comparing performance metrics
- Use
math-percent-increaseormath-percent-decreaseto compare two periods - Use
math-averageto find the mean across multiple data points
Statistical summary of a dataset
- Use
math-sumfor the total - Use
math-averagefor the mean - Use
math-minandmath-maxfor the range
Random selection
- Use
math-random-integerfor picking random IDs or indices - Use
math-random-numberfor generating random decimal values (e.g., test data)
Important Notes
- Division by zero is handled gracefully with descriptive error messages (e.g., percent-calculate with total=0)
- The
numbersarray order matters for percentage and ratio operations — check each action's description for the expected order - GCD values are converted to integers before calculation
- Random number generation requires min_value to be strictly less than max_value
- All results include a human-readable
formattedorcalculationstring for easy display







