You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -7,54 +7,136 @@ Run ```pip install mathfunctionize``` to get started
7
7
8
8
Import the library into python file: ```from mathfunctionize import mathfunctionize```
9
9
10
-
Functions are able to be used by stating ```mathfunctionize.intendedFunction()``` and replacing ```intendedFunction()``` with the one of the avalible functions listed below.
10
+
Functions are able to be used by stating ```mathfunctionize.intendedFunction()``` and replacing ```intendedFunction()``` with one of the available functions listed below.
11
11
12
-
## Operations:
12
+
## Constants
13
13
---
14
-
```addition(a, b)``` - takes two numerical inputs and returns the sum of the two numbers
14
+
```pi``` - the ratio of a circle's circumference to its diameter, approximately 3.14159
15
15
16
-
```subtraction(a, b)``` - takes two numerical inputs and returns the number minus the second number
16
+
```e``` - Euler's number, the base of the natural logarithm, approximately 2.71828
17
17
18
-
```multiplication(a, b)``` - takes two numerical inputs and returns the product of the two numbers
18
+
## Arithmetic
19
+
---
20
+
```addition(arr)``` - takes a list of numbers and returns the sum of all elements, e.g. ```addition([1, 2, 3])``` returns ```6```
21
+
22
+
```subtraction(arr)``` - takes a list of numbers and subtracts each subsequent element from the first, e.g. ```subtraction([10, 3, 2])``` returns ```5```
23
+
24
+
```multiplication(arr)``` - takes a list of numbers and returns the product of all elements, e.g. ```multiplication([2, 3, 4])``` returns ```24```
25
+
26
+
```division(arr)``` - takes a list of numbers and divides the first element by each subsequent element, e.g. ```division([100, 5, 2])``` returns ```10```
27
+
28
+
```power(arr)``` - takes a list of numbers and exponentiates left-to-right, e.g. ```power([2, 3])``` returns ```8```
29
+
30
+
```modulo(arr)``` - takes a list of numbers and applies the modulo operator left-to-right, e.g. ```modulo([10, 3])``` returns ```1```
31
+
32
+
```flatDivision(arr)``` - takes a list of numbers and performs floor division left-to-right, e.g. ```flatDivision([10, 3])``` returns ```3```
33
+
34
+
## Algebra
35
+
---
36
+
```gamma(x)``` - computes the gamma function of x, a generalization of the factorial to real and complex numbers where gamma(n) = (n-1)! for positive integers
37
+
38
+
```factorial(x)``` - returns the factorial of a non-negative integer x, i.e. x! = x * (x-1) * ... * 1
39
+
40
+
```absolute(x)``` - returns the absolute value of x
41
+
42
+
```squareRoot(x)``` - returns the square root of x
43
+
44
+
```cubeRoot(x)``` - returns the cube root of x
45
+
46
+
```nthRoot(x, n)``` - returns the nth root of x
47
+
48
+
```round(x, place)``` - rounds x to the nearest specified place value (e.g. 1, 10, 100)
49
+
50
+
## Counting
51
+
---
52
+
```combinations(n, r)``` - returns the number of ways to choose r items from n items without regard to order, i.e. n! / (r! * (n-r)!)
53
+
54
+
```permutations(n, r)``` - returns the number of ways to arrange r items from n items where order matters, i.e. n! / (n-r)!
55
+
56
+
```circularPermutations(n)``` - returns the number of ways to arrange n items in a circle, i.e. (n-1)!
57
+
58
+
```derangements(n)``` - returns the number of permutations of n elements where no element appears in its original position
59
+
60
+
## Probability
61
+
---
62
+
```bayes_theorem(priorA, priorB, likelihoodA, likelihoodB)``` - computes the posterior probability using Bayes' theorem given prior probabilities and likelihoods for two hypotheses
19
63
20
-
```division(a, b)``` - takes two numerical inputs and returns the first number divided by the second number
64
+
```uniformPDF(a, b)``` - returns the probability density for a continuous uniform distribution over the interval [a, b]
21
65
22
-
```power(a, b)```
66
+
```uniformCDF(X, a, b)``` - returns the cumulative distribution function value for a uniform distribution, giving the probability that a random variable is less than or equal to X
23
67
24
-
```modulo(a, b)```
68
+
```normalPDF(X, mean, stdDev)``` - returns the probability density of the normal (Gaussian) distribution at point X given a mean and standard deviation
25
69
26
-
```flatDivision(a, b)```
70
+
```normalCDF(x, mean, stdDev)``` - returns the cumulative distribution function value for the normal distribution, approximating the probability that a random variable is less than or equal to x
27
71
28
-
```factorial(x)```
72
+
```gammaPDF(x, a, b)``` - returns the probability density of the gamma distribution at point x with shape parameter a and rate parameter b
29
73
30
-
## Mathematics
74
+
## Complex Numbers
31
75
---
32
-
```absolute(x)```
76
+
```complex_addition(a, b)``` - adds two complex numbers represented as strings (e.g. ```"3+4i"```, ```"2-1i"```) and returns the result as a string
33
77
34
-
```round(x, place)```
78
+
```complex_subtraction(a, b)``` - subtracts two complex numbers represented as strings and returns the result as a string
35
79
36
-
## Quantative Analysis
80
+
## Trigonometry
37
81
---
38
-
```localMinimum(arr)```
82
+
```sin(x)``` / ```sine(x)``` - returns the sine of x (in radians) using a Taylor series approximation
39
83
40
-
```localMaximum(arr)```
84
+
```cos(x)``` / ```cosine(x)``` - returns the cosine of x (in radians) using a Taylor series approximation
41
85
42
-
```globalMinimum(arr)```
86
+
```tan(x)``` / ```tangent(x)``` - returns the tangent of x (in radians), computed as sine(x) / cosine(x)
43
87
44
-
```globalMaximum(arr)```
88
+
```csc(x)``` / ```cosecant(x)``` - returns the cosecant of x (in radians), computed as 1 / sine(x)
89
+
90
+
```sec(x)``` / ```secant(x)``` - returns the secant of x (in radians), computed as 1 / cosine(x)
91
+
92
+
```cot(x)``` / ```cotangent(x)``` - returns the cotangent of x (in radians), computed as cosine(x) / sine(x)
93
+
94
+
```arcsine(x)``` - returns the inverse sine of x (where -1 <= x <= 1) using a Taylor series approximation
95
+
96
+
```arccosine(x)``` - returns the inverse cosine of x (where -1 <= x <= 1) using a Taylor series approximation
97
+
98
+
```arctangent(x)``` - returns the inverse tangent of x (where -1 <= x <= 1) using a Taylor series approximation
99
+
100
+
```arccotangent(x)``` - returns the inverse cotangent of x (x cannot be 0)
101
+
102
+
```arcsecant(x)``` - returns the inverse secant of x (where |x| >= 1)
103
+
104
+
```arccosecant(x)``` - returns the inverse cosecant of x (where |x| >= 1)
105
+
106
+
```degreeToRadian(degree)``` - converts an angle from degrees to radians, normalizing to the range [0, 2*pi]
107
+
108
+
```radianToDegree(radian)``` - converts an angle from radians (in the range [0, 2*pi]) to degrees
109
+
110
+
## Quantitative Analysis
111
+
---
112
+
```localMinimum(arr)``` - finds all local minima in an array and returns a list containing the count and their positions
113
+
114
+
```localMaximum(arr)``` - finds all local maxima in an array and returns a list containing the count and their positions
115
+
116
+
```globalMinimum(arr)``` - finds the smallest value in an array and returns a list containing the value and all positions where it occurs
117
+
118
+
```globalMaximum(arr)``` - finds the largest value in an array and returns a list containing the value and all positions where it occurs
45
119
46
120
## Statistics
47
121
---
48
-
```mean(arr)```
49
-
```median(arr)```
50
-
```standardDevation(arr)```
51
-
```mode(arr)```
122
+
```mean(arr)``` - returns the arithmetic mean (average) of a list of numbers
123
+
124
+
```median(arr)``` - returns the median (middle value) of a sorted list of numbers, averaging the two middle values for even-length lists
125
+
126
+
```standardDevation(arr)``` - returns the population standard deviation of a list of numbers, measuring the spread of data around the mean
127
+
128
+
```mode(arr)``` - returns the most frequently occurring value in a list of numbers
129
+
130
+
```variance(arr)``` - returns the population variance of a list of numbers, measuring how far each value is from the mean
52
131
53
132
## Linear Algebra
54
-
```additionMatrix(arr)```
55
-
```subtractionMatrix(arr)```
56
-
```multiplicationMatrix(arr)```
57
-
```determinant(arr)```
58
-
```transpose(arr)```
133
+
---
134
+
```additionMatrix(arr1, arr2)``` - adds two matrices of the same dimensions element-wise and returns the resulting matrix
135
+
136
+
```subtractionMatrix(arr1, arr2)``` - subtracts two matrices of the same dimensions element-wise and returns the resulting matrix
137
+
138
+
```multiplicationMatrix(arr1, arr2)``` - performs matrix multiplication on two matrices where the number of columns in arr1 equals the number of rows in arr2
59
139
140
+
```determinant(arr)``` - computes the determinant of a square matrix using cofactor expansion
60
141
142
+
```transpose(arr)``` - returns the transpose of a matrix, swapping rows and columns
`isMetricSpace(d, S)` - Determines whether a given distance function d satisfies the three metric space axioms (non-negativity with identity of indiscernibles, symmetry, and the triangle inequality) over a set S. Returns a boolean indicating whether (S, d) forms a valid metric space.
27
7
28
-
dist()
8
+
`dist(x, y, metric)` - Computes the distance between two points x and y under a specified metric. Supports common metrics such as Euclidean, Manhattan, and Chebyshev distance in n-dimensional space.
29
9
30
10
## Calculus
31
-
limit()
32
11
33
-
derivitive()
12
+
`limit(f, x, a)` - Evaluates the limit of a function f(x) as x approaches a value a, using numerical approximation from both the left and right sides. Detects one-sided limits and indicates when a two-sided limit does not exist.
13
+
14
+
`derivative(f, x)` - Computes the numerical derivative of a function f at a given point x using finite difference approximation. Returns the instantaneous rate of change of f at x.
34
15
35
-
concavity()
16
+
`concavity(f, x)` - Determines the concavity of a function f at a point x by computing the second derivative. Returns whether the function is concave up (positive second derivative), concave down (negative second derivative), or at an inflection point.
36
17
37
-
integral()
18
+
`integral(f, a, b)` - Computes the definite integral of a function f over the interval [a, b] using numerical integration (e.g. Simpson's rule or the trapezoidal rule). Returns the signed area under the curve.
38
19
39
-
continuity()
20
+
`continuity(f, x)` - Tests whether a function f is continuous at a point x by checking that the left-hand limit, right-hand limit, and function value at x all exist and are equal. Returns a boolean.
40
21
41
22
## Complex Analysis
42
23
43
-
conjugate()
24
+
`conjugate(z)` - Returns the complex conjugate of a complex number z. For z = a + bi, the conjugate is a - bi. Takes a string representation and returns a string.
44
25
45
-
rootsOfUnity()
26
+
`rootsOfUnity(n)` - Computes all n-th roots of unity, i.e. the n complex numbers z such that z^n = 1. Returns them as a list of complex number strings evenly spaced on the unit circle.
46
27
47
28
## Set Theory
48
29
49
-
powerSet()
30
+
`powerSet(S)` - Returns the power set of a given set S, which is the set of all possible subsets of S including the empty set and S itself. For a set of size n, the power set contains 2^n elements.
50
31
51
-
union()
32
+
`union(A, B)` - Returns the union of two sets A and B, containing all elements that are in A, in B, or in both.
52
33
53
-
intersection()
34
+
`intersection(A, B)` - Returns the intersection of two sets A and B, containing only the elements that are present in both A and B.
54
35
55
-
isOpenSet()
36
+
`isOpenSet(S, topology)` - Determines whether a given subset S is an open set within a specified topology. Returns a boolean based on whether S belongs to the collection of open sets defined by the topology.
56
37
57
38
## Real Analysis
58
39
59
-
## Statistics
60
-
61
-
nPr()
62
-
63
-
nCr()
64
-
65
40
## Number Theory
66
41
67
-
isPrime(x)
42
+
`isPrime(x)` - Determines whether a positive integer x is a prime number, i.e. a number greater than 1 whose only divisors are 1 and itself. Returns a boolean.
68
43
69
44
## Topology
70
45
71
-
smooth()
46
+
`smooth(f, x)` - Tests whether a function f is infinitely differentiable (smooth) at a point x by computing successive numerical derivatives and checking for convergence. Returns a boolean or a smoothness classification.
72
47
73
48
## Polynomials
74
-
factor()
75
49
76
-
divide()
50
+
`factor(coefficients)` - Factors a polynomial given its coefficients into irreducible polynomial factors. Returns the factored form as a list of factor-multiplicity pairs.
77
51
78
-
zeros()
79
-
## Linear Algebra
52
+
`divide(dividend, divisor)` - Performs polynomial long division on two polynomials represented by their coefficient lists. Returns the quotient and remainder as separate coefficient lists.
80
53
81
-
powerSet()
82
-
83
-
union()
84
-
85
-
intersection()
86
-
87
-
isOpenSet()
54
+
`zeros(coefficients)` - Finds all real and complex roots (zeros) of a polynomial given its coefficients. Returns a list of values where the polynomial evaluates to zero.
0 commit comments