mathai 2.5.1__tar.gz → 2.5.3__tar.gz
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.
- {mathai-2.5.1 → mathai-2.5.3}/PKG-INFO +3 -1
- {mathai-2.5.1 → mathai-2.5.3}/mathai/__init__.py +2 -5
- {mathai-2.5.1 → mathai-2.5.3}/mathai/decision.py +1 -1
- mathai-2.5.3/mathai/factor.py +66 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/integrate.py +3 -5
- {mathai-2.5.1 → mathai-2.5.3}/mathai/linear.py +1 -1
- {mathai-2.5.1 → mathai-2.5.3}/mathai/logic.py +1 -1
- {mathai-2.5.1 → mathai-2.5.3}/mathai/ml.py +1 -1
- mathai-2.5.3/mathai/mldirect.py +1018 -0
- mathai-2.5.3/mathai/ode.py +302 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/pde.py +1 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/printeq.py +0 -1
- {mathai-2.5.1 → mathai-2.5.3}/mathai/trig.py +0 -1
- {mathai-2.5.1 → mathai-2.5.3}/mathai.egg-info/PKG-INFO +3 -1
- {mathai-2.5.1 → mathai-2.5.3}/mathai.egg-info/SOURCES.txt +2 -0
- mathai-2.5.3/mathai.egg-info/requires.txt +1 -0
- {mathai-2.5.1 → mathai-2.5.3}/setup.py +4 -1
- mathai-2.5.1/mathai/factor.py +0 -187
- mathai-2.5.1/mathai/ode.py +0 -296
- {mathai-2.5.1 → mathai-2.5.3}/README.md +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/apart.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/base.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/benchmark.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/diff.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/electronic.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/expand.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/formula_applier.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/formula_compiler.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/fraction.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/graphics.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/inverse.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/lambda_calculus.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/limit.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/matrix.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/mlscalar.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/ncert_data.txt +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/ncert_data_optimized.txt +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/parser.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/qm.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/simplify.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/square_root.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/statistics.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/test.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/tool.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai/univariate_inequality.py +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai.egg-info/dependency_links.txt +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/mathai.egg-info/top_level.txt +0 -0
- {mathai-2.5.1 → mathai-2.5.3}/setup.cfg +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mathai
|
|
3
|
-
Version: 2.5.
|
|
3
|
+
Version: 2.5.3
|
|
4
4
|
Summary: Mathematics solving Ai tailored to NCERT
|
|
5
5
|
Home-page: https://github.com/infinity390/mathai
|
|
6
6
|
Requires-Python: >=3.7
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: numpy
|
|
8
9
|
Dynamic: description
|
|
9
10
|
Dynamic: description-content-type
|
|
10
11
|
Dynamic: home-page
|
|
12
|
+
Dynamic: requires-dist
|
|
11
13
|
Dynamic: requires-python
|
|
12
14
|
Dynamic: summary
|
|
13
15
|
|
|
@@ -28,6 +28,7 @@ from .expand import expand
|
|
|
28
28
|
|
|
29
29
|
from .ml import NeuralNetwork, diff_matrix_matrix
|
|
30
30
|
from .mlscalar import NeuralNetworkScalar
|
|
31
|
+
from .mldirect import NeuralNetworkDirect
|
|
31
32
|
|
|
32
33
|
from .parser import parse, remove_extra_brackets
|
|
33
34
|
|
|
@@ -44,11 +45,7 @@ from .integrate import normalize as integration_basic
|
|
|
44
45
|
|
|
45
46
|
from .diff import diff, diff2
|
|
46
47
|
|
|
47
|
-
from .factor import
|
|
48
|
-
from .factor import factor2, take_common
|
|
49
|
-
from .factor import rationalize_sqrt as rationalize
|
|
50
|
-
from .factor import merge_sqrt
|
|
51
|
-
from .factor import factorconst as factor0
|
|
48
|
+
from .factor import factor0, factor1, factor2
|
|
52
49
|
|
|
53
50
|
from .fraction import fraction, fraction0
|
|
54
51
|
|
|
@@ -11,7 +11,7 @@ from .univariate_inequality import simple_wavycurvy, wavycurvy, prepare, absolut
|
|
|
11
11
|
from .fraction import fraction
|
|
12
12
|
from .expand import expand
|
|
13
13
|
from .logic import logic0, set_sub, truth_gen, solve_logically
|
|
14
|
-
from .factor import factor2,
|
|
14
|
+
from .factor import factor2, factor1, factor0
|
|
15
15
|
from .limit import limit1, limit5
|
|
16
16
|
from .linear import linear_solve
|
|
17
17
|
from .matrix import matrix_solve, matrix_formula
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
|
|
2
|
+
import math
|
|
3
|
+
|
|
4
|
+
from .base import * # tree_form, TreeNode, str_form, factor_generation, product, summation, partitions ...
|
|
5
|
+
from .simplify import simplify
|
|
6
|
+
from .expand import expand # noqa: F401
|
|
7
|
+
from .formula_compiler import formula_list_compiler
|
|
8
|
+
|
|
9
|
+
# Kept so that `from .factor import *` in other modules keeps working.
|
|
10
|
+
from .parser import parse # noqa: F401
|
|
11
|
+
from .simplify import convert_to_basic # noqa: F401
|
|
12
|
+
from .tool import poly # noqa: F401
|
|
13
|
+
from .fraction import fraction
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
factor2 = formula_list_compiler("poly(x,a,b,c) a*(x-(-b+sqrt(b^2-4*a*c))/(2*a))*(x-(-b-sqrt(b^2-4*a*c))/(2*a)) [] _ _ b^2-4*a*c _")
|
|
17
|
+
factor1_s = """x^2-y^2 (x+y)*(x-y) [] _ _ _ _
|
|
18
|
+
x^3-y^3 (x-y)*(x^2+x*y+y^2) [] _ _ _ _
|
|
19
|
+
x^3+y^3 (x+y)*(x^2-x*y+y^2) [] _ _ _ _
|
|
20
|
+
x*y+a*y+x+a (x+a)*(y+1) [[a,1]] _ _ _ _
|
|
21
|
+
a*b+a*c a*(b+c) [[b,1]] _ _ _ _
|
|
22
|
+
a*b*c+a*b*d a*b*(c+d) [] _ _ _ _
|
|
23
|
+
a*x+b*x (a+b)*x [] _ _ _ _
|
|
24
|
+
a*x+a*y a*(x+y) [] _ _ _ _
|
|
25
|
+
a*c+a*d+b*c+b*d (a+b)*(c+d) [] _ _ _ _
|
|
26
|
+
x^2+2*a*x+a^2 (x+a)^2 [] _ _ _ _
|
|
27
|
+
x^2-2*a*x+a^2 (x-a)^2 [] _ _ _ _
|
|
28
|
+
a*b*c+a*d a*(b*c+d) [] _ _ _ _"""
|
|
29
|
+
factor1 = formula_list_compiler(factor1_s)
|
|
30
|
+
|
|
31
|
+
def _coeff(term):
|
|
32
|
+
"""Integer coefficient of a term (1 if none)."""
|
|
33
|
+
for item in factor_generation(term):
|
|
34
|
+
if item.name.startswith("d_"):
|
|
35
|
+
try:
|
|
36
|
+
return int(item.name[2:])
|
|
37
|
+
except ValueError:
|
|
38
|
+
return 1
|
|
39
|
+
return 1
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _hcf(numbers):
|
|
43
|
+
"""gcd of the coefficients; negative only if every coefficient is negative."""
|
|
44
|
+
g = 0
|
|
45
|
+
for x in numbers:
|
|
46
|
+
g = math.gcd(g, x)
|
|
47
|
+
if g == 0:
|
|
48
|
+
return 1
|
|
49
|
+
if numbers and all(x < 0 for x in numbers):
|
|
50
|
+
return -g
|
|
51
|
+
return g
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _factorconst(eq):
|
|
55
|
+
if not eq.children:
|
|
56
|
+
return eq
|
|
57
|
+
if eq.name == "f_add":
|
|
58
|
+
n = _hcf([_coeff(child) for child in eq.children])
|
|
59
|
+
if n != 1:
|
|
60
|
+
const = tree_form("d_" + str(n))
|
|
61
|
+
return const * TreeNode(eq.name, [child / const for child in eq.children])
|
|
62
|
+
return TreeNode(eq.name, [_factorconst(child) for child in eq.children])
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def factor0(eq):
|
|
66
|
+
return simplify(_factorconst(eq))
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
from .factor import factor2
|
|
2
|
-
from .factor import factorconst as factor0
|
|
3
|
-
from .factor import factor as factor1
|
|
1
|
+
from .factor import factor2, factor1, factor0
|
|
4
2
|
from .parser import parse
|
|
5
3
|
import itertools
|
|
6
4
|
from .diff import diff
|
|
@@ -289,14 +287,14 @@ def byparts(eq):
|
|
|
289
287
|
return TreeNode("f_try", output)
|
|
290
288
|
eq = eq2
|
|
291
289
|
return TreeNode(eq.name, [byparts(child) for child in eq.children])
|
|
292
|
-
|
|
293
290
|
integrate_fraction_s = """integrate(1/sqrt(poly(x,a,b,c)),x) 1/sqrt(a)*log(abs(sqrt(a)*x+b/(2*sqrt(a))+sqrt((sqrt(a)*x+b/(2*sqrt(a)))^2+(4*a*c-b^2)/(4*a)))) [] x [a,b,c] [a,4*a*c-b^2] _ [[a,0],[b^2-4*a*c,0]]
|
|
294
291
|
integrate(1/sqrt(poly(x,a,b,c)),x) 1/sqrt(a)*log(abs(sqrt(a)*x+b/(2*sqrt(a))+sqrt((sqrt(a)*x+b/(2*sqrt(a)))^2-(b^2-4*a*c)/(4*a)))) [] x [a,b,c] [a,b^2-4*a*c] _ [[a,0],[4*a*c-b^2,0]]
|
|
295
292
|
integrate(1/sqrt(poly(x,a,b,c)),x) 1/sqrt(-a)*arcsin((sqrt(-a)*x-b/(2*sqrt(-a)))/sqrt((4*a*c-b^2)/(4*a))) [] x [a,b,c] [4*a*c-b^2] a [[a,0],[b^2-4*a*c,0]]
|
|
296
293
|
integrate(1/poly(x,a,b,c),x) 1/(sqrt(a)*sqrt((4*a*c-b^2)/(4*a)))*arctan((sqrt(a)*x+b/(2*sqrt(a)))/sqrt((4*a*c-b^2)/(4*a))) [] x [a,b,c] [a,4*a*c-b^2] _ [[a,0],[b^2-4*a*c,0]]
|
|
297
|
-
integrate(1/poly(x,a,b,c),x) -1/(sqrt(-a)*sqrt((
|
|
294
|
+
integrate(1/poly(x,a,b,c),x) -1/(sqrt(-a)*sqrt((4*a*c-b^2)/(-4*a)))*arctan((sqrt(-a)*x-b/(2*sqrt(-a)))/sqrt((4*a*c-b^2)/(-4*a))) [] x [a,b,c] [4*a*c-b^2] a [[a,0],[b^2-4*a*c,0]]
|
|
298
295
|
integrate(poly(x,p,q)/sqrt(poly(x,a,b,c)),x) (p/a)*sqrt(a*x^2+b*x+c)+(q-p*b/(2*a))*integrate(1/sqrt(a*x^2+b*x+c),x) [] x [p,q,a,b,c] _ _ _ [[a,0]]
|
|
299
296
|
integrate(poly(x,p,q)/poly(x,a,b,c),x) (p/(2*a))*log(abs(a*x^2+b*x+c))+(q-p*b/(2*a))*integrate(1/(a*x^2+b*x+c),x) [] x [p,q,a,b,c] _ _ _ [[a,0]]"""
|
|
297
|
+
|
|
300
298
|
integrate_fraction = formula_list_compiler(integrate_fraction_s)
|
|
301
299
|
|
|
302
300
|
def_integrate_formula_s = """integrate(abs(poly(x,a,b)),x,m,n) ((a*n+b)*abs(a*n+b)-(a*m+b)*abs(a*m+b))/(2*a) [] x [a,b] _ _
|
|
@@ -675,7 +675,7 @@ class NeuralNetwork:
|
|
|
675
675
|
A_list = A_list + flatten_list(item)
|
|
676
676
|
exec(s, env2)
|
|
677
677
|
return env2["fx"](A_list,flatten_list(given_x))
|
|
678
|
-
def train(self, train_x, train_y, learning_rate, epoch, batch_size=1):
|
|
678
|
+
def train(self, train_x, train_y, learning_rate=12, epoch=10000, batch_size=1):
|
|
679
679
|
global hadamard, zeros, transpose, matadd, sigmoid, identity, power, vec, diag, flatten,\
|
|
680
680
|
matmul, reshape, kronecker, commutation, broadcast, im2col, conv, col2im
|
|
681
681
|
print("gradients calculated")
|