API Reference
Complete reference for all public functions. All functions are accessed via mathfunctionize.functionName() after importing with from mathfunctionize import mathfunctionize.
Constants
The ratio of a circle's circumference to its diameter, approximately 3.14159. Value: 3.141592653589793
Euler's number, the base of the natural logarithm, approximately 2.71828. Value: 2.718281828459045
Arithmetic
Basic arithmetic operations. All functions take a list of numbers and apply the operation across all elements.
Takes a list of numbers and returns the sum of all elements.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers to sum. |
Returns: int | float
mathfunctionize.addition([1, 2, 3]) # 6
Takes a list of numbers and subtracts each subsequent element from the first.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers. The first element is subtracted from by all subsequent elements. |
Returns: int | float
mathfunctionize.subtraction([10, 3, 2]) # 5
Takes a list of numbers and returns the product of all elements.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers to multiply. |
Returns: int | float
mathfunctionize.multiplication([2, 3, 4]) # 24
Takes a list of numbers and divides the first element by each subsequent element.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers. The first element is divided by all subsequent elements. |
Returns: float
mathfunctionize.division([100, 5, 2]) # 10.0
Takes a list of numbers and exponentiates left-to-right.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers to exponentiate sequentially. |
Returns: int | float
mathfunctionize.power([2, 3]) # 8
mathfunctionize.power([2, 3, 2]) # 64
Takes a list of numbers and applies the modulo operator left-to-right.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers. |
Returns: int | float
mathfunctionize.modulo([10, 3]) # 1
Takes a list of numbers and performs floor division left-to-right.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers. |
Returns: int
mathfunctionize.flatDivision([10, 3]) # 3
Algebra
Factorial, gamma function, absolute value, roots, and rounding.
Returns the factorial of a non-negative integer x, i.e. x! = x * (x-1) * ... * 1.
| Parameter | Type | Description |
|---|---|---|
x | int | Non-negative integer. |
Returns: int x!
mathfunctionize.factorial(5) # 120
mathfunctionize.factorial(0) # 1
Computes the gamma function of x, a generalization of the factorial to real and complex numbers where Γ(n) = (n−1)! for positive integers. Raises an exception for zero and negative integers.
| Parameter | Type | Description |
|---|---|---|
x | int | float | Input value. Must not be zero or a negative integer. |
Returns: int | float
Raises: Exception if x is 0 or a negative integer.
mathfunctionize.gamma(5) # 24
mathfunctionize.gamma(0.5) # sqrt(pi) ≈ 1.7724...
Returns the absolute value of x.
| Parameter | Type | Description |
|---|---|---|
x | int | float | Input value. |
Returns: int | float |x|
mathfunctionize.absolute(-7) # 7
mathfunctionize.absolute(3.5) # 3.5
Returns the square root of x.
| Parameter | Type | Description |
|---|---|---|
x | int | float | Non-negative number. |
Returns: float
mathfunctionize.squareRoot(144) # 12.0
Returns the cube root of x.
| Parameter | Type | Description |
|---|---|---|
x | int | float | Input value. |
Returns: float
mathfunctionize.cubeRoot(27) # 3.0
Returns the n-th root of x.
| Parameter | Type | Description |
|---|---|---|
x | int | float | Input value. |
n | int | Root degree. |
Returns: float x1/n
mathfunctionize.nthRoot(625, 4) # 5.0
Rounds x to the nearest specified place value (e.g. 1, 10, 100).
| Parameter | Type | Description |
|---|---|---|
x | int | float | Number to round. |
place | int | Rounding granularity (1, 10, 100, …). |
Returns: int | float
mathfunctionize.round(47, 10) # 50
mathfunctionize.round(123, 100) # 100
Counting
Combinatorial counting functions.
Returns the number of ways to choose r items from n items without regard to order, i.e. n! / (r! * (n-r)!).
| Parameter | Type | Description |
|---|---|---|
n | int | Total items. |
r | int | Items to choose. |
Returns: float
mathfunctionize.combinations(10, 3) # 120.0
Returns the number of ways to arrange r items from n items where order matters, i.e. n! / (n-r)!
| Parameter | Type | Description |
|---|---|---|
n | int | Total items. |
r | int | Items to arrange. |
Returns: float
mathfunctionize.permutations(5, 3) # 60.0
Returns the number of ways to arrange n items in a circle, i.e. (n−1)!
| Parameter | Type | Description |
|---|---|---|
n | int | Number of elements. |
Returns: int
mathfunctionize.circularPermutations(5) # 24
Returns the number of permutations of n elements where no element appears in its original position.
| Parameter | Type | Description |
|---|---|---|
n | int | Number of elements. |
Returns: int
mathfunctionize.derangements(4) # 9
mathfunctionize.derangements(5) # 44
Probability
Probability distributions and Bayes' theorem.
Computes the posterior probability using Bayes' theorem given prior probabilities and likelihoods for two hypotheses.
| Parameter | Type | Description |
|---|---|---|
priorA | float | Prior probability of A. |
priorB | float | Prior probability of B. |
likelihoodA | float | Likelihood of evidence given A. |
likelihoodB | float | Likelihood of evidence given B. |
Returns: float
mathfunctionize.bayes_theorem(0.01, 0.99, 0.9, 0.05)
# 0.154...
Returns the probability density for a continuous uniform distribution over the interval [a, b].
| Parameter | Type | Description |
|---|---|---|
a | float | Lower bound. |
b | float | Upper bound. |
Returns: float 1 / (b − a)
mathfunctionize.uniformPDF(0, 10) # 0.1
Returns the cumulative distribution function value for a uniform distribution, giving the probability that a random variable is less than or equal to X.
| Parameter | Type | Description |
|---|---|---|
X | float | Point to evaluate. |
a | float | Lower bound. |
b | float | Upper bound. |
Returns: float 0 if X < a, 1 if X > b, (X − a)/(b − a) otherwise.
mathfunctionize.uniformCDF(3, 0, 10) # 0.3
Returns the probability density of the normal (Gaussian) distribution at point X given a mean and standard deviation.
| Parameter | Type | Description |
|---|---|---|
X | float | Point to evaluate. |
mean | float | Mean (μ) of the distribution. |
stdDev | float | Standard deviation (σ). |
Returns: float
mathfunctionize.normalPDF(0, 0, 1) # 0.3989... (standard normal at 0)
Returns the cumulative distribution function value for the normal distribution, approximating the probability that a random variable is less than or equal to x.
| Parameter | Type | Description |
|---|---|---|
x | float | Point to evaluate. |
mean | float | Mean (μ) of the distribution. |
stdDev | float | Standard deviation (σ). |
Returns: float
mathfunctionize.normalCDF(0, 0, 1) # 0.5 (50th percentile)
Returns the probability density of the gamma distribution at point x with shape parameter a and rate parameter b.
| Parameter | Type | Description |
|---|---|---|
x | float | Point to evaluate (x > 0). |
a | float | Shape parameter (α). |
b | float | Rate parameter (β). |
Returns: float
mathfunctionize.gammaPDF(2, 2, 1) # ~0.2706...
Complex Numbers
Operations on complex numbers represented as strings (e.g. "3+4i", "2-1i").
Adds two complex numbers given as strings.
| Parameter | Type | Description |
|---|---|---|
a | str | First complex number (e.g. "3+4i"). |
b | str | Second complex number. |
Returns: str the sum as a complex number string.
mathfunctionize.complex_addition("3+4i", "1+2i") # "4.0+6.0i"
mathfunctionize.complex_addition("5-3i", "2+1i") # "7.0-2.0i"
Subtracts the second complex number from the first. Both given as strings.
| Parameter | Type | Description |
|---|---|---|
a | str | First complex number. |
b | str | Second complex number. |
Returns: str the difference as a complex number string.
mathfunctionize.complex_subtraction("5+3i", "2+1i") # "3.0+2.0i"
Trigonometry
Trigonometric functions computed via Taylor series expansions. Angles in radians unless otherwise noted.
Returns the sine of x (in radians) using a Taylor series approximation. sin is a shorthand alias for sine.
| Parameter | Type | Description |
|---|---|---|
x | float | Angle in radians. |
Returns: float
mathfunctionize.sin(mathfunctionize.pi / 2) # ~1.0
Returns the cosine of x (in radians) using a Taylor series approximation.
| Parameter | Type | Description |
|---|---|---|
x | float | Angle in radians. |
Returns: float
mathfunctionize.cos(0) # ~1.0
Returns the tangent of x (in radians), computed as sine(x) / cosine(x). Raises an exception if cos(x) = 0.
| Parameter | Type | Description |
|---|---|---|
x | float | Angle in radians. |
Returns: float
Raises: Exception if cos(x) = 0.
mathfunctionize.tan(mathfunctionize.pi / 4) # ~1.0
Returns the cosecant of x (in radians), computed as 1 / sine(x). Raises an exception if sin(x) = 0.
| Parameter | Type | Description |
|---|---|---|
x | float | Angle in radians. |
Returns: float
mathfunctionize.csc(mathfunctionize.pi / 2) # ~1.0
Returns the secant of x (in radians), computed as 1 / cosine(x). Raises an exception if cos(x) = 0.
| Parameter | Type | Description |
|---|---|---|
x | float | Angle in radians. |
Returns: float
mathfunctionize.sec(0) # ~1.0
Returns the cotangent of x (in radians), computed as cosine(x) / sine(x). Raises an exception if sin(x) = 0.
| Parameter | Type | Description |
|---|---|---|
x | float | Angle in radians. |
Returns: float
mathfunctionize.cot(mathfunctionize.pi / 4) # ~1.0
Returns the inverse sine of x (where -1 <= x <= 1) using a Taylor series approximation.
| Parameter | Type | Description |
|---|---|---|
x | float | Value in [−1, 1]. |
Returns: float angle in radians.
Raises: Exception if x is outside [−1, 1].
mathfunctionize.arcsine(0.5) # ~0.5236... (≈ π/6)
Returns the inverse cosine of x (where -1 <= x <= 1) using a Taylor series approximation.
| Parameter | Type | Description |
|---|---|---|
x | float | Value in [−1, 1]. |
Returns: float angle in radians.
Raises: Exception if x is outside [−1, 1].
mathfunctionize.arccosine(0.5) # ~1.0472... (≈ π/3)
Returns the inverse tangent of x (where -1 <= x <= 1) using a Taylor series approximation.
| Parameter | Type | Description |
|---|---|---|
x | float | Value in [−1, 1]. |
Returns: float angle in radians.
mathfunctionize.arctangent(1) # ~0.7854... (≈ π/4)
Returns the inverse cotangent of x (x cannot be 0).
| Parameter | Type | Description |
|---|---|---|
x | float | Input value (x ≠ 0). |
Returns: float angle in radians.
mathfunctionize.arccotangent(1) # ~0.7854...
Returns the inverse secant of x (where |x| >= 1).
| Parameter | Type | Description |
|---|---|---|
x | float | Input value (|x| ≥ 1). |
Returns: float angle in radians.
mathfunctionize.arcsecant(2) # ~0.5235...
Returns the inverse cosecant of x (where |x| >= 1).
| Parameter | Type | Description |
|---|---|---|
x | float | Input value (|x| ≥ 1). |
Returns: float angle in radians.
mathfunctionize.arccosecant(2) # ~0.5235...
Converts an angle from degrees to radians, normalizing to the range [0, 2π].
| Parameter | Type | Description |
|---|---|---|
degree | float | Angle in degrees. |
Returns: float angle in radians.
mathfunctionize.degreeToRadian(180) # 3.14159...
mathfunctionize.degreeToRadian(45) # 0.7853...
Converts an angle from radians (in the range [0, 2π]) to degrees.
| Parameter | Type | Description |
|---|---|---|
radian | float | Angle in radians (0 ≤ radian ≤ 2π). |
Returns: float angle in degrees.
Raises: Exception if radian is outside [0, 2π].
mathfunctionize.radianToDegree(mathfunctionize.pi) # 180.0
Statistics
Descriptive statistics on numerical arrays.
Returns the arithmetic mean (average) of a list of numbers.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers. |
Returns: float
mathfunctionize.mean([2, 4, 6, 8]) # 5.0
Returns the median (middle value) of a sorted list of numbers, averaging the two middle values for even-length lists.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers. |
Returns: float | None returns None for empty arrays.
mathfunctionize.median([1, 3, 5, 7]) # 4.0
mathfunctionize.median([1, 2, 3]) # 2
Returns the most frequently occurring value in a list of numbers.
| Parameter | Type | Description |
|---|---|---|
arr | list | List of values. |
Returns: int | float
Raises: Exception for empty arrays.
mathfunctionize.mode([1, 2, 2, 3, 3, 3]) # 3
Returns the population standard deviation of a list of numbers, measuring the spread of data around the mean.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers. |
Returns: float
mathfunctionize.standardDevation([2, 4, 4, 4, 5, 5, 7, 9]) # 2.0
Returns the population variance of a list of numbers, measuring how far each value is from the mean.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers. |
Returns: float
mathfunctionize.variance([2, 4, 4, 4, 5, 5, 7, 9]) # 4.0
Quantitative Analysis
Finding extrema (minima and maxima) in numerical arrays.
Finds all local minima in an array and returns a list containing the count and their positions.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers. |
Returns: [int, list[int]] a list containing [count, [indices]].
mathfunctionize.localMinimum([5, 2, 8, 1, 9]) # [2, [1, 3]]
Finds all local maxima in an array and returns a list containing the count and their positions.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | List of numbers. |
Returns: [int, list[int]] a list containing [count, [indices]].
mathfunctionize.localMaximum([1, 5, 2, 8, 3]) # [2, [1, 3]]
Finds the smallest value in an array and returns a list containing the value and all positions where it occurs.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | Non-empty list of numbers. |
Returns: [number, list[int]] [min_value, [indices]].
Raises: Exception for empty arrays.
mathfunctionize.globalMinimum([5, 2, 8, 2, 9]) # [2, [1, 3]]
Finds the largest value in an array and returns a list containing the value and all positions where it occurs.
| Parameter | Type | Description |
|---|---|---|
arr | list[int | float] | Non-empty list of numbers. |
Returns: [number, list[int]] [max_value, [indices]].
Raises: Exception for empty arrays.
mathfunctionize.globalMaximum([5, 9, 8, 9, 1]) # [9, [1, 3]]
Linear Algebra
Matrix operations. Matrices are represented as lists of lists (rows).
Adds two matrices of the same dimensions element-wise and returns the resulting matrix.
| Parameter | Type | Description |
|---|---|---|
arr1 | list[list] | First matrix. |
arr2 | list[list] | Second matrix (same dimensions as arr1). |
Returns: list[list]
Raises: Exception if dimensions don't match.
A = [[1, 2], [3, 4]]
B = [[5, 6], [7, 8]]
mathfunctionize.additionMatrix(A, B) # [[6, 8], [10, 12]]
Subtracts two matrices of the same dimensions element-wise and returns the resulting matrix.
| Parameter | Type | Description |
|---|---|---|
arr1 | list[list] | First matrix. |
arr2 | list[list] | Second matrix. |
Returns: list[list]
Raises: Exception if dimensions don't match.
A = [[5, 6], [7, 8]]
B = [[1, 2], [3, 4]]
mathfunctionize.subtractionMatrix(A, B) # [[4, 4], [4, 4]]
Performs matrix multiplication on two matrices where the number of columns in arr1 equals the number of rows in arr2.
| Parameter | Type | Description |
|---|---|---|
arr1 | list[list] | First matrix (m × n). |
arr2 | list[list] | Second matrix (n × p). |
Returns: list[list] resulting m × p matrix.
Raises: Exception if dimensions are incompatible.
A = [[1, 2], [3, 4]]
B = [[5, 6], [7, 8]]
mathfunctionize.multiplicationMatrix(A, B) # [[19, 22], [43, 50]]
Computes the determinant of a square matrix using cofactor expansion.
| Parameter | Type | Description |
|---|---|---|
arr | list[list] | Square matrix. |
Returns: int | float
Raises: Exception if the matrix is empty or not square.
mathfunctionize.determinant([[1, 2], [3, 4]]) # -2
mathfunctionize.determinant([[6, 1, 1], [4, -2, 5], [2, 8, 7]]) # -306
Returns the transpose of a matrix, swapping rows and columns.
| Parameter | Type | Description |
|---|---|---|
arr | list[list] | Input matrix. |
Returns: list[list]
Raises: Exception if the matrix is empty.
mathfunctionize.transpose([[1, 2, 3], [4, 5, 6]])
# [[1, 4], [2, 5], [3, 6]]
Naive Set Theory
Set operations using lists as set representations.
Removes all duplicate elements from a list and returns a new list containing only unique values in their original order.
| Parameter | Type | Description |
|---|---|---|
arr | list | Input list. |
Returns: list
mathfunctionize.set([1, 2, 2, 3, 3, 3]) # [1, 2, 3]Returns the union of two sets, containing all unique elements that are in either set1 or set2.
| Parameter | Type | Description |
|---|---|---|
set1 | list | First set. |
set2 | list | Second set. |
Returns: list
mathfunctionize.union([1, 2], [2, 3]) # [1, 2, 3]Returns the intersection of two sets, containing only the elements present in both set1 and set2.
| Parameter | Type | Description |
|---|---|---|
set1 | list | First set. |
set2 | list | Second set. |
Returns: list
mathfunctionize.intersection([1, 2, 3], [2, 3, 4]) # [2, 3]Returns the difference of two sets, containing elements that are in set1 but not in set2.
| Parameter | Type | Description |
|---|---|---|
set1 | list | First set. |
set2 | list | Second set. |
Returns: list
mathfunctionize.difference([1, 2, 3], [2, 3, 4]) # [1]Returns the symmetric difference of two sets, containing elements that are in either set but not in both.
| Parameter | Type | Description |
|---|---|---|
set1 | list | First set. |
set2 | list | Second set. |
Returns: list
mathfunctionize.symmetricDifference([1, 2, 3], [2, 3, 4]) # [1, 4]Returns the power set of a given set, which is the list of all possible subsets including the empty set.
| Parameter | Type | Description |
|---|---|---|
set | list | Input set. |
Returns: list[list]
mathfunctionize.powerSet([1, 2]) # [[], [1], [2], [1, 2]]Determines whether a given set is an open set within a specified topology by checking if every element of the set belongs to the topology.
| Parameter | Type | Description |
|---|---|---|
set | list | The set to check. |
topology | list | The topology (collection of open sets). |
Returns: bool
mathfunctionize.isOpenSet([1, 2], [1, 2, 3]) # TrueReturns the Cartesian product of two sets, producing a list of all ordered pairs [a, b] where a is from set1 and b is from set2.
| Parameter | Type | Description |
|---|---|---|
set1 | list | First set. |
set2 | list | Second set. |
Returns: list[list]
mathfunctionize.cartesianProduct([1, 2], [3, 4])
# [[1, 3], [1, 4], [2, 3], [2, 4]]Returns True if element x is a member of the given set, False otherwise.
| Parameter | Type | Description |
|---|---|---|
x | any | Element to check. |
set | list | The set. |
Returns: bool
mathfunctionize.isMemberOfSet(2, [1, 2, 3]) # TrueReturns True if every element of set1 is also in set2, False otherwise.
| Parameter | Type | Description |
|---|---|---|
set1 | list | Candidate subset. |
set2 | list | Superset to check against. |
Returns: bool
mathfunctionize.isSubset([1, 2], [1, 2, 3]) # TrueReturns True if both sets contain exactly the same elements, regardless of order.
| Parameter | Type | Description |
|---|---|---|
set1 | list | First set. |
set2 | list | Second set. |
Returns: bool
mathfunctionize.setEquality([3, 1, 2], [1, 2, 3]) # TrueReturns the complement of a set with respect to a universal set, containing all elements in the universal set that are not in the given set.
| Parameter | Type | Description |
|---|---|---|
set | list | The set. |
universal | list | The universal set. |
Returns: list
mathfunctionize.complement([1, 2], [1, 2, 3, 4]) # [3, 4]Returns the number of elements in a set.
| Parameter | Type | Description |
|---|---|---|
set | list | The set. |
Returns: int
mathfunctionize.cardinality([1, 2, 3]) # 3Returns True if set1 is a subset of set2 but the two sets are not equal.
| Parameter | Type | Description |
|---|---|---|
set1 | list | Candidate subset. |
set2 | list | Superset. |
Returns: bool
mathfunctionize.isProperSubset([1, 2], [1, 2, 3]) # TrueReturns True if every element of set2 is also in set1.
| Parameter | Type | Description |
|---|---|---|
set1 | list | Candidate superset. |
set2 | list | Subset to check. |
Returns: bool
mathfunctionize.isSuperset([1, 2, 3], [1, 2]) # TrueReturns True if set1 is a superset of set2 but the two sets are not equal.
| Parameter | Type | Description |
|---|---|---|
set1 | list | Candidate superset. |
set2 | list | Subset. |
Returns: bool
mathfunctionize.isProperSuperset([1, 2, 3], [1, 2]) # TrueReturns True if the two sets share no elements in common.
| Parameter | Type | Description |
|---|---|---|
set1 | list | First set. |
set2 | list | Second set. |
Returns: bool
mathfunctionize.isDisjoint([1, 2], [3, 4]) # TrueReturns True if the set contains no elements.
| Parameter | Type | Description |
|---|---|---|
set | list | The set. |
Returns: bool
mathfunctionize.isEmpty([]) # TrueZFC Axiomatic Set Theory
Functions corresponding to the axioms of Zermelo–Fraenkel set theory with the Axiom of Choice.
Verifies the Axiom of Extensionality by checking whether two sets are equal iff they contain exactly the same elements.
| Parameter | Type | Description |
|---|---|---|
set1 | list | First set. |
set2 | list | Second set. |
Returns: bool
mathfunctionize.extensionality([1, 2], [2, 1]) # TrueReturns the empty set, affirming the Axiom of Empty Set.
Returns: list
mathfunctionize.emptySet() # []Returns a set containing exactly two elements a and b, applying the Axiom of Pairing.
| Parameter | Type | Description |
|---|---|---|
a | any | First element. |
b | any | Second element. |
Returns: list
mathfunctionize.pairing(1, 2) # [1, 2]Takes a list of sets and returns the union of all their elements, applying the Axiom of Union.
| Parameter | Type | Description |
|---|---|---|
collection | list[list] | A collection of sets. |
Returns: list
mathfunctionize.axiomOfUnion([[1, 2], [2, 3], [4]]) # [1, 2, 3, 4]Returns the subset of elements from a set that satisfy a given predicate function, applying the Axiom of Separation.
| Parameter | Type | Description |
|---|---|---|
set | list | The set to filter. |
predicate | Callable | A function returning True/False for each element. |
Returns: list
mathfunctionize.separation([1, 2, 3, 4, 5], lambda x: x > 3) # [4, 5]Maps a function over a set and returns the set of all outputs with duplicates removed, applying the Axiom of Replacement.
| Parameter | Type | Description |
|---|---|---|
set | list | The input set. |
func | Callable | Function to apply to each element. |
Returns: list
mathfunctionize.replacement([1, 2, 3], lambda x: x * 2) # [2, 4, 6]Returns the first n elements of the von Neumann ordinal construction of the natural numbers, demonstrating the Axiom of Infinity.
| Parameter | Type | Description |
|---|---|---|
n | int | Number of ordinals to generate. |
Returns: list
mathfunctionize.infinitySet(3) # [[], [[]], [[], [[]]]]Verifies the Axiom of Regularity (Foundation) by checking that no element of the set is equal to the set itself. Returns True if the axiom holds.
| Parameter | Type | Description |
|---|---|---|
set | list | The set to check. |
Returns: bool
mathfunctionize.regularity([1, 2, 3]) # TrueGiven a collection of non-empty sets, selects one element from each set and returns them as a list, applying the Axiom of Choice.
| Parameter | Type | Description |
|---|---|---|
collection | list[list] | A list of non-empty sets. |
Returns: list
mathfunctionize.axiomOfChoice([[1, 2], [3, 4], [5]]) # [1, 3, 5]Metric Spaces
Distance functions and metric space verification.
Computes the distance between two points x and y in n-dimensional space under a specified metric. Supports "euclidean" (default), "manhattan", and "chebyshev".
| Parameter | Type | Description |
|---|---|---|
x | list[float] | First point. |
y | list[float] | Second point. |
metric | str | "euclidean", "manhattan", or "chebyshev". |
Returns: float
mathfunctionize.dist([0, 0], [3, 4]) # 5.0
mathfunctionize.dist([0, 0], [3, 4], "manhattan") # 7
mathfunctionize.dist([0, 0], [3, 4], "chebyshev") # 4Determines whether a distance function d satisfies the three metric space axioms (non-negativity with identity of indiscernibles, symmetry, and the triangle inequality) over a set S.
| Parameter | Type | Description |
|---|---|---|
d | Callable | Distance function taking two elements. |
S | list | Set of points to verify over. |
Returns: bool
d = lambda a, b: mathfunctionize.dist(a, b)
S = [[0, 0], [1, 0], [0, 1]]
mathfunctionize.isMetricSpace(d, S) # TrueCalculus
Numerical calculus: limits, derivatives, integrals, concavity, and continuity.
Evaluates the limit of a function f as x approaches a value a using numerical approximation from both sides. Returns None if the two-sided limit does not exist.
| Parameter | Type | Description |
|---|---|---|
f | Callable | The function. |
x | str | Variable name (unused, for signature clarity). |
a | float | The value to approach. |
Returns: float | None
f = lambda x: (x**2 - 1) / (x - 1)
mathfunctionize.limit(f, "x", 1) # 2.0Computes the numerical derivative of a function f at a point x using the central difference method.
| Parameter | Type | Description |
|---|---|---|
f | Callable | The function. |
x | float | Point to evaluate. |
Returns: float
mathfunctionize.derivative(lambda x: x**2, 3) # ~6.0Determines the concavity of a function f at a point x by computing the second derivative. Returns "concave up", "concave down", or "inflection point".
| Parameter | Type | Description |
|---|---|---|
f | Callable | The function. |
x | float | Point to evaluate. |
Returns: str
mathfunctionize.concavity(lambda x: x**2, 0) # "concave up"
mathfunctionize.concavity(lambda x: -x**2, 0) # "concave down"Computes the definite integral of a function f over the interval [a, b] using Simpson's rule.
| Parameter | Type | Description |
|---|---|---|
f | Callable | The function to integrate. |
a | float | Lower bound. |
b | float | Upper bound. |
Returns: float
mathfunctionize.integral(lambda x: x**2, 0, 1) # ~0.3333...Tests whether a function f is continuous at a point x by checking that the left-hand limit, right-hand limit, and function value are all equal. Returns a boolean.
| Parameter | Type | Description |
|---|---|---|
f | Callable | The function. |
x | float | Point to check. |
Returns: bool
mathfunctionize.continuity(lambda x: x**2, 1) # TrueComplex Analysis
Operations on complex numbers as strings.
Returns the complex conjugate of a complex number z represented as a string. For z = "a+bi", returns "a-bi".
| Parameter | Type | Description |
|---|---|---|
z | str | Complex number string. |
Returns: str
mathfunctionize.conjugate("3+4i") # "3-4i"
mathfunctionize.conjugate("5-2i") # "5+2i"Computes all n-th roots of unity, returning them as a list of complex number strings evenly spaced on the unit circle.
| Parameter | Type | Description |
|---|---|---|
n | int | The degree (number of roots). |
Returns: list[str]
mathfunctionize.rootsOfUnity(4)
# ["1.0+0.0i", "0.0+1.0i", "-1.0+0.0i", "0.0-1.0i"]Number Theory
Determines whether a positive integer x is a prime number. Returns a boolean.
| Parameter | Type | Description |
|---|---|---|
x | int | Positive integer. |
Returns: bool
mathfunctionize.isPrime(17) # True
mathfunctionize.isPrime(4) # FalseTopology
Tests whether a function f appears to be infinitely differentiable (smooth) at a point x by computing successive numerical derivatives and checking for convergence. Returns a boolean.
| Parameter | Type | Description |
|---|---|---|
f | Callable | The function. |
x | float | Point to check. |
Returns: bool
mathfunctionize.smooth(lambda x: x**3, 0) # TruePolynomials
Polynomial evaluation, division, root finding, and factoring. Coefficients are ordered from highest degree to lowest.
Evaluates a polynomial at a given value x, where coefficients are ordered from highest degree to lowest.
| Parameter | Type | Description |
|---|---|---|
coefficients | list[float] | Coefficients, highest degree first. |
x | float | Value to evaluate at. |
Returns: float
# 2x^2 + 3x + 1 at x = 2
mathfunctionize.polyEval([2, 3, 1], 2) # 15Performs polynomial long division on two polynomials represented by their coefficient lists. Returns [quotient, remainder].
| Parameter | Type | Description |
|---|---|---|
dividend | list[float] | Dividend polynomial coefficients. |
divisor | list[float] | Divisor polynomial coefficients. |
Returns: [list, list] [quotient, remainder]
# (x^2 + 3x + 2) / (x + 1)
mathfunctionize.divide([1, 3, 2], [1, 1]) # [[1.0, 2.0], []]Finds the real roots of a polynomial given its coefficients. Supports linear, quadratic, and higher-degree polynomials via rational root search.
| Parameter | Type | Description |
|---|---|---|
coefficients | list[float] | Polynomial coefficients, highest degree first. |
Returns: list[float]
# x^2 - 5x + 6 = (x-2)(x-3)
mathfunctionize.zeros([1, -5, 6]) # [3.0, 2.0]Factors a polynomial given its coefficients into irreducible factors. Returns a list of [factor, multiplicity] pairs.
| Parameter | Type | Description |
|---|---|---|
coefficients | list[float] | Polynomial coefficients, highest degree first. |
Returns: list of [[coefficients], multiplicity] pairs
# x^2 - 5x + 6 = (x-2)(x-3)
mathfunctionize.factor([1, -5, 6])
# [[[1, -3], 1], [[1, -2], 1]]