hypermath-Kavyansh-Arya 0.2.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.
HyperMath.py
ADDED
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
|
|
2
|
+
class factorial:
|
|
3
|
+
def __init__(self, n):
|
|
4
|
+
self.n = n
|
|
5
|
+
|
|
6
|
+
def calculate(self):
|
|
7
|
+
if self.n < 0:
|
|
8
|
+
raise ValueError("Factorial is not defined for negative numbers.")
|
|
9
|
+
elif self.n == 0 or self.n == 1:
|
|
10
|
+
return 1
|
|
11
|
+
else:
|
|
12
|
+
result = 1
|
|
13
|
+
for i in range(2, self.n + 1):
|
|
14
|
+
result *= i
|
|
15
|
+
return result
|
|
16
|
+
class double_factorial:
|
|
17
|
+
def __init__(self, n):
|
|
18
|
+
self.n = n
|
|
19
|
+
|
|
20
|
+
def calculate(self):
|
|
21
|
+
if self.n < 0:
|
|
22
|
+
raise ValueError("Double factorial is not defined for negative numbers.")
|
|
23
|
+
elif self.n == 0 or self.n == 1:
|
|
24
|
+
return 1
|
|
25
|
+
else:
|
|
26
|
+
result = 1
|
|
27
|
+
for i in range(self.n, 0, -2):
|
|
28
|
+
result *= i
|
|
29
|
+
return result
|
|
30
|
+
class square_root:
|
|
31
|
+
def __init__(self, n):
|
|
32
|
+
self.n = n
|
|
33
|
+
|
|
34
|
+
def calculate(self):
|
|
35
|
+
if self.n < 0:
|
|
36
|
+
raise ValueError("Square root is not defined for negative numbers.")
|
|
37
|
+
return self.n ** 0.5
|
|
38
|
+
class superfactorial(factorial):
|
|
39
|
+
def calculate(self):
|
|
40
|
+
if self.n < 0:
|
|
41
|
+
raise ValueError("Superfactorial is not defined for negative numbers.")
|
|
42
|
+
elif self.n == 0 or self.n == 1:
|
|
43
|
+
return 1
|
|
44
|
+
else:
|
|
45
|
+
result = 1
|
|
46
|
+
for i in range(1, self.n + 1):
|
|
47
|
+
result *= factorial(i).calculate()
|
|
48
|
+
return result
|
|
49
|
+
class exponentiation:
|
|
50
|
+
def __init__(self, base, exponent):
|
|
51
|
+
self.base = base
|
|
52
|
+
self.exponent = exponent
|
|
53
|
+
|
|
54
|
+
def calculate(self):
|
|
55
|
+
return self.base ** self.exponent
|
|
56
|
+
class successor:
|
|
57
|
+
def __init__(self, n):
|
|
58
|
+
self.n = n
|
|
59
|
+
|
|
60
|
+
def calculate(self):
|
|
61
|
+
return self.n + 1
|
|
62
|
+
class tetration:
|
|
63
|
+
def __init__(self, base, height):
|
|
64
|
+
self.base = base
|
|
65
|
+
self.height = height
|
|
66
|
+
|
|
67
|
+
def calculate(self):
|
|
68
|
+
if self.height < 0:
|
|
69
|
+
raise ValueError("Tetration is not defined for negative heights.")
|
|
70
|
+
elif self.height == 0:
|
|
71
|
+
return 1
|
|
72
|
+
else:
|
|
73
|
+
result = self.base
|
|
74
|
+
for _ in range(1, self.height):
|
|
75
|
+
result = self.base ** result
|
|
76
|
+
return result
|
|
77
|
+
class pentation:
|
|
78
|
+
def __init__(self, base, height):
|
|
79
|
+
self.base = base
|
|
80
|
+
self.height = height
|
|
81
|
+
|
|
82
|
+
def calculate(self):
|
|
83
|
+
if self.height < 0:
|
|
84
|
+
raise ValueError("Pentation is not defined for negative heights.")
|
|
85
|
+
elif self.height == 0:
|
|
86
|
+
return 1
|
|
87
|
+
else:
|
|
88
|
+
result = self.base
|
|
89
|
+
for _ in range(1, self.height):
|
|
90
|
+
result = tetration(self.base, result).calculate()
|
|
91
|
+
return result
|
|
92
|
+
class complex_number:
|
|
93
|
+
def __init__(self, real, imaginary):
|
|
94
|
+
self.real = real
|
|
95
|
+
self.imaginary = imaginary
|
|
96
|
+
|
|
97
|
+
def calculate(self):
|
|
98
|
+
return complex(self.real, self.imaginary)
|
|
99
|
+
class logarithm:
|
|
100
|
+
def __init__(self, base, value):
|
|
101
|
+
self.base = base
|
|
102
|
+
self.value = value
|
|
103
|
+
|
|
104
|
+
def calculate(self):
|
|
105
|
+
if self.base <= 0 or self.base == 1:
|
|
106
|
+
raise ValueError("Logarithm base must be positive and not equal to 1.")
|
|
107
|
+
if self.value <= 0:
|
|
108
|
+
raise ValueError("Logarithm value must be positive.")
|
|
109
|
+
import math
|
|
110
|
+
return math.log(self.value, self.base)
|
|
111
|
+
class constants:
|
|
112
|
+
def __init__(self):
|
|
113
|
+
self.pi = 3.141592653589793
|
|
114
|
+
self.e = 2.718281828459045
|
|
115
|
+
self.phi = 1.618033988749895
|
|
116
|
+
|
|
117
|
+
def get_constant(self, name):
|
|
118
|
+
if name == "pi":
|
|
119
|
+
return self.pi
|
|
120
|
+
elif name == "e":
|
|
121
|
+
return self.e
|
|
122
|
+
elif name == "phi":
|
|
123
|
+
return self.phi
|
|
124
|
+
else:
|
|
125
|
+
raise ValueError("Unknown constant name.")
|
|
126
|
+
class arithmetic_operations:
|
|
127
|
+
def add(self, a, b):
|
|
128
|
+
return a + b
|
|
129
|
+
|
|
130
|
+
def subtract(self, a, b):
|
|
131
|
+
return a - b
|
|
132
|
+
|
|
133
|
+
def multiply(self, a, b):
|
|
134
|
+
return a * b
|
|
135
|
+
|
|
136
|
+
def divide(self, a, b):
|
|
137
|
+
if b == 0:
|
|
138
|
+
raise ValueError("Division by zero is not allowed.")
|
|
139
|
+
return a / b
|
|
140
|
+
class trigonometric_functions:
|
|
141
|
+
def sine(self, angle):
|
|
142
|
+
import math
|
|
143
|
+
return math.sin(angle)
|
|
144
|
+
|
|
145
|
+
def cosine(self, angle):
|
|
146
|
+
import math
|
|
147
|
+
return math.cos(angle)
|
|
148
|
+
|
|
149
|
+
def tangent(self, angle):
|
|
150
|
+
import math
|
|
151
|
+
return math.tan(angle)
|
|
152
|
+
class hexation:
|
|
153
|
+
def __init__(self, base, height):
|
|
154
|
+
self.base = base
|
|
155
|
+
self.height = height
|
|
156
|
+
|
|
157
|
+
def calculate(self):
|
|
158
|
+
if self.height < 0:
|
|
159
|
+
raise ValueError("Hexation is not defined for negative heights.")
|
|
160
|
+
elif self.height == 0:
|
|
161
|
+
return 1
|
|
162
|
+
else:
|
|
163
|
+
result = self.base
|
|
164
|
+
for _ in range(1, self.height):
|
|
165
|
+
result = pentation(self.base, result).calculate()
|
|
166
|
+
return result
|
|
167
|
+
class limit:
|
|
168
|
+
def __init__(self, function, variable, approach):
|
|
169
|
+
self.function = function
|
|
170
|
+
self.variable = variable
|
|
171
|
+
self.approach = approach
|
|
172
|
+
|
|
173
|
+
def calculate(self):
|
|
174
|
+
import sympy as sp
|
|
175
|
+
x = sp.symbols(self.variable)
|
|
176
|
+
limit_value = sp.limit(self.function, x, self.approach)
|
|
177
|
+
return limit_value
|
|
178
|
+
class derivative:
|
|
179
|
+
def __init__(self, function, variable):
|
|
180
|
+
self.function = function
|
|
181
|
+
self.variable = variable
|
|
182
|
+
|
|
183
|
+
def calculate(self):
|
|
184
|
+
import sympy as sp
|
|
185
|
+
x = sp.symbols(self.variable)
|
|
186
|
+
derivative_value = sp.diff(self.function, x)
|
|
187
|
+
return derivative_value
|
|
188
|
+
class integral:
|
|
189
|
+
def __init__(self, function, variable):
|
|
190
|
+
self.function = function
|
|
191
|
+
self.variable = variable
|
|
192
|
+
|
|
193
|
+
def calculate(self):
|
|
194
|
+
import sympy as sp
|
|
195
|
+
x = sp.symbols(self.variable)
|
|
196
|
+
integral_value = sp.integrate(self.function, x)
|
|
197
|
+
return integral_value
|
|
198
|
+
class quadratic_equation:
|
|
199
|
+
def __init__(self, a, b, c):
|
|
200
|
+
self.a = a
|
|
201
|
+
self.b = b
|
|
202
|
+
self.c = c
|
|
203
|
+
|
|
204
|
+
def calculate(self):
|
|
205
|
+
import math
|
|
206
|
+
discriminant = self.b ** 2 - 4 * self.a * self.c
|
|
207
|
+
if discriminant < 0:
|
|
208
|
+
raise ValueError("No real roots exist.")
|
|
209
|
+
root1 = (-self.b + math.sqrt(discriminant)) / (2 * self.a)
|
|
210
|
+
root2 = (-self.b - math.sqrt(discriminant)) / (2 * self.a)
|
|
211
|
+
return root1, root2
|
|
212
|
+
class uncommon_constants:
|
|
213
|
+
def __init__(self):
|
|
214
|
+
self.constants = {
|
|
215
|
+
"golden_ratio": 1.618033988749895,
|
|
216
|
+
"euler_mascheroni": 0.577215664901532,
|
|
217
|
+
"aperys_constant": 1.202056903159594,
|
|
218
|
+
"catalans_constant": 0.915965594177219,
|
|
219
|
+
"khinchin_constant": 2.685452001065306
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
def get_constant(self, name):
|
|
223
|
+
if name in self.constants:
|
|
224
|
+
return self.constants[name]
|
|
225
|
+
else:
|
|
226
|
+
raise ValueError("Unknown constant name.")
|
|
227
|
+
class decimal_exponent:
|
|
228
|
+
def __init__(self, base, exponent):
|
|
229
|
+
self.base = base
|
|
230
|
+
self.exponent = exponent
|
|
231
|
+
|
|
232
|
+
def calculate(self):
|
|
233
|
+
return self.base ** self.exponent
|
|
234
|
+
|
|
235
|
+
return result
|
|
236
|
+
class hyperfactorial:
|
|
237
|
+
def __init__(self, n):
|
|
238
|
+
self.n = n
|
|
239
|
+
|
|
240
|
+
def calculate(self):
|
|
241
|
+
if self.n < 0:
|
|
242
|
+
raise ValueError("Hyperfactorial is not defined for negative numbers.")
|
|
243
|
+
result = 1
|
|
244
|
+
for i in range(1, self.n + 1):
|
|
245
|
+
result *= i ** i
|
|
246
|
+
return result
|
|
247
|
+
class predecessor:
|
|
248
|
+
def __init__(self, n):
|
|
249
|
+
self.n = n
|
|
250
|
+
|
|
251
|
+
def calculate(self):
|
|
252
|
+
return self.n - 1
|
|
253
|
+
|
|
254
|
+
class complex_exponentiation:
|
|
255
|
+
def __init__(self, base, exponent):
|
|
256
|
+
self.base = base
|
|
257
|
+
self.exponent = exponent
|
|
258
|
+
|
|
259
|
+
def calculate(self):
|
|
260
|
+
return self.base ** self.exponent
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
class paradoxes:
|
|
264
|
+
def __init__(self):
|
|
265
|
+
self.paradoxes = {
|
|
266
|
+
"liars_paradox": "This statement is false.",
|
|
267
|
+
"barbers_paradox": "The barber is the one who shaves all those, and those only, who do not shave themselves.",
|
|
268
|
+
"russells_paradox": "The set of all sets that do not contain themselves.",
|
|
269
|
+
"achilles_and_tortoise": "Achilles can never overtake the tortoise in a race if the tortoise has a head start.",
|
|
270
|
+
"grandfather_paradox": "If you travel back in time and kill your grandfather, you would never have been born to go back in time."
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
def get_paradox(self, name):
|
|
274
|
+
if name in self.paradoxes:
|
|
275
|
+
return self.paradoxes[name]
|
|
276
|
+
else:
|
|
277
|
+
raise ValueError("Unknown paradox name.")
|
|
278
|
+
class inequality_solver:
|
|
279
|
+
def __init__(self, inequality, variable):
|
|
280
|
+
self.inequality = inequality
|
|
281
|
+
self.variable = variable
|
|
282
|
+
|
|
283
|
+
def solve(self):
|
|
284
|
+
import sympy as sp
|
|
285
|
+
x = sp.symbols(self.variable)
|
|
286
|
+
solution = sp.solve_univariate_inequality(self.inequality, x)
|
|
287
|
+
return solution
|
|
288
|
+
class identity_matrix:
|
|
289
|
+
def __init__(self, size):
|
|
290
|
+
self.size = size
|
|
291
|
+
|
|
292
|
+
def generate(self):
|
|
293
|
+
import numpy as np
|
|
294
|
+
return np.identity(self.size)
|
|
295
|
+
class computer_number_system:
|
|
296
|
+
def __init__(self, number, base):
|
|
297
|
+
self.number = number
|
|
298
|
+
self.base = base
|
|
299
|
+
|
|
300
|
+
def convert(self):
|
|
301
|
+
if self.base < 2 or self.base > 36:
|
|
302
|
+
raise ValueError("Base must be between 2 and 36.")
|
|
303
|
+
if self.number < 0:
|
|
304
|
+
raise ValueError("Number must be non-negative.")
|
|
305
|
+
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
306
|
+
result = ""
|
|
307
|
+
n = self.number
|
|
308
|
+
while n > 0:
|
|
309
|
+
result = digits[n % self.base] + result
|
|
310
|
+
n //= self.base
|
|
311
|
+
return result if result else "0"
|
|
312
|
+
class nth_root:
|
|
313
|
+
def __init__(self, n, root):
|
|
314
|
+
self.n = n
|
|
315
|
+
self.root = root
|
|
316
|
+
|
|
317
|
+
def calculate(self):
|
|
318
|
+
if self.root <= 0:
|
|
319
|
+
raise ValueError("Root must be positive.")
|
|
320
|
+
return self.n ** (1 / self.root)
|
|
321
|
+
class calculus:
|
|
322
|
+
def __init__(self, function, variable):
|
|
323
|
+
self.function = function
|
|
324
|
+
self.variable = variable
|
|
325
|
+
|
|
326
|
+
def differentiate(self):
|
|
327
|
+
import sympy as sp
|
|
328
|
+
x = sp.symbols(self.variable)
|
|
329
|
+
derivative_value = sp.diff(self.function, x)
|
|
330
|
+
return derivative_value
|
|
331
|
+
|
|
332
|
+
def integrate(self):
|
|
333
|
+
import sympy as sp
|
|
334
|
+
x = sp.symbols(self.variable)
|
|
335
|
+
integral_value = sp.integrate(self.function, x)
|
|
336
|
+
return integral_value
|
|
337
|
+
class fibonacci:
|
|
338
|
+
def __init__(self, n):
|
|
339
|
+
self.n = n
|
|
340
|
+
|
|
341
|
+
def calculate(self):
|
|
342
|
+
if self.n < 0:
|
|
343
|
+
raise ValueError("Fibonacci is not defined for negative numbers.")
|
|
344
|
+
elif self.n == 0:
|
|
345
|
+
return 0
|
|
346
|
+
elif self.n == 1:
|
|
347
|
+
return 1
|
|
348
|
+
else:
|
|
349
|
+
a, b = 0, 1
|
|
350
|
+
for _ in range(2, self.n + 1):
|
|
351
|
+
a, b = b, a + b
|
|
352
|
+
return b
|
|
353
|
+
class tribonacci:
|
|
354
|
+
def __init__(self, n):
|
|
355
|
+
self.n = n
|
|
356
|
+
|
|
357
|
+
def calculate(self):
|
|
358
|
+
if self.n < 0:
|
|
359
|
+
raise ValueError("Tribonacci is not defined for negative numbers.")
|
|
360
|
+
elif self.n == 0:
|
|
361
|
+
return 0
|
|
362
|
+
elif self.n == 1 or self.n == 2:
|
|
363
|
+
return 1
|
|
364
|
+
else:
|
|
365
|
+
a, b, c = 0, 1, 1
|
|
366
|
+
for _ in range(3, self.n + 1):
|
|
367
|
+
a, b, c = b, c, a + b + c
|
|
368
|
+
return c
|
|
369
|
+
class tetranacci:
|
|
370
|
+
def __init__(self, n):
|
|
371
|
+
self.n = n
|
|
372
|
+
|
|
373
|
+
def calculate(self):
|
|
374
|
+
if self.n < 0:
|
|
375
|
+
raise ValueError("Tetranacci is not defined for negative numbers.")
|
|
376
|
+
elif self.n == 0:
|
|
377
|
+
return 0
|
|
378
|
+
elif self.n == 1 or self.n == 2:
|
|
379
|
+
return 1
|
|
380
|
+
elif self.n == 3:
|
|
381
|
+
return 2
|
|
382
|
+
else:
|
|
383
|
+
a, b, c, d = 0, 1, 1, 2
|
|
384
|
+
for _ in range(4, self.n + 1):
|
|
385
|
+
a, b, c, d = b, c, d, a + b + c + d
|
|
386
|
+
return d
|
|
387
|
+
|
|
388
|
+
class round_up:
|
|
389
|
+
def __init__(self, n):
|
|
390
|
+
self.n = n
|
|
391
|
+
|
|
392
|
+
def calculate(self):
|
|
393
|
+
import math
|
|
394
|
+
return math.ceil(self.n)
|
|
395
|
+
class round_down:
|
|
396
|
+
def __init__(self, n):
|
|
397
|
+
self.n = n
|
|
398
|
+
|
|
399
|
+
def calculate(self):
|
|
400
|
+
import math
|
|
401
|
+
return math.floor(self.n)
|
|
402
|
+
class round_nearest:
|
|
403
|
+
def __init__(self, n):
|
|
404
|
+
self.n = n
|
|
405
|
+
|
|
406
|
+
def calculate(self):
|
|
407
|
+
import math
|
|
408
|
+
return round(self.n)
|
|
409
|
+
class absolute_value:
|
|
410
|
+
def __init__(self, n):
|
|
411
|
+
self.n = n
|
|
412
|
+
|
|
413
|
+
def calculate(self):
|
|
414
|
+
return abs(self.n)
|
|
415
|
+
class tensor_product:
|
|
416
|
+
def __init__(self, A, B):
|
|
417
|
+
self.A = A
|
|
418
|
+
self.B = B
|
|
419
|
+
|
|
420
|
+
def calculate(self):
|
|
421
|
+
import numpy as np
|
|
422
|
+
return np.kron(self.A, self.B)
|
|
423
|
+
class lie_bracket:
|
|
424
|
+
def __init__(self, A, B):
|
|
425
|
+
self.A = A
|
|
426
|
+
self.B = B
|
|
427
|
+
|
|
428
|
+
def calculate(self):
|
|
429
|
+
import numpy as np
|
|
430
|
+
return np.dot(self.A, self.B) - np.dot(self.B, self.A)
|
|
431
|
+
class pi_finder:
|
|
432
|
+
def __init__(self, iterations, precision=100):
|
|
433
|
+
if iterations < 1:
|
|
434
|
+
raise ValueError("Iterations must be at least 1.")
|
|
435
|
+
if precision < 1:
|
|
436
|
+
raise ValueError("Precision must be at least 1.")
|
|
437
|
+
|
|
438
|
+
self.iterations = iterations
|
|
439
|
+
self.precision = precision
|
|
440
|
+
|
|
441
|
+
def calculate(self):
|
|
442
|
+
from decimal import Decimal, getcontext
|
|
443
|
+
|
|
444
|
+
getcontext().prec = self.precision
|
|
445
|
+
|
|
446
|
+
C = Decimal(426880) * Decimal(10005).sqrt()
|
|
447
|
+
|
|
448
|
+
K = 6
|
|
449
|
+
M = 1
|
|
450
|
+
X = 1
|
|
451
|
+
L = 13591409
|
|
452
|
+
S = Decimal(L)
|
|
453
|
+
|
|
454
|
+
for i in range(1, self.iterations):
|
|
455
|
+
M = (K**3 - 16 * K) * M // (i**3)
|
|
456
|
+
L += 545140134
|
|
457
|
+
X *= -262537412640768000
|
|
458
|
+
|
|
459
|
+
S += Decimal(M * L) / Decimal(X)
|
|
460
|
+
|
|
461
|
+
K += 12
|
|
462
|
+
|
|
463
|
+
return C / S
|
|
464
|
+
|
|
465
|
+
class gamma:
|
|
466
|
+
def __init__(self, value):
|
|
467
|
+
if value <= -1 and value == int(value):
|
|
468
|
+
raise ValueError("Factorial is undefined for negative integers.")
|
|
469
|
+
|
|
470
|
+
self.value = value
|
|
471
|
+
|
|
472
|
+
def calculate(self):
|
|
473
|
+
import math
|
|
474
|
+
return math.gamma(self.value + 1)
|
|
475
|
+
class unit_covertor:
|
|
476
|
+
def __init__(self, value, from_unit, to_unit):
|
|
477
|
+
self.value = value
|
|
478
|
+
self.from_unit = from_unit
|
|
479
|
+
self.to_unit = to_unit
|
|
480
|
+
|
|
481
|
+
def convert(self):
|
|
482
|
+
conversion_factors = {
|
|
483
|
+
"m_to_km": 0.001,
|
|
484
|
+
"km_to_m": 1000,
|
|
485
|
+
"cm_to_m": 0.01,
|
|
486
|
+
"m_to_cm": 100,
|
|
487
|
+
"in_to_cm": 2.54,
|
|
488
|
+
"cm_to_in": 1 / 2.54,
|
|
489
|
+
"ft_to_m": 0.3048,
|
|
490
|
+
"m_to_ft": 1 / 0.3048,
|
|
491
|
+
"lb_to_kg": 0.45359237,
|
|
492
|
+
"kg_to_lb": 1 / 0.45359237,
|
|
493
|
+
"oz_to_g": 28.3495,
|
|
494
|
+
"g_to_oz": 1 / 28.3495,
|
|
495
|
+
"l_to_ml": 1000,
|
|
496
|
+
"ml_to_l": 0.001,
|
|
497
|
+
"gal_to_l": 3.78541,
|
|
498
|
+
"l_to_gal": 1 / 3.78541,
|
|
499
|
+
"mi_to_km": 1.60934,
|
|
500
|
+
"km_to_mi": 1 / 1.60934,
|
|
501
|
+
"yd_to_m": 0.9144,
|
|
502
|
+
"m_to_yd": 1 / 0.9144,
|
|
503
|
+
"ft_to_in": 12,
|
|
504
|
+
"in_to_ft": 1 / 12,
|
|
505
|
+
"mi_to_ft": 5280,
|
|
506
|
+
"ft_to_mi": 1 / 5280,
|
|
507
|
+
"rad_to_deg": 180 / 3.141592653589793,
|
|
508
|
+
"deg_to_rad": 3.141592653589793 / 180,
|
|
509
|
+
"c_to_f": lambda c: (c * 9 / 5) + 32,
|
|
510
|
+
"f_to_c": lambda f: (f - 32) * 5 / 9,
|
|
511
|
+
"k_to_c": lambda k: k - 273.15,
|
|
512
|
+
"c_to_k": lambda c: c + 273.15,
|
|
513
|
+
"f_to_k": lambda f: (f - 32) * 5 / 9 + 273.15,
|
|
514
|
+
"k_to_f": lambda k: (k - 273.15) * 9 / 5 + 32,
|
|
515
|
+
"kms_to_mph": 0.621371,
|
|
516
|
+
"mph_to_kms": 1 / 0.621371,
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
key = f"{self.from_unit}_to_{self.to_unit}"
|
|
520
|
+
if key not in conversion_factors:
|
|
521
|
+
raise ValueError("Conversion not supported.")
|
|
522
|
+
|
|
523
|
+
return self.value * conversion_factors[key]
|
|
524
|
+
class prime_checker:
|
|
525
|
+
def __init__(self, n):
|
|
526
|
+
self.n = n
|
|
527
|
+
|
|
528
|
+
def is_prime(self):
|
|
529
|
+
if self.n <= 1:
|
|
530
|
+
return False
|
|
531
|
+
for i in range(2, int(self.n ** 0.5) + 1):
|
|
532
|
+
if self.n % i == 0:
|
|
533
|
+
return False
|
|
534
|
+
return True
|
|
535
|
+
class prime_generator:
|
|
536
|
+
def __init__(self, limit):
|
|
537
|
+
self.limit = limit
|
|
538
|
+
|
|
539
|
+
def generate_primes(self):
|
|
540
|
+
primes = []
|
|
541
|
+
for num in range(2, self.limit + 1):
|
|
542
|
+
is_prime = True
|
|
543
|
+
for i in range(2, int(num ** 0.5) + 1):
|
|
544
|
+
if num % i == 0:
|
|
545
|
+
is_prime = False
|
|
546
|
+
break
|
|
547
|
+
if is_prime:
|
|
548
|
+
primes.append(num)
|
|
549
|
+
return primes
|
|
550
|
+
class prime_factorization:
|
|
551
|
+
def __init__(self, n):
|
|
552
|
+
self.n = n
|
|
553
|
+
|
|
554
|
+
def factorize(self):
|
|
555
|
+
factors = []
|
|
556
|
+
num = self.n
|
|
557
|
+
for i in range(2, int(num ** 0.5) + 1):
|
|
558
|
+
while num % i == 0:
|
|
559
|
+
factors.append(i)
|
|
560
|
+
num //= i
|
|
561
|
+
if num > 1:
|
|
562
|
+
factors.append(num)
|
|
563
|
+
return factors
|
|
564
|
+
class identites:
|
|
565
|
+
def __init__(self):
|
|
566
|
+
self.identities = {
|
|
567
|
+
"pythagorean": "a^2 + b^2 = c^2",
|
|
568
|
+
"trig": "sin^2(x) + cos^2(x) = 1",
|
|
569
|
+
"logarithmic": "log_b(xy) = log_b(x) + log_b(y)",
|
|
570
|
+
"exponential": "e^(x+y) = e^x * e^y",
|
|
571
|
+
"binomial": "(a+b)^n = sum(k=0 to n) C(n,k) * a^(n-k) * b^k"
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
def get_identity(self, name):
|
|
575
|
+
if name in self.identities:
|
|
576
|
+
return self.identities[name]
|
|
577
|
+
else:
|
|
578
|
+
raise ValueError("Unknown identity name.")
|
|
579
|
+
class pythagoras_theory:
|
|
580
|
+
def __init__(self, a=None, b=None, c=None):
|
|
581
|
+
self.a = a
|
|
582
|
+
self.b = b
|
|
583
|
+
self.c = c
|
|
584
|
+
|
|
585
|
+
def calculate_missing_side(self):
|
|
586
|
+
if self.c is None:
|
|
587
|
+
if self.a is not None and self.b is not None:
|
|
588
|
+
return (self.a ** 2 + self.b ** 2) ** 0.5
|
|
589
|
+
else:
|
|
590
|
+
raise ValueError("Insufficient information to calculate hypotenuse.")
|
|
591
|
+
elif self.a is None:
|
|
592
|
+
if self.c is not None and self.b is not None:
|
|
593
|
+
return (self.c ** 2 - self.b ** 2) ** 0.5
|
|
594
|
+
else:
|
|
595
|
+
raise ValueError("Insufficient information to calculate side a.")
|
|
596
|
+
elif self.b is None:
|
|
597
|
+
if self.c is not None and self.a is not None:
|
|
598
|
+
return (self.c ** 2 - self.a ** 2) ** 0.5
|
|
599
|
+
else:
|
|
600
|
+
raise ValueError("Insufficient information to calculate side b.")
|
|
601
|
+
else:
|
|
602
|
+
raise ValueError("All sides are already provided.")
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hypermath-Kavyansh-Arya
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A custom math module for factorials, roots, and advanced operations.
|
|
5
|
+
Author: Kavyansh N Arya
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
It is a custom python module to implement advance mathematical calculation and have different constants like pi, Euler number, golden ratio and more
|
|
13
|
+
NOTICE:
|
|
14
|
+
It requires at least Python 3.0 otherwise it will not work or not even install.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
HyperMath.py,sha256=fxeosrC47zZT023DtkYFeIJQ-FNpznd1jvIApWb-0v8,18399
|
|
2
|
+
hypermath_kavyansh_arya-0.2.0.dist-info/METADATA,sha256=xnpkQmdUQQi1XVypcdCPjr3kK7QTHAaUDMJiLLubPjU,631
|
|
3
|
+
hypermath_kavyansh_arya-0.2.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
4
|
+
hypermath_kavyansh_arya-0.2.0.dist-info/top_level.txt,sha256=bOavEwrIQ7y0eP_Vz1iSZuHeLoAuATdZB3yj8G6gnbg,10
|
|
5
|
+
hypermath_kavyansh_arya-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
HyperMath
|