Arithmetic Calculator
enhancedtoolkits.calculators.arithmetic.ArithmeticCalculatorTools ¶
Bases: BaseCalculatorTools
Calculator for basic arithmetic operations.
Source code in src/enhancedtoolkits/calculators/arithmetic.py
Functions¶
add ¶
Add two numbers and return the result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a | float | First number | required |
b | float | Second number | required |
Returns:
Type | Description |
---|---|
str | JSON string containing addition result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
subtract ¶
Subtract second number from first and return the result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a | float | First number | required |
b | float | Second number | required |
Returns:
Type | Description |
---|---|
str | JSON string containing subtraction result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
multiply ¶
Multiply two numbers and return the result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a | float | First number | required |
b | float | Second number | required |
Returns:
Type | Description |
---|---|
str | JSON string containing multiplication result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
divide ¶
Divide first number by second and return the result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a | float | Numerator | required |
b | float | Denominator | required |
Returns:
Type | Description |
---|---|
str | JSON string containing division result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
exponentiate ¶
Raise first number to the power of the second number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a | float | Base | required |
b | float | Exponent | required |
Returns:
Type | Description |
---|---|
str | JSON string containing exponentiation result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
square_root ¶
Calculate the square root of a number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n | float | Number to calculate square root of | required |
Returns:
Type | Description |
---|---|
str | JSON string containing square root result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
factorial ¶
Calculate the factorial of a number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n | int | Number to calculate factorial of (must be non-negative integer) | required |
Returns:
Type | Description |
---|---|
str | JSON string containing factorial result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
is_prime ¶
Check if a number is prime.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n | int | Number to check for primality | required |
Returns:
Type | Description |
---|---|
str | JSON string containing prime check result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
modulo ¶
Calculate the remainder when a is divided by b.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a | float | Dividend | required |
b | float | Divisor | required |
Returns:
Type | Description |
---|---|
str | JSON string containing modulo result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
absolute ¶
Calculate the absolute value of a number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n | float | Number to find absolute value of | required |
Returns:
Type | Description |
---|---|
str | JSON string containing absolute value result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
round_number ¶
Round a number to specified decimal places.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n | float | Number to round | required |
decimals | int | Number of decimal places (default: 0) | 0 |
Returns:
Type | Description |
---|---|
str | JSON string containing rounded number result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
log ¶
Calculate logarithm with specified base.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n | float | Number to calculate logarithm of | required |
base | float | Logarithm base (default: 10.0) | 10.0 |
Returns:
Type | Description |
---|---|
str | JSON string containing logarithm result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
ln ¶
Calculate natural logarithm (base e).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n | float | Number to calculate natural logarithm of | required |
Returns:
Type | Description |
---|---|
str | JSON string containing natural logarithm result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
gcd ¶
Calculate greatest common divisor of two integers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a | int | First integer | required |
b | int | Second integer | required |
Returns:
Type | Description |
---|---|
str | JSON string containing GCD result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
lcm ¶
Calculate least common multiple of two integers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a | int | First integer | required |
b | int | Second integer | required |
Returns:
Type | Description |
---|---|
str | JSON string containing LCM result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
mean ¶
Calculate arithmetic mean of a list of numbers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
numbers | List[float] | List of numbers | required |
Returns:
Type | Description |
---|---|
str | JSON string containing mean result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
median ¶
Calculate median of a list of numbers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
numbers | List[float] | List of numbers | required |
Returns:
Type | Description |
---|---|
str | JSON string containing median result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
standard_deviation ¶
Calculate standard deviation of a list of numbers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
numbers | List[float] | List of numbers | required |
Returns:
Type | Description |
---|---|
str | JSON string containing standard deviation result |
Source code in src/enhancedtoolkits/calculators/arithmetic.py
get_llm_usage_instructions staticmethod
¶
Returns detailed instructions for LLMs on how to use basic arithmetic operations.
Source code in src/enhancedtoolkits/calculators/arithmetic.py
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 |
|