math_formulas¶
shortfx.fxExcel.math_formulas
¶
Excel-compatible mathematical and trigonometric functions.
Functions¶
ABS(number: float) -> float
¶
Returns the absolute value of a number.
Description
Returns the absolute (positive) value of a number. Equivalent to Excel's ABS function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The number for which to calculate the absolute value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The absolute value of the number. |
Usage Example
ABS(-5.5) 5.5 ABS(3) 3
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ACOS(number: float) -> float
¶
Returns the arccosine of a number in radians.
Description
Returns the inverse cosine (arccosine) of a number. The result is in radians between 0 and π. Equivalent to Excel's ACOS function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The cosine value, must be between -1 and 1. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The arccosine in radians. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is not between -1 and 1. |
Usage Example
ACOS(0.5) 1.0471975511965979 ACOS(1) 0.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ACOSH(number: float) -> float
¶
Returns the inverse hyperbolic cosine of a number.
Description
Returns the inverse hyperbolic cosine. Equivalent to Excel's ACOSH function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
A number greater than or equal to 1. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic cosine. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is less than 1. |
Usage Example
ACOSH(1) 0.0 ACOSH(10) 2.993222846126381
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ACOT(number: float) -> float
¶
Returns the arccotangent of a number in radians.
Description
Returns the inverse cotangent (arccotangent) of a number. Equivalent to Excel's ACOT function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The cotangent value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The arccotangent in radians. |
Usage Example
ACOT(1) 0.7853981633974483 ACOT(2) 0.4636476090008061
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ACOTH(number: float) -> float
¶
Returns the inverse hyperbolic cotangent of a number.
Description
Returns the inverse hyperbolic cotangent. Equivalent to Excel's ACOTH function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
A number where |number| > 1. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic cotangent. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |number| <= 1. |
Usage Example
ACOTH(2) 0.5493061443340548 ACOTH(-2) -0.5493061443340548
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
AGGREGATE(data: List[Union[int, float]], operation: str = 'sum') -> float
¶
Returns an aggregate calculation from a list.
Description
Performs aggregate operations on a list of numbers. Similar to Excel's AGGREGATE function (simplified version).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
List[Union[int, float]]
|
List of numbers to aggregate. |
required |
operation
|
str
|
Operation type: 'sum', 'avg', 'max', or 'min'. |
'sum'
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The aggregated result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If list is empty or operation is invalid. |
Usage Example
AGGREGATE([1, 2, 3, 4, 5], "sum") 15 AGGREGATE([1, 2, 3, 4, 5], "avg") 3.0 AGGREGATE([1, 2, 3, 4, 5], "max") 5
Cost: O(n) where n is the length of data
Source code in shortfx/fxExcel/math_formulas.py
ARABIC(roman: str) -> int
¶
Converts a Roman numeral to an Arabic number.
Description
Converts text in Roman numeral format to an Arabic numeral. Equivalent to Excel's ARABIC function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roman
|
str
|
A valid Roman numeral string. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The Arabic numeral equivalent. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the string is not a valid Roman numeral. |
Usage Example
ARABIC('MCMLXXXIV') 1984 ARABIC('CDXCIX') 499
Cost: O(n) where n is the length of the Roman numeral
Source code in shortfx/fxExcel/math_formulas.py
ASIN(number: float) -> float
¶
Returns the arcsine of a number in radians.
Description
Returns the inverse sine (arcsine) of a number. The result is in radians between -π/2 and π/2. Equivalent to Excel's ASIN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The sine value, must be between -1 and 1. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The arcsine in radians. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is not between -1 and 1. |
Usage Example
ASIN(0.5) 0.5235987755982989 ASIN(1) 1.5707963267948966
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ASINH(number: float) -> float
¶
Returns the inverse hyperbolic sine of a number.
Description
Returns the inverse hyperbolic sine. Equivalent to Excel's ASINH function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
Any real number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic sine. |
Usage Example
ASINH(1) 0.881373587019543 ASINH(-1) -0.881373587019543
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ATAN(number: float) -> float
¶
Returns the arctangent of a number in radians.
Description
Returns the inverse tangent (arctangent) of a number. The result is in radians between -π/2 and π/2. Equivalent to Excel's ATAN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The tangent value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The arctangent in radians. |
Usage Example
ATAN(1) 0.7853981633974483 ATAN(0) 0.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ATAN2(x: float, y: float) -> float
¶
Returns the arctangent from x and y coordinates.
Description
Returns the arctangent of the specified x and y coordinates. Equivalent to Excel's ATAN2 function (note: Excel uses x, y order).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The x-coordinate. |
required |
y
|
float
|
The y-coordinate. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The arctangent in radians. |
Usage Example
ATAN2(1, 1) 0.7853981633974483 ATAN2(1, 0) 1.5707963267948966
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ATANH(number: float) -> float
¶
Returns the inverse hyperbolic tangent of a number.
Description
Returns the inverse hyperbolic tangent. Equivalent to Excel's ATANH function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
A number between -1 and 1 (exclusive). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic tangent. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is not in the range (-1, 1). |
Usage Example
ATANH(0.5) 0.5493061443340548 ATANH(-0.5) -0.5493061443340548
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
BASE(number: int, radix: int, min_length: int = 0) -> str
¶
Converts a number to text representation with a given base.
Description
Converts a number into a text representation with the specified base. Equivalent to Excel's BASE function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
int
|
The number to convert (must be non-negative). |
required |
radix
|
int
|
The base to convert to (between 2 and 36). |
required |
min_length
|
int
|
Minimum length of returned string (pads with zeros). |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Text representation in the specified base. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If base is not between 2 and 36, or number is negative. |
Usage Example
BASE(7, 2) '111' BASE(100, 16) '64' BASE(15, 2, 8) '00001111'
Cost: O(log n) where n is the number
Source code in shortfx/fxExcel/math_formulas.py
CEILING(number: float, significance: float = 1) -> float
¶
Rounds a number up to the nearest multiple of significance.
Description
Rounds a number up, away from zero, to the nearest multiple of significance. Equivalent to Excel's CEILING function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The value to round. |
required |
significance
|
float
|
The multiple to which to round. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The rounded value. |
Usage Example
CEILING(2.5, 1) 3.0 CEILING(4.3, 0.5) 4.5 CEILING(-2.5, -1) -2.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
CEILING_MATH(number: float, significance: float = 1, mode: int = 0) -> float
¶
Rounds a number up to nearest multiple with mode control.
Description
Rounds a number up to the nearest integer or multiple of significance. Equivalent to Excel's CEILING.MATH function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The value to round. |
required |
significance
|
float
|
The multiple to which to round (default 1). |
1
|
mode
|
int
|
For negative numbers: 0 = away from zero, 1 = toward zero. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The rounded value. |
Usage Example
CEILING_MATH(2.5) 3.0 CEILING_MATH(-2.5, 1, 0) -2.0 CEILING_MATH(-2.5, 1, 1) -3.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
CEILING_PRECISE(number: float, significance: float = 1) -> float
¶
Rounds a number up to nearest multiple (always away from zero).
Description
Rounds a number up to the nearest integer or multiple of significance, regardless of sign. Equivalent to Excel's CEILING.PRECISE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The value to round. |
required |
significance
|
float
|
The multiple to which to round (default 1). |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The rounded value. |
Usage Example
CEILING_PRECISE(2.5, 1) 3.0 CEILING_PRECISE(-2.5, 1) -2.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
COMBIN(n: int, k: int) -> int
¶
Returns the number of combinations for given items.
Description
Returns the number of combinations (without repetition) for a given number of items. Equivalent to Excel's COMBIN function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Total number of items (must be >= 0). |
required |
k
|
int
|
Number of items in each combination (must be 0 <= k <= n). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of combinations. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If n < 0, k < 0, or k > n. |
Usage Example
COMBIN(5, 2) 10 COMBIN(10, 3) 120
Cost: O(k)
Source code in shortfx/fxExcel/math_formulas.py
COMBINA(n: int, k: int) -> int
¶
Returns the number of combinations with repetitions.
Description
Returns the number of combinations (with repetition) for a given number of items. Equivalent to Excel's COMBINA function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Total number of items (must be >= 0). |
required |
k
|
int
|
Number of items in each combination (must be >= 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of combinations with repetition. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If n < 0 or k < 0. |
Usage Example
COMBINA(4, 3) 20 COMBINA(3, 2) 6
Cost: O(k)
Source code in shortfx/fxExcel/math_formulas.py
COS(number: float) -> float
¶
Returns the cosine of an angle in radians.
Description
Returns the cosine of the specified angle. Equivalent to Excel's COS function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The cosine of the angle. |
Usage Example
COS(0) 1.0 COS(math.pi) -1.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
COSH(number: float) -> float
¶
Returns the hyperbolic cosine of a number.
Description
Returns the hyperbolic cosine. Equivalent to Excel's COSH function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
Any real number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic cosine. |
Usage Example
COSH(0) 1.0 COSH(1) 1.5430806348152437
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
COT(number: float) -> float
¶
Returns the cotangent of an angle in radians.
Description
Returns the cotangent of the specified angle. Equivalent to Excel's COT function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The cotangent of the angle. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If cotangent is undefined at this angle. |
Usage Example
COT(math.pi/4) 1.0 COT(math.pi/6) 1.7320508075688772
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
COTH(number: float) -> float
¶
Returns the hyperbolic cotangent of a number.
Description
Returns the hyperbolic cotangent. Equivalent to Excel's COTH function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
Any real number (except 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic cotangent. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is 0. |
Usage Example
COTH(1) 1.3130352854993313 COTH(2) 1.0373147207275482
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
CSC(number: float) -> float
¶
Returns the cosecant of an angle in radians.
Description
Returns the cosecant of the specified angle. Equivalent to Excel's CSC function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The cosecant of the angle. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If cosecant is undefined at this angle. |
Usage Example
CSC(math.pi/2) 1.0 CSC(math.pi/6) 2.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
CSCH(number: float) -> float
¶
Returns the hyperbolic cosecant of a number.
Description
Returns the hyperbolic cosecant. Equivalent to Excel's CSCH function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
Any real number (except 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic cosecant. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is 0. |
Usage Example
CSCH(1) 0.8509181282393216 CSCH(2) 0.27572056477178325
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
DECIMAL(text: str, radix: int) -> int
¶
Converts text representation of number in given base to decimal.
Description
Converts a text string that represents a number in a given base to its decimal (base 10) equivalent. Equivalent to Excel's DECIMAL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text representation of the number. |
required |
radix
|
int
|
The base of the number (between 2 and 36). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The decimal equivalent. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If base is not between 2 and 36, or text is invalid. |
Usage Example
DECIMAL("111", 2) 7 DECIMAL("FF", 16) 255
Cost: O(n) where n is the length of text
Source code in shortfx/fxExcel/math_formulas.py
DEGREES(angle: float) -> float
¶
Converts radians to degrees.
Description
Converts an angle in radians to degrees. Equivalent to Excel's DEGREES function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle
|
float
|
An angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The angle in degrees. |
Usage Example
DEGREES(math.pi) 180.0 DEGREES(math.pi/2) 90.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
EVEN(number: float) -> int
¶
Rounds a number up to the nearest even integer.
Description
Rounds a number up to the nearest even integer. Positive numbers round up, negative numbers round down (away from zero). Equivalent to Excel's EVEN function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The value to round. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The nearest even integer. |
Usage Example
EVEN(1.5) 2 EVEN(3) 4 EVEN(-1) -2
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
EXP(number: float) -> float
¶
Returns e raised to the power of a number.
Description
Returns the constant e (approximately 2.71828) raised to the power of a number. Equivalent to Excel's EXP function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The exponent. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
e^number. |
Usage Example
EXP(1) 2.718281828459045 EXP(0) 1.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
FACT(number: int) -> int
¶
Returns the factorial of a number.
Description
Returns the factorial of a number (n!). Equivalent to Excel's FACT function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
int
|
A non-negative integer. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The factorial. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is negative. |
Usage Example
FACT(5) 120 FACT(0) 1
Cost: O(n)
Source code in shortfx/fxExcel/math_formulas.py
FACTDOUBLE(number: int) -> int
¶
Returns the double factorial of a number.
Description
Returns the double factorial of a number (n!!). For even numbers, multiplies all even integers; for odd, multiplies all odd integers. Equivalent to Excel's FACTDOUBLE function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
int
|
A non-negative integer. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The double factorial. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is negative. |
Usage Example
FACTDOUBLE(6) 48 FACTDOUBLE(5) 15
Cost: O(n)
Source code in shortfx/fxExcel/math_formulas.py
FLOOR(number: float, significance: float = 1) -> float
¶
Rounds a number down to the nearest multiple of significance.
Description
Rounds a number down, toward zero, to the nearest multiple of significance. Equivalent to Excel's FLOOR function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The value to round. |
required |
significance
|
float
|
The multiple to which to round. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The rounded value. |
Usage Example
FLOOR(3.7, 1) 3.0 FLOOR(2.5, 0.1) 2.5
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
FLOOR_MATH(number: float, significance: float = 1, mode: int = 0) -> float
¶
Rounds a number down to nearest multiple with mode control.
Description
Rounds a number down to the nearest integer or multiple of significance. Equivalent to Excel's FLOOR.MATH function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The value to round. |
required |
significance
|
float
|
The multiple to which to round (default 1). |
1
|
mode
|
int
|
For negative numbers: 0 = toward zero, 1 = away from zero. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The rounded value. |
Usage Example
FLOOR_MATH(3.7) 3.0 FLOOR_MATH(-2.5, 1, 0) -2.0 FLOOR_MATH(-2.5, 1, 1) -3.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
FLOOR_PRECISE(number: float, significance: float = 1) -> float
¶
Rounds a number down to nearest multiple (always toward zero).
Description
Rounds a number down to the nearest integer or multiple of significance, regardless of sign. Equivalent to Excel's FLOOR.PRECISE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The value to round. |
required |
significance
|
float
|
The multiple to which to round (default 1). |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The rounded value. |
Usage Example
FLOOR_PRECISE(3.7, 1) 3.0 FLOOR_PRECISE(-2.5, 1) -2.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
GCD(*numbers: int) -> int
¶
Returns the greatest common divisor of integers.
Description
Returns the greatest common divisor of two or more integers. Equivalent to Excel's GCD function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*numbers
|
int
|
One or more integers. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The greatest common divisor. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no numbers are provided. |
Usage Example
GCD(12, 18) 6 GCD(15, 25, 35) 5
Cost: O(n * log(min)) where n is number count
Source code in shortfx/fxExcel/math_formulas.py
INT(number: float) -> int
¶
Rounds a number down to the nearest integer.
Description
Rounds a number down to the nearest integer (toward negative infinity). Equivalent to Excel's INT function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The value to round. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The nearest integer (rounded down). |
Usage Example
INT(8.9) 8 INT(-8.9) -9
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ISO_CEILING(number: float, significance: float = 1) -> float
¶
Rounds a number up to nearest multiple (ISO standard).
Description
Rounds a number up to the nearest integer or multiple of significance. Equivalent to Excel's ISO.CEILING function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The value to round. |
required |
significance
|
float
|
The multiple to which to round (default 1). |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The rounded value. |
Usage Example
ISO_CEILING(2.5) 3.0 ISO_CEILING(-2.5) -2.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
LCM(*numbers: int) -> int
¶
Returns the least common multiple of integers.
Description
Returns the least common multiple of two or more integers. Equivalent to Excel's LCM function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*numbers
|
int
|
One or more integers. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The least common multiple. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no numbers are provided. |
Usage Example
LCM(12, 18) 36 LCM(4, 6, 8) 24
Cost: O(n * log(min)) where n is number count
Source code in shortfx/fxExcel/math_formulas.py
LN(number: float) -> float
¶
Returns the natural logarithm of a number.
Description
Returns the natural logarithm (base e) of a number. Equivalent to Excel's LN function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
A positive number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The natural logarithm. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is not positive. |
Usage Example
LN(math.e) 1.0 LN(10) 2.302585092994046
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
LOG(number: float, base: float = 10) -> float
¶
Returns the logarithm of a number to a specified base.
Description
Returns the logarithm of a number to the specified base. Equivalent to Excel's LOG function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
A positive number. |
required |
base
|
float
|
The base of the logarithm (default 10). |
10
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The logarithm. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number <= 0, base <= 0, or base = 1. |
Usage Example
LOG(100, 10) 2.0 LOG(8, 2) 3.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
LOG10(number: float) -> float
¶
Returns the base-10 logarithm of a number.
Description
Returns the common (base 10) logarithm of a number. Equivalent to Excel's LOG10 function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
A positive number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The base-10 logarithm. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is not positive. |
Usage Example
LOG10(100) 2.0 LOG10(1000) 3.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
MDETERM(matrix: List[List[float]]) -> float
¶
Returns the matrix determinant of an array.
Description
Returns the determinant of a square matrix. Equivalent to Excel's MDETERM function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
List[List[float]]
|
A square matrix. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The determinant. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If matrix is not square. |
Usage Example
MDETERM([[1, 2], [3, 4]]) -2.0 MDETERM([[2, 0], [0, 2]]) 4.0
Cost: O(n³) where n is matrix dimension
Source code in shortfx/fxExcel/math_formulas.py
MINVERSE(matrix: List[List[float]]) -> List[List[float]]
¶
Returns the inverse of a square matrix.
Description
Returns the inverse matrix of a given square matrix. Equivalent to Excel's MINVERSE function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
List[List[float]]
|
A square, invertible matrix. |
required |
Returns:
| Type | Description |
|---|---|
List[List[float]]
|
List[List[float]]: The inverse matrix. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If matrix is not square or not invertible. |
Usage Example
MINVERSE([[1, 2], [3, 4]]) [[-2.0, 1.0], [1.5, -0.5]]
Cost: O(n³) where n is matrix dimension
Source code in shortfx/fxExcel/math_formulas.py
MMULT(matrix1: List[List[float]], matrix2: List[List[float]]) -> List[List[float]]
¶
Returns the matrix product of two arrays.
Description
Returns the matrix product of two arrays. The result is an array with the same number of rows as matrix1 and columns as matrix2. Equivalent to Excel's MMULT function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix1
|
List[List[float]]
|
The first matrix. |
required |
matrix2
|
List[List[float]]
|
The second matrix. |
required |
Returns:
| Type | Description |
|---|---|
List[List[float]]
|
List[List[float]]: The matrix product. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If matrices cannot be multiplied (columns of matrix1 must equal rows of matrix2). |
Usage Example
MMULT([[1, 2], [3, 4]], [[5, 6], [7, 8]]) [[19, 22], [43, 50]] MMULT([[1, 2, 3]], [[4], [5], [6]]) [[32]]
Cost: O(n * m * p) where n, m, p are matrix dimensions
Source code in shortfx/fxExcel/math_formulas.py
MOD(number: float, divisor: float) -> float
¶
Returns the remainder from division.
Description
Returns the remainder after a number is divided by a divisor. The result has the same sign as the divisor. Equivalent to Excel's MOD function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The number to divide. |
required |
divisor
|
float
|
The divisor (cannot be zero). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The remainder. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If divisor is zero. |
Usage Example
MOD(10, 3) 1.0 MOD(-10, 3) 2.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
MROUND(number: float, multiple: float) -> float
¶
Rounds a number to the nearest multiple.
Description
Rounds a number to the nearest multiple of a specified value. Equivalent to Excel's MROUND function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The number to round. |
required |
multiple
|
float
|
The multiple to which to round. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The rounded number. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number and multiple have different signs. |
Usage Example
MROUND(10, 3) 9.0 MROUND(1.3, 0.2) 1.4 MROUND(-10, -3) -9.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
MULTINOMIAL(*numbers: int) -> int
¶
Returns the multinomial of a set of numbers.
Description
Returns the ratio of the factorial of a sum of values to the product of factorials. Equivalent to Excel's MULTINOMIAL function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*numbers
|
int
|
One or more non-negative integers. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The multinomial coefficient. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any number is negative. |
Usage Example
MULTINOMIAL(2, 3, 4) 1260 MULTINOMIAL(3, 3) 20
Cost: O(n) where n is the sum of all numbers
Source code in shortfx/fxExcel/math_formulas.py
MUNIT(dimension: int) -> List[List[float]]
¶
Returns the identity matrix for the specified dimension.
Description
Returns a square identity matrix of the specified size. Equivalent to Excel's MUNIT function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension
|
int
|
The size of the identity matrix (must be positive). |
required |
Returns:
| Type | Description |
|---|---|
List[List[float]]
|
List[List[float]]: The identity matrix. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If dimension is not positive. |
Usage Example
MUNIT(3) [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]] MUNIT(2) [[1.0, 0.0], [0.0, 1.0]]
Cost: O(n²) where n is the dimension
Source code in shortfx/fxExcel/math_formulas.py
ODD(number: float) -> int
¶
Rounds a number up to the nearest odd integer.
Description
Rounds a number up to the nearest odd integer. Positive numbers round up, negative numbers round down (away from zero). Equivalent to Excel's ODD function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The value to round. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The nearest odd integer. |
Usage Example
ODD(1.5) 3 ODD(2) 3 ODD(-2) -3
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
PI() -> float
¶
Returns the value of pi (π).
Description
Returns the mathematical constant π (pi), accurate to 15 digits. Equivalent to Excel's PI function.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The value of π. |
Usage Example
PI() 3.141592653589793
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
POWER(number: float, power: float) -> float
¶
Returns the result of a number raised to a power.
Description
Returns the result of a number raised to a power. Equivalent to Excel's POWER function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The base number. |
required |
power
|
float
|
The exponent. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
number^power. |
Usage Example
POWER(5, 2) 25.0 POWER(2, 0.5) 1.4142135623730951
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
PRODUCT(*numbers: Union[float, List[float]]) -> float
¶
Returns the product of numbers.
Description
Multiplies all the numbers given as arguments and returns the product. Equivalent to Excel's PRODUCT function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*numbers
|
Union[float, List[float]]
|
One or more numbers or lists of numbers to multiply. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The product of all numbers. |
Usage Example
PRODUCT(5, 15, 30) 2250 PRODUCT([2, 3], 4) 24 PRODUCT([1, 2, 3, 4]) 24
Cost: O(n) where n is total number of values
Source code in shortfx/fxExcel/math_formulas.py
QUOTIENT(numerator: float, denominator: float) -> int
¶
Returns the integer portion of a division.
Description
Returns the integer portion of a division, discarding the remainder. Equivalent to Excel's QUOTIENT function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
numerator
|
float
|
The dividend. |
required |
denominator
|
float
|
The divisor. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The integer part of the division. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If denominator is zero. |
Usage Example
QUOTIENT(10, 3) 3 QUOTIENT(-10, 3) -3 QUOTIENT(5.5, 2) 2
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
RADIANS(angle: float) -> float
¶
Converts degrees to radians.
Description
Converts an angle in degrees to radians. Equivalent to Excel's RADIANS function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle
|
float
|
An angle in degrees. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The angle in radians. |
Usage Example
RADIANS(180) 3.141592653589793 RADIANS(90) 1.5707963267948966
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
RAND() -> float
¶
Returns a random number between 0 and 1.
Description
Returns an evenly distributed random real number greater than or equal to 0 and less than 1. Equivalent to Excel's RAND function.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
A random number between 0 and 1. |
Usage Example
result = RAND() 0 <= result < 1 True
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
RANDARRAY(rows: int = 1, columns: int = 1, min_val: float = 0, max_val: float = 1, whole_number: bool = False) -> List[List[float]]
¶
Returns an array of random numbers.
Description
Returns an array of random numbers between 0 and 1. You can specify the number of rows and columns, minimum and maximum values, and whether to return whole numbers or decimal values. Equivalent to Excel's RANDARRAY function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rows
|
int
|
Number of rows (default 1). |
1
|
columns
|
int
|
Number of columns (default 1). |
1
|
min_val
|
float
|
Minimum value (default 0). |
0
|
max_val
|
float
|
Maximum value (default 1). |
1
|
whole_number
|
bool
|
Return integers if True, decimals if False (default False). |
False
|
Returns:
| Type | Description |
|---|---|
List[List[float]]
|
List[List[float]]: Array of random numbers. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If rows or columns are not positive, or min_val >= max_val. |
Usage Example
result = RANDARRAY(2, 3) len(result) == 2 and len(result[0]) == 3 True result = RANDARRAY(2, 2, 1, 10, True) all(1 <= x <= 10 and isinstance(x, (int, float)) for row in result for x in row) True
Cost: O(rows * columns)
Source code in shortfx/fxExcel/math_formulas.py
RANDBETWEEN(bottom: int, top: int) -> int
¶
Returns a random integer between two numbers.
Description
Returns a random integer between the numbers you specify. Equivalent to Excel's RANDBETWEEN function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bottom
|
int
|
The smallest integer to return. |
required |
top
|
int
|
The largest integer to return. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
A random integer between bottom and top (inclusive). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If bottom > top. |
Usage Example
result = RANDBETWEEN(1, 10) 1 <= result <= 10 True result = RANDBETWEEN(-5, 5) -5 <= result <= 5 True
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ROMAN(number: int, form: int = 0) -> str
¶
Converts an Arabic number to Roman numeral as text.
Description
Converts an Arabic numeral to Roman numeral format. Equivalent to Excel's ROMAN function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
int
|
The number to convert (1 to 3999). |
required |
form
|
int
|
Simplification level (0-4, default 0 = classic). |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The Roman numeral. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is not in range 1-3999. |
Usage Example
ROMAN(1984) 'MCMLXXXIV' ROMAN(499) 'CDXCIX'
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ROUND(number: float, num_digits: int = 0) -> float
¶
Rounds a number to a specified number of digits.
Description
Rounds a number to the specified number of decimal places. Equivalent to Excel's ROUND function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The number to round. |
required |
num_digits
|
int
|
Number of decimal places (can be negative). |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The rounded number. |
Usage Example
ROUND(2.15, 1) 2.1 ROUND(2.149, 1) 2.1 ROUND(-1.475, 2) -1.48
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ROUNDDOWN(number: float, num_digits: int = 0) -> float
¶
Rounds a number down (toward zero).
Description
Rounds a number down, toward zero, to a specified number of digits. Equivalent to Excel's ROUNDDOWN function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The number to round down. |
required |
num_digits
|
int
|
Number of decimal places (can be negative). |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The rounded down number. |
Usage Example
ROUNDDOWN(3.14159, 2) 3.14 ROUNDDOWN(-3.14159, 2) -3.14
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
ROUNDUP(number: float, num_digits: int = 0) -> float
¶
Rounds a number up (away from zero).
Description
Rounds a number up, away from zero, to a specified number of digits. Equivalent to Excel's ROUNDUP function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The number to round up. |
required |
num_digits
|
int
|
Number of decimal places (can be negative). |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The rounded up number. |
Usage Example
ROUNDUP(3.14159, 2) 3.15 ROUNDUP(-3.14159, 2) -3.15
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
SEC(number: float) -> float
¶
Returns the secant of an angle in radians.
Description
Returns the secant of the specified angle. Equivalent to Excel's SEC function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The secant of the angle. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If secant is undefined at this angle. |
Usage Example
SEC(0) 1.0 SEC(math.pi/3) 2.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
SECH(number: float) -> float
¶
Returns the hyperbolic secant of a number.
Description
Returns the hyperbolic secant. Equivalent to Excel's SECH function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
Any real number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic secant. |
Usage Example
SECH(0) 1.0 SECH(1) 0.6480542736638855
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
SEQUENCE(rows: int, columns: int = 1, start: float = 1, step: float = 1) -> List[List[float]]
¶
Generates a list of sequential numbers in an array.
Description
Generates a list of sequential numbers in an array, such as 1, 2, 3, 4. Equivalent to Excel's SEQUENCE function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rows
|
int
|
Number of rows to return. |
required |
columns
|
int
|
Number of columns to return (default 1). |
1
|
start
|
float
|
First number in the sequence (default 1). |
1
|
step
|
float
|
Amount to increment each value (default 1). |
1
|
Returns:
| Type | Description |
|---|---|
List[List[float]]
|
List[List[float]]: Array of sequential numbers. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If rows or columns are not positive. |
Usage Example
SEQUENCE(3) [[1], [2], [3]] SEQUENCE(2, 3, 0, 5) [[0, 5, 10], [15, 20, 25]] SEQUENCE(1, 4, 10, -2) [[10, 8, 6, 4]]
Cost: O(rows * columns)
Source code in shortfx/fxExcel/math_formulas.py
SERIESSUM(x: float, n: int, m: int, coefficients: List[float]) -> float
¶
Returns the sum of a power series.
Description
Returns the sum of a power series based on the formula: SERIESSUM(x,n,m,a) = a1x^n + a2x^(n+m) + a3x^(n+2m) + ... + aix^(n+(i-1)m) Equivalent to Excel's SERIESSUM function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The input value to the power series. |
required |
n
|
int
|
The initial power to which x is raised. |
required |
m
|
int
|
The step by which to increase n for each term. |
required |
coefficients
|
List[float]
|
Array of coefficients. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The sum of the power series. |
Usage Example
SERIESSUM(2, 1, 2, [1, 1, 1]) 42.0 SERIESSUM(1, 0, 1, [1, 2, 3]) 6.0
Cost: O(k) where k is the number of coefficients
Source code in shortfx/fxExcel/math_formulas.py
SIGN(number: float) -> int
¶
Returns the sign of a number.
Description
Returns 1 if number is positive, -1 if negative, 0 if zero. Equivalent to Excel's SIGN function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
Any real number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The sign (-1, 0, or 1). |
Usage Example
SIGN(10) 1 SIGN(-5) -1 SIGN(0) 0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
SIN(number: float) -> float
¶
Returns the sine of an angle in radians.
Description
Returns the sine of the specified angle. Equivalent to Excel's SIN function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The sine of the angle. |
Usage Example
SIN(math.pi/2) 1.0 SIN(0) 0.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
SINH(number: float) -> float
¶
Returns the hyperbolic sine of a number.
Description
Returns the hyperbolic sine. Equivalent to Excel's SINH function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
Any real number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic sine. |
Usage Example
SINH(1) 1.1752011936438014 SINH(0) 0.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
SQRT(number: float) -> float
¶
Returns the positive square root of a number.
Description
Returns the square root of a number. Equivalent to Excel's SQRT.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
A non-negative number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The square root. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is negative. |
Usage Example
SQRT(16) 4.0 SQRT(2) 1.4142135623730951
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
SQRTPI(number: float) -> float
¶
Returns the square root of (number * pi).
Description
Returns the square root of a number multiplied by π. Equivalent to Excel's SQRTPI function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
A non-negative number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The square root of (number * π). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If number is negative. |
Usage Example
SQRTPI(1) 1.7724538509055159 SQRTPI(2) 2.5066282746310002
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
SUBTOTAL(function_num: int, *values: Union[float, List[float]]) -> float
¶
Returns a subtotal in a list or database.
Description
Returns a subtotal in a list or database using a specified function. Equivalent to Excel's SUBTOTAL function. Function numbers: 1=AVERAGE, 2=COUNT, 3=COUNTA, 4=MAX, 5=MIN, 6=PRODUCT, 7=STDEV, 8=STDEVP, 9=SUM, 10=VAR, 11=VARP
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function_num
|
int
|
Number specifying which function to use (1-11). |
required |
*values
|
Union[float, List[float]]
|
One or more numbers or lists to process. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The calculated subtotal. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If function_num is not between 1 and 11. |
Usage Example
SUBTOTAL(9, [1, 2, 3, 4, 5]) # SUM 15 SUBTOTAL(1, [10, 20, 30]) # AVERAGE 20.0 SUBTOTAL(4, [5, 15, 25]) # MAX 25
Cost: O(n) where n is total number of values
Source code in shortfx/fxExcel/math_formulas.py
2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 | |
SUM(*numbers: Union[float, List[float]]) -> float
¶
Returns the sum of numbers.
Description
Adds all the numbers in a range of cells or provided as arguments. Equivalent to Excel's SUM function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*numbers
|
Union[float, List[float]]
|
One or more numbers or lists of numbers to sum. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The sum of all numbers. |
Usage Example
SUM(1, 2, 3) 6 SUM([1, 2, 3], 4, 5) 15 SUM([10, 20], [30, 40]) 100
Cost: O(n) where n is total number of values
Source code in shortfx/fxExcel/math_formulas.py
SUMIF(values: List[Union[int, float]], criteria: str) -> float
¶
Sums numbers that meet a specified criterion.
Description
Adds the cells specified by a given criteria. Equivalent to Excel's SUMIF function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
List[Union[int, float]]
|
List of numbers to evaluate. |
required |
criteria
|
str
|
Condition as string (e.g., ">10", "<=5", "=3"). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Sum of numbers that meet the criterion. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If criteria format is invalid. |
Usage Example
SUMIF([1, 5, 10, 15, 20], ">10") 35 SUMIF([2, 4, 6, 8, 10], "<=5") 6 SUMIF([1, 2, 3, 4, 5], ">=3") 12
Cost: O(n) where n is the length of values
Source code in shortfx/fxExcel/math_formulas.py
SUMIFS(sum_range: List[Union[int, float]], *criteria_pairs) -> float
¶
Sums values that meet multiple criteria.
Description
Adds cells in a range that meet multiple criteria specified as pairs of (criteria_range, criterion). Equivalent to Excel's SUMIFS function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sum_range
|
List[Union[int, float]]
|
Range of values to sum. |
required |
*criteria_pairs
|
Alternating criteria_range and criterion pairs. Each criteria_range is a list and each criterion is a string (e.g., ">10", "<=5") or a direct value for equality. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Sum of values meeting all criteria. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If criteria are not provided as pairs or ranges differ in length. |
Usage Example
SUMIFS([10, 20, 30, 40], [1, 2, 3, 4], ">1", [5, 15, 25, 35], "<30") 50 SUMIFS([100, 200, 300], ["A", "B", "A"], "A") 400
Cost: O(n * m) where n is range length and m is number of criteria
Source code in shortfx/fxExcel/math_formulas.py
2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 | |
SUMPRODUCT(*arrays: List[Union[int, float]]) -> float
¶
Returns the sum of the products of corresponding array components.
Description
Multiplies corresponding components in the given arrays, and returns the sum of those products. Equivalent to Excel's SUMPRODUCT function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*arrays
|
List[Union[int, float]]
|
Two or more arrays of the same length. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The sum of products. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If arrays have different lengths or no arrays provided. |
Usage Example
SUMPRODUCT([1, 2, 3], [4, 5, 6]) 32 SUMPRODUCT([2, 3], [4, 5], [6, 7]) 69
Cost: O(n * m) where n is array length and m is number of arrays
Source code in shortfx/fxExcel/math_formulas.py
SUMSQ(*numbers: Union[float, List[float]]) -> float
¶
Returns the sum of the squares of the arguments.
Description
Returns the sum of the squares of the arguments. Equivalent to Excel's SUMSQ function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*numbers
|
Union[float, List[float]]
|
One or more numbers or lists of numbers. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The sum of squares. |
Usage Example
SUMSQ(3, 4) 25 SUMSQ([1, 2, 3]) 14 SUMSQ([2, 3], 4) 29
Cost: O(n) where n is total number of values
Source code in shortfx/fxExcel/math_formulas.py
SUMX2MY2(array_x: List[float], array_y: List[float]) -> float
¶
Returns the sum of the difference of squares.
Description
Returns the sum of the difference of squares of corresponding values in two arrays. Formula: Σ(x² - y²) Equivalent to Excel's SUMX2MY2 function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array_x
|
List[float]
|
The first array. |
required |
array_y
|
List[float]
|
The second array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The sum of the difference of squares. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If arrays have different lengths. |
Usage Example
SUMX2MY2([2, 3, 9], [6, 5, 11]) -156 SUMX2MY2([1, 2], [3, 4]) -16
Cost: O(n) where n is array length
Source code in shortfx/fxExcel/math_formulas.py
SUMX2PY2(array_x: List[float], array_y: List[float]) -> float
¶
Returns the sum of the sum of squares.
Description
Returns the sum of the sum of squares of corresponding values in two arrays. Formula: Σ(x² + y²) Equivalent to Excel's SUMX2PY2 function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array_x
|
List[float]
|
The first array. |
required |
array_y
|
List[float]
|
The second array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The sum of the sum of squares. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If arrays have different lengths. |
Usage Example
SUMX2PY2([2, 3, 9], [6, 5, 11]) 344 SUMX2PY2([1, 2], [3, 4]) 30
Cost: O(n) where n is array length
Source code in shortfx/fxExcel/math_formulas.py
SUMXMY2(array_x: List[float], array_y: List[float]) -> float
¶
Returns the sum of squares of differences.
Description
Returns the sum of squares of differences of corresponding values in two arrays. Formula: Σ(x - y)² Equivalent to Excel's SUMXMY2 function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array_x
|
List[float]
|
The first array. |
required |
array_y
|
List[float]
|
The second array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The sum of squares of differences. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If arrays have different lengths. |
Usage Example
SUMXMY2([2, 3, 9], [6, 5, 11]) 24 SUMXMY2([1, 2], [3, 4]) 8
Cost: O(n) where n is array length
Source code in shortfx/fxExcel/math_formulas.py
TAN(number: float) -> float
¶
Returns the tangent of an angle in radians.
Description
Returns the tangent of the specified angle. Equivalent to Excel's TAN function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The tangent of the angle. |
Usage Example
TAN(math.pi/4) 1.0 TAN(0) 0.0
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
TANH(number: float) -> float
¶
Returns the hyperbolic tangent of a number.
Description
Returns the hyperbolic tangent. Equivalent to Excel's TANH function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
Any real number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic tangent. |
Usage Example
TANH(0) 0.0 TANH(1) 0.7615941559557649
Cost: O(1)
Source code in shortfx/fxExcel/math_formulas.py
TRANSPOSE(array: List[List[float]]) -> List[List[float]]
¶
Transposes a matrix (swaps rows and columns).
Excel function: TRANSPOSE
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
List[List[float]]
|
Input matrix. |
required |
Returns:
| Type | Description |
|---|---|
List[List[float]]
|
List[List[float]]: The transposed matrix. |
Usage Example
TRANSPOSE([[1, 2, 3], [4, 5, 6]]) [[1, 4], [2, 5], [3, 6]]
Cost: O(m * n)
Source code in shortfx/fxExcel/math_formulas.py
TRUNC(number: float, num_digits: int = 0) -> float
¶
Truncates a number to an integer by removing decimals.
Description
Truncates a number to an integer by removing the fractional part. Equivalent to Excel's TRUNC function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
float
|
The number to truncate. |
required |
num_digits
|
int
|
Number of decimal places to preserve (default 0). |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The truncated number. |
Usage Example
TRUNC(8.9) 8.0 TRUNC(-8.9) -8.0 TRUNC(8.9876, 2) 8.98
Cost: O(1)