sparsh-math-tools 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Math_Tools/__init__.py ADDED
@@ -0,0 +1,15 @@
1
+ from .arithmetic import *
2
+ from .fractions import *
3
+ from .number_theory import *
4
+ from .set_theory import *
5
+ from .geometry import *
6
+ from .statistics import *
7
+ from .logic import *
8
+
9
+ class _Credits:
10
+ def __repr__(self):
11
+ return "Math Tools Package v1.0"
12
+ def __call__(self):
13
+ print(self.__repr__())
14
+
15
+ credits = _Credits()
@@ -0,0 +1,97 @@
1
+ #arithmetic.py
2
+ def add(x):
3
+ i = 0
4
+ for j in x:
5
+ i += j
6
+ return i
7
+
8
+ def sub(x):
9
+ i = x[0]
10
+ for j in x[1:]:
11
+ i -= j
12
+ return i
13
+
14
+ def mul(x):
15
+ i = 1
16
+ for j in x:
17
+ i *= j
18
+ return i
19
+
20
+ def div(x):
21
+ i = x[0]
22
+ for j in x[1:]:
23
+ if j == 0:
24
+ return "DivisonByZeroError"
25
+ i /= j
26
+ return i
27
+
28
+ def mod(x):
29
+ i = x[0]
30
+ for j in x[1:]:
31
+ if j == 0:
32
+ return "ModuloByZeroError"
33
+ i %= j
34
+ return i
35
+
36
+ def pow(x):
37
+ i = x[0]
38
+ for j in x[1:]:
39
+ i **= j
40
+ return i
41
+
42
+ def ceil(x):
43
+ if x > int(x):
44
+ return int(x) + 1
45
+ return int(x)
46
+
47
+ def floor(x):
48
+ return x // 1
49
+
50
+ def floor_div(x):
51
+ i = x[0]
52
+ for j in x[1:]:
53
+ if j == 0:
54
+ return "DivisonByZeroError"
55
+ i //= j
56
+ return i
57
+
58
+ def ceil_div(x):
59
+ i = x[0]
60
+ for j in x[1:]:
61
+ if j == 0:
62
+ return "DivisonByZeroError"
63
+ i = ceil(i / j)
64
+ return i
65
+
66
+ def abs(x):
67
+ if x < 0:
68
+ return x - x*2
69
+ return x
70
+
71
+ def root(x,y):
72
+ if y == 0:
73
+ return 1
74
+ return x**(1/y)
75
+
76
+ def percent_of(x,y):
77
+ return (x/y)*100
78
+
79
+ def percentage(x,y):
80
+ return (x/100)*y
81
+
82
+ def percent_change(x,y):
83
+ return ((x-y)/x)*100
84
+
85
+ def calc_speed(x,y):
86
+ if y == 0:
87
+ return "DivisionByZeroError"
88
+ return x/y
89
+
90
+ def calc_distance(x,y):
91
+ return x*y
92
+
93
+ def calc_time(x,y):
94
+ if y == 0:
95
+ return "DivisionByZeroError"
96
+ return x/y
97
+
@@ -0,0 +1,74 @@
1
+ #fractions.py
2
+ from .arithmetic import floor
3
+ from .number_theory import gcd, lcm
4
+
5
+ def simplest_form(x,y):
6
+ return (x/gcd(x,y),y/gcd(x,y))
7
+
8
+ def add_frac(x1,y1,x2,y2):
9
+ if y1 == y2:
10
+ if x1+x2 > y1:
11
+ return ((x1+x2)%y1,floor((x1+x2)/y1),y1)
12
+ return (x1+x2,y1)
13
+ LCM = lcm(y1,y2)
14
+ x3 = 1
15
+ x4 = 1
16
+ x3 *= LCM/y1
17
+ x4 *= LCM/y2
18
+ if x3+x4 > LCM:
19
+ return ((x3+x4)%y1,floor((x3+x4)/y1),LCM)
20
+ return (x3+x4,LCM)
21
+
22
+ def sub_frac(x1,y1,x2,y2):
23
+ if y1 == y2:
24
+ if x1-x2 > y1:
25
+ return ((x1-x2)%y1,floor((x1-x2)/y1),y1)
26
+ return (x1-x2,y1)
27
+ LCM = lcm(y1,y2)
28
+ x3 = 1
29
+ x4 = 1
30
+ x3 *= LCM/y1
31
+ x4 *= LCM/y2
32
+ if x3-x4 > LCM:
33
+ return ((x3-x4)%y1,floor((x3-x4)/y1),LCM)
34
+ return (x3-x4,LCM)
35
+
36
+ def mul_frac(x1,y1,x2,y2):
37
+ return(x1*x2,y1*y2)
38
+
39
+ def div_frac(x1,y1,x2,y2):
40
+ return (x1*y2,x2*y1)
41
+
42
+ def compare(x1,y1,x2,y2):
43
+ sig = 0
44
+ if y1 < 0 or y2 < 0:
45
+ sig = 1
46
+ if x1*y2 > x2*y1:
47
+ if sig == 0:
48
+ return -1
49
+ return 1
50
+ elif x1*y2 == x2*y1:
51
+ return 0
52
+ elif x1*y2 < x2*y1:
53
+ if sig == 0:
54
+ return 1
55
+ return -1
56
+
57
+ def equivalent_fractions(x,y,z):
58
+ vals = []
59
+ for i in range(1,z+1):
60
+ vals.append((x*i,y*i))
61
+ return vals
62
+
63
+ def check_equivalent(x1,y1,x2,y2):
64
+ return x1*y2 == y1*x2
65
+
66
+ def conv_mixed_frac(x,y,z):
67
+ return (y*z+x,y)
68
+
69
+ def conv_improper_frac(x,y):
70
+ if x < y:
71
+ return "NotImproperError"
72
+ if y == 0:
73
+ return "DivisionByZeroError"
74
+ return (x%y,floor(x/y),y)
Math_Tools/geometry.py ADDED
@@ -0,0 +1,72 @@
1
+ #geometry.py
2
+ from .arithmetic import root
3
+
4
+ def square_area(x):
5
+ return x**2
6
+
7
+ def area_rectangle(x,y):
8
+ return x*y
9
+
10
+ def area_paralellogram(x,y):
11
+ return x*y
12
+
13
+ def area_rhombus(x,y):
14
+ return (x*y)/2
15
+
16
+ def area_kite(x,y):
17
+ return (x*y)/2
18
+
19
+ def area_trapezium(x,y,z):
20
+ return ((x+y)/2)*z
21
+
22
+ def area_regular_triangle(x,y):
23
+ return 0.5 * x * y
24
+
25
+ def area_right_triangle(x,y):
26
+ return 0.5 * x * y
27
+
28
+ def area_ngon(x,y,z):
29
+ return (x*y*z)/2
30
+
31
+ def distance(x1, y1, x2, y2):
32
+ return root((x1 - x2)**2 + (y1 - y2)**2, 2)
33
+
34
+ def distance_3D(x1, y1, z1, x2, y2, z2):
35
+ return root((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2, 2)
36
+
37
+ def midpoint(x1,y1,x2,y2):
38
+ return ((x1+x2)/2,(y1+y2)/2)
39
+
40
+ def midpoint_3D(x1,y1,z1,x2,y2,z2):
41
+ return ((x1+x2)/2,(y1+y2)/2,(z1+z2)/2)
42
+
43
+ def slope_formula(x1,y1,x2,y2):
44
+ if x2 - x1 == 0:
45
+ return "SlopeFormulaError"
46
+ return (y2-y1)/(x2-x1)
47
+
48
+ def slope_formula_3D(x1,y1,z1,x2,y2,z2):
49
+ return (x2-x1,y2-y1,z2-z1)
50
+
51
+ def line_relationship(x1,y1,x2,y2,x3,y3,x4,y4):
52
+ a1 = y1-y2
53
+ a2 = y3-y4
54
+ b1 = x2-x1
55
+ b2 = x4-x3
56
+ if (a1 == 0 and b1 == 0) or (a2 == 0 and b2 == 0):
57
+ return "DistinctPointsError"
58
+ c1 = x1*y2-x2*y1
59
+ c2 = x3*y4-x4*y3
60
+ if a1*b2 == a2*b1 and b1*c2 == b2*c1 and a1*c2 == a2*c1:
61
+ return "Coincident"
62
+ elif a1*b2 - a2*b1 == 0:
63
+ return "Parallel"
64
+ elif a1*a2 + b1*b2 == 0:
65
+ return ("Perpendicular", (b1*c2-b2*c1)/(a1*b2-a2*b1),(c1*a2-c2*a1)/(a1*b2-a2*b1))
66
+ elif a1*b2-a2*b1 != 0:
67
+ return ("Intersecting", (b1*c2-b2*c1)/(a1*b2-a2*b1),(c1*a2-c2*a1)/(a1*b2-a2*b1))
68
+ else:
69
+ return 0
70
+
71
+ def section_formula(x1,y1,x2,y2,m,n):
72
+ return ((m*x2+n*x1)/m+n,(m*y2+n*y1)/m+n)
Math_Tools/logic.py ADDED
@@ -0,0 +1,27 @@
1
+ #logic.py
2
+ def andGate(x,y):
3
+ return x and y
4
+
5
+ def orGate(x,y):
6
+ return x or y
7
+
8
+ def notGate(x):
9
+ return not x
10
+
11
+ def nor(x,y):
12
+ return not(x or y)
13
+
14
+ def nand(x,y):
15
+ return not(x and y)
16
+
17
+ def xor(x,y):
18
+ return (x or y) and (nand(x,y))
19
+
20
+ def xnor(x,y):
21
+ return not(xor(x,y))
22
+
23
+ def conv_bin(x):
24
+ return bin(x)[2:]
25
+
26
+ def conv_dec(x):
27
+ return int(x, 2)
@@ -0,0 +1,113 @@
1
+ #number_theory.py
2
+ from .arithmetic import abs
3
+ def gcd(x,y):
4
+ xFactors = []
5
+ yFactors = []
6
+ for i in range(1,x+1):
7
+ if x % i == 0:
8
+ xFactors.append(i)
9
+ for i in range(1,y+1):
10
+ if y % i == 0:
11
+ yFactors.append(i)
12
+ CommonFactors = []
13
+ for i in xFactors:
14
+ if i in yFactors:
15
+ CommonFactors.append(i)
16
+ return max(CommonFactors)
17
+
18
+ def lcm(x,y):
19
+ xFactors = []
20
+ yFactors = []
21
+ for i in range(1,x+1):
22
+ if x % i == 0:
23
+ xFactors.append(i)
24
+ for i in range(1,y+1):
25
+ if y % i == 0:
26
+ yFactors.append(i)
27
+ CommonFactors = []
28
+ for i in xFactors:
29
+ if i in yFactors:
30
+ CommonFactors.append(i)
31
+ return abs(x*y) // max(CommonFactors)
32
+
33
+ def is_prime(x):
34
+ xFactors = []
35
+ for i in range(1,x+1):
36
+ if x % i == 0:
37
+ xFactors.append(i)
38
+ if len(xFactors) == 2:
39
+ return True
40
+ return False
41
+
42
+ def is_composite(x):
43
+ xFactors = []
44
+ for i in range(1,x+1):
45
+ if x % i == 0:
46
+ xFactors.append(i)
47
+ if len(xFactors) > 2:
48
+ return True
49
+ return False
50
+
51
+ def factors(x):
52
+ xFactors = []
53
+ for i in range(1,x+1):
54
+ if x % i == 0:
55
+ xFactors.append(i)
56
+ return xFactors
57
+
58
+ def factorial(x):
59
+ val = 1
60
+ for i in range(1,x+1):
61
+ val *= i
62
+ return val
63
+
64
+ def is_odd(x):
65
+ return x%2 == 1
66
+
67
+ def is_even(x):
68
+ return x%2 == 0
69
+
70
+ def co_prime(x,y):
71
+ xFactors = []
72
+ yFactors = []
73
+ for i in range(1,x+1):
74
+ if x % i == 0:
75
+ xFactors.append(i)
76
+ for i in range(1,y+1):
77
+ if y % i == 0:
78
+ yFactors.append(i)
79
+ CommonFactors = []
80
+ for i in xFactors:
81
+ if i in yFactors:
82
+ CommonFactors.append(i)
83
+ return max(CommonFactors) == 1
84
+
85
+ def collatz_conjecture(x):
86
+ vals = []
87
+ temp = x
88
+ while True:
89
+ if temp % 2 == 0:
90
+ temp /= 2
91
+ elif temp % 2 == 1:
92
+ temp *= 3
93
+ temp += 1
94
+ vals.append(temp)
95
+ if temp == 1:
96
+ break
97
+ return vals
98
+
99
+ def fibbonacci(x):
100
+ if x < 0:
101
+ return "NegativeFibbonacciError"
102
+ vals = [0,1]
103
+ for i in range(0,x+1):
104
+ vals.append(vals[i]+vals[i+1])
105
+ return vals
106
+
107
+ def nth_fibbonacci(x):
108
+ if x < 0:
109
+ return "NegativeFibbonacciError"
110
+ vals = [0,1]
111
+ for i in range(0,x+1):
112
+ vals.append(vals[i]+vals[i+1])
113
+ return vals[len(vals)-1]
@@ -0,0 +1,78 @@
1
+ #set_theory.py
2
+ def union(x,y):
3
+ i = []
4
+ for j in x:
5
+ if j in i:
6
+ continue
7
+ i.append(j)
8
+ for j in y:
9
+ if j in i:
10
+ continue
11
+ i.append(j)
12
+ return i
13
+
14
+ def intersection(x,y):
15
+ i = []
16
+ for j in x:
17
+ if j in y:
18
+ i.append(j)
19
+ return i
20
+
21
+ def set_diff(x,y):
22
+ i = []
23
+ for j in x:
24
+ if j not in y:
25
+ i.append(j)
26
+ return i
27
+
28
+ def set_sym_diff(x,y):
29
+ i = set()
30
+ for j in x:
31
+ if j not in y:
32
+ i.add(j)
33
+ for j in y:
34
+ if j not in x:
35
+ i.add(j)
36
+ return i
37
+
38
+ def subset(x,y):
39
+ val = 0
40
+ for i in x:
41
+ if i in y:
42
+ val += 1
43
+ if val == len(x):
44
+ return True
45
+ return False
46
+
47
+ def superset(x,y):
48
+ val = 0
49
+ for i in y:
50
+ if i in x:
51
+ val += 1
52
+ if val == len(y):
53
+ return True
54
+ return False
55
+
56
+ def disjoint(x,y):
57
+ val = 0
58
+ for i in x:
59
+ if i not in y:
60
+ val += 1
61
+ if val == len(x):
62
+ return True
63
+ return False
64
+
65
+ def cartesian(x,y):
66
+ i = []
67
+ for j in x:
68
+ for k in y:
69
+ i.append((f"{j} : {k}"))
70
+ return i
71
+
72
+ def cardinality(x):
73
+ vals = []
74
+ for i in x:
75
+ if i in vals:
76
+ continue
77
+ vals.append(i)
78
+ return len(vals)
@@ -0,0 +1,24 @@
1
+ #statistics.py
2
+ from .arithmetic import add
3
+
4
+ def average(x):
5
+ return add(x)/len(x)
6
+
7
+ def mean(x):
8
+ if len(x)%2 == 1:
9
+ return x[len(x)//2]
10
+ return ((x[len(x)//2-1])+(x[len(x)//2]))/2
11
+
12
+ def mode(x):
13
+ counts = []
14
+ vals = []
15
+ for i in x:
16
+ counts.append(x.count(i))
17
+ vals.append(i)
18
+ return vals[counts.index(max(counts))]
19
+
20
+ def find_max(x):
21
+ return max(x)
22
+
23
+ def find_min(x):
24
+ return min(x)
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: sparsh-math-tools
3
+ Version: 1.0.0
4
+ Summary: A custom rational-first mathematics utility package.
5
+ Author: Sparsh Bansal
6
+ Requires-Python: >=3.11
7
+ Description-Content-Type: text/markdown
8
+ License-File: License.txt
9
+ Dynamic: license-file
10
+
11
+ # Math Tools (`math_tools`)
12
+
13
+ > A custom, rational-first Python mathematics utility package built from scratch with zero external dependencies.
14
+
15
+ - **Author:** Sparsh Bansal
16
+ - **Version:** 1.0.0
17
+ - **Python Compatibility:** Python 3.11+ (configured with unlimited integer string conversion for arbitrary-precision sequences)
18
+
19
+ ---
20
+
21
+ ## Overview
22
+
23
+ `math_tools` is a lightweight, modular mathematics library containing **78 functions** organized across **7 core mathematical domains**. Designed with a **rational-first** philosophy, its geometry, fraction, coordinate, and arithmetic utilities avoid irrational constants (such as $\pi$) wherever possible, relying on clean algebraic and coordinate formulations.
24
+
25
+ ---
26
+
27
+ ## Project Structure
28
+
29
+ ```text
30
+ your_project/
31
+ ├── README.md
32
+ ├── test.py # Full test suite verifying all 78 functions
33
+ └── math_tools/
34
+ ├── __init__.py # Package initializer, metadata, and credits helper
35
+ ├── arithmetic.py # Core arithmetic, roots, percentages, and kinematics
36
+ ├── number_theory.py # Primes, factors, GCD/LCM, Collatz, and Fibonacci
37
+ ├── set_theory.py # Set operations, relations, Cartesian products, cardinality
38
+ ├── geometry.py # 2D areas, 2D/3D distance, midpoint, slope, lines, section formula
39
+ ├── fractions.py # Rational fraction arithmetic, simplification, and conversions
40
+ ├── statistics.py # Measures of central tendency and extrema
41
+ └── logic.py # Boolean logic gates and binary/decimal conversions
42
+ ```
43
+
44
+ ---
45
+
46
+ ## Installation & Quick Start
47
+
48
+ 1. Place the `math_tools/` folder inside your project directory (or add its parent folder to your Python path).
49
+ 2. Import the entire package or specific submodules directly in your Python script:
50
+
51
+ ```python
52
+ import math_tools as mt
53
+
54
+ # Check package credits
55
+ print(mt.credits)
56
+
57
+ # Run functions across modules
58
+ print(mt.fibbonacci(6)) # [0, 1, 1, 2, 3, 5, 8, 13, 21]
59
+ print(mt.add_frac(1, 4, 1, 2)) # (3.0, 4)
60
+ print(mt.distance(0, 0, 3, 4)) # 5.0
61
+ print(mt.xor(True, False)) # True
62
+ ```
63
+
64
+ You can also import individual submodules to keep memory usage minimal:
65
+
66
+ ```python
67
+ from math_tools import geometry, number_theory
68
+
69
+ print(geometry.midpoint(2, 4, 6, 8)) # (4.0, 6.0)
70
+ print(number_theory.gcd(12, 18)) # 6
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Module Reference (78 Functions)
76
+
77
+ ### 1. `arithmetic.py` (18 Functions)
78
+ Core list-based arithmetic operations, rounding, roots, percentages, and speed-distance-time formulas.
79
+
80
+ | Function | Description |
81
+ | :--- | :--- |
82
+ | `add(x)` | Returns the sum of all numbers in list `x`. |
83
+ | `sub(x)` | Sequentially subtracts remaining elements in list `x` from `x[0]`. |
84
+ | `mul(x)` | Returns the product of all numbers in list `x`. |
85
+ | `div(x)` | Sequentially divides `x[0]` by subsequent elements in `x` (handles zero division). |
86
+ | `mod(x)` | Sequentially computes modulo of `x[0]` by subsequent elements in `x`. |
87
+ | `pow(x)` | Sequentially raises `x[0]` to the power of subsequent elements in `x`. |
88
+ | `ceil(x)` | Returns the smallest integer greater than or equal to `x`. |
89
+ | `floor(x)` | Returns the largest integer less than or equal to `x`. |
90
+ | `floor_div(x)` | Performs sequential floor division across list `x`. |
91
+ | `ceil_div(x)` | Performs sequential ceiling division across list `x`. |
92
+ | `abs(x)` | Returns the absolute value of `x`. |
93
+ | `root(x, y)` | Computes the $y$-th root of `x` ($x^{1/y}$). |
94
+ | `percent_of(x, y)` | Calculates what percentage `x` is of `y`. |
95
+ | `percentage(x, y)` | Calculates `x`% of `y`. |
96
+ | `percent_change(x, y)` | Calculates percentage change from `x` to `y`. |
97
+ | `calc_speed(x, y)` | Calculates speed given distance `x` and time `y`. |
98
+ | `calc_distance(x, y)` | Calculates distance given speed `x` and time `y`. |
99
+ | `calc_time(x, y)` | Calculates time given distance `x` and speed `y`. |
100
+
101
+ ---
102
+
103
+ ### 2. `number_theory.py` (12 Functions)
104
+ Divisibility, primality, factorials, and classic integer sequences.
105
+
106
+ | Function | Description |
107
+ | :--- | :--- |
108
+ | `gcd(x, y)` | Returns the Greatest Common Divisor of `x` and `y`. |
109
+ | `lcm(x, y)` | Returns the Least Common Multiple of `x` and `y`. |
110
+ | `is_prime(x)` | Returns `True` if `x` is a prime number. |
111
+ | `is_composite(x)` | Returns `True` if `x` is a composite number. |
112
+ | `factors(x)` | Returns a list of all positive divisors of `x`. |
113
+ | `factorial(x)` | Computes $x!$ iteratively. |
114
+ | `is_odd(x)` | Returns `True` if `x` is odd. |
115
+ | `is_even(x)` | Returns `True` if `x` is even. |
116
+ | `co_prime(x, y)` | Returns `True` if `gcd(x, y) == 1`. |
117
+ | `collatz_conjecture(x)` | Generates the Collatz hailstone sequence starting at `x` down to `1`. |
118
+ | `fibbonacci(x)` | Generates the Fibonacci sequence up to index `x`. |
119
+ | `nth_fibbonacci(x)` | Returns the Fibonacci number at index `x`. |
120
+
121
+ ---
122
+
123
+ ### 3. `set_theory.py` (9 Functions)
124
+ Discrete set operations implemented from scratch on iterables.
125
+
126
+ | Function | Description |
127
+ | :--- | :--- |
128
+ | `union(x, y)` | Returns unique elements present in `x` or `y`. |
129
+ | `intersection(x, y)` | Returns elements common to both `x` and `y`. |
130
+ | `set_diff(x, y)` | Returns elements in `x` that are not in `y` ($x \setminus y$). |
131
+ | `set_sym_diff(x, y)` | Returns elements in either `x` or `y`, but not both ($x riangle y$). |
132
+ | `subset(x, y)` | Returns `True` if `x` is a subset of `y` ($x \subseteq y$). |
133
+ | `superset(x, y)` | Returns `True` if `x` is a superset of `y` ($x \supseteq y$). |
134
+ | `disjoint(x, y)` | Returns `True` if `x` and `y` share no elements. |
135
+ | `cartesian(x, y)` | Returns formatted pairs representing the Cartesian product $x imes y$. |
136
+ | `cardinality(x)` | Returns the count of unique elements in `x` ($ ert x ert$). |
137
+
138
+ ---
139
+
140
+ ### 4. `geometry.py` (17 Functions)
141
+ Rational 2D area formulas and 2D/3D coordinate geometry utilities.
142
+
143
+ | Function | Description |
144
+ | :--- | :--- |
145
+ | `square_area(x)` | Area of a square with side `x`. |
146
+ | `area_rectangle(x, y)` | Area of a rectangle with sides `x` and `y`. |
147
+ | `area_paralellogram(x, y)` | Area of a parallelogram with base `x` and height `y`. |
148
+ | `area_rhombus(x, y)` | Area of a rhombus given diagonals `x` and `y`. |
149
+ | `area_kite(x, y)` | Area of a kite given diagonals `x` and `y`. |
150
+ | `area_trapezium(x, y, z)` | Area of a trapezium with parallel sides `x`, `y` and height `z`. |
151
+ | `area_regular_triangle(x, y)` | Area of a triangle with base `x` and height `y`. |
152
+ | `area_right_triangle(x, y)` | Area of a right triangle with legs `x` and `y`. |
153
+ | `area_ngon(x, y, z)` | Area of a regular $n$-gon with `x` sides, side length `y`, and apothem `z`. |
154
+ | `distance(x1, y1, x2, y2)` | Euclidean distance between two 2D points. |
155
+ | `3D_distance(x1, y1, z1, x2, y2, z2)` | Euclidean distance between two 3D points. |
156
+ | `midpoint(x1, y1, x2, y2)` | Midpoint coordinates between two 2D points. |
157
+ | `3D_midpoint(x1, y1, z1, x2, y2, z2)` | Midpoint coordinates between two 3D points. |
158
+ | `slope_formula(x1, y1, x2, y2)` | Slope $m$ of a line passing through two 2D points. |
159
+ | `3D_slope_formula(x1, y1, z1, x2, y2, z2)` | 3D direction vector $(dx, dy, dz)$ between two points. |
160
+ | `line_relationship(...)` | Classifies two infinite lines (`Coincident`, `Parallel`, `Perpendicular`, `Intersecting`) and returns intersection coordinates. |
161
+ | `section_formula(x1, y1, x2, y2, m, n)` | Internal division point dividing segment in ratio $m:n$. |
162
+
163
+ ---
164
+
165
+ ### 5. `fractions.py` (10 Functions)
166
+ Exact rational fraction arithmetic, comparison, and mixed/improper conversions.
167
+
168
+ | Function | Description |
169
+ | :--- | :--- |
170
+ | `simplest_form(x, y)` | Reduces fraction $x/y$ by its GCD. |
171
+ | `add_frac(x1, y1, x2, y2)` | Adds two fractions and formats improper sums as mixed fractions. |
172
+ | `sub_frac(x1, y1, x2, y2)` | Subtracts two fractions using common denominators. |
173
+ | `mul_frac(x1, y1, x2, y2)` | Multiplies two fractions ($x_1x_2 / y_1y_2$). |
174
+ | `div_frac(x1, y1, x2, y2)` | Divides two fractions ($x_1y_2 / x_2y_1$). |
175
+ | `compare(x1, y1, x2, y2)` | Compares two fractions via cross-multiplication. |
176
+ | `equivalent_fractions(x, y, z)` | Generates the first `z` equivalent multiples of $x/y$. |
177
+ | `check_equivalent(x1, y1, x2, y2)` | Returns `True` if $x_1/y_1 = x_2/y_2$. |
178
+ | `conv_mixed_frac(x, y, z)` | Converts mixed fraction $z rac{x}{y}$ to an improper fraction tuple. |
179
+ | `conv_improper_frac(x, y)` | Converts improper fraction $x/y$ into `(remainder, whole, denominator)`. |
180
+
181
+ ---
182
+
183
+ ### 6. `statistics.py` (5 Functions)
184
+ Descriptive statistics for numeric lists.
185
+
186
+ | Function | Description |
187
+ | :--- | :--- |
188
+ | `average(x)` | Computes the arithmetic mean of list `x`. |
189
+ | `mean(x)` | Computes the middle value (median) of list `x`. |
190
+ | `mode(x)` | Returns the most frequently occurring element in `x`. |
191
+ | `find_max(x)` | Returns the maximum value in `x`. |
192
+ | `find_min(x)` | Returns the minimum value in `x`. |
193
+
194
+ ---
195
+
196
+ ### 7. `logic.py` (9 Functions)
197
+ Boolean logic gates and base-2 / base-10 converters.
198
+
199
+ | Function | Description |
200
+ | :--- | :--- |
201
+ | `and(x, y)` | Logical AND gate. |
202
+ | `or(x, y)` | Logical OR gate. |
203
+ | `not(x)` | Logical NOT gate. |
204
+ | `nor(x, y)` | Logical NOR gate. |
205
+ | `nand(x, y)` | Logical NAND gate. |
206
+ | `xor(x, y)` | Logical Exclusive OR gate. |
207
+ | `xnor(x, y)` | Logical Exclusive NOR gate. |
208
+ | `conv_bin(x)` | Converts decimal integer `x` to a binary string. |
209
+ | `conv_dec(x)` | Converts binary string `x` to a decimal integer. |
210
+
211
+ ---
212
+
213
+ ## Running Tests
214
+
215
+ Execute the included test suite to verify every function across all 7 submodules:
216
+
217
+ ```bash
218
+ python test.py
219
+ ```
@@ -0,0 +1,13 @@
1
+ Math_Tools/__init__.py,sha256=niMGBB7rrPWORB59HblNs_FB7uHirBzeHWVNpee288E,351
2
+ Math_Tools/arithmetic.py,sha256=p_sCHOIxyImI62wh6jlOQVebbqjkeUp7ss864bwHOAw,1380
3
+ Math_Tools/fractions.py,sha256=JIvYcpxWeuDd7XlY-zjaoNwq0JIHZbxNd2-wBpR5lFM,1487
4
+ Math_Tools/geometry.py,sha256=aFQ5R6-FCnBuk5QXFZ9YRXnr5qo8cA7BlSQjGK8ZDGs,1690
5
+ Math_Tools/logic.py,sha256=aS6yM6c6HJb6RoYst05UcsuMzZLt9t9KzrElER1017k,375
6
+ Math_Tools/number_theory.py,sha256=3FdPD2HNqjXTJ5lszAx5awJuYnfyvdc6YyHA1dBYZsM,2275
7
+ Math_Tools/set_theory.py,sha256=lxOzX3ozbPPG3TnImjZ2u7RsI453j44y_6FQXeFJpmI,1265
8
+ Math_Tools/statistics.py,sha256=u7kGq-XUjgTktIEiKj272wzygK-pUt48vSEMXLltPfY,422
9
+ sparsh_math_tools-1.0.0.dist-info/licenses/License.txt,sha256=PSrFqyj2EVRKWS6iTWwGjdUXPQ5IHhHpRYbJ2dFToZ8,1093
10
+ sparsh_math_tools-1.0.0.dist-info/METADATA,sha256=v3XCfjC93Iu9sfi1CT0KlGNzRz7Fwvve82tm08rV8RA,10019
11
+ sparsh_math_tools-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
12
+ sparsh_math_tools-1.0.0.dist-info/top_level.txt,sha256=0C8f6T0n2s-MTGe7-zQ_vXThMeXWufohCnLTFHuX0aA,11
13
+ sparsh_math_tools-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2026] [SPARSH BANSAL]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ Math_Tools