math4u 0.1.2__tar.gz → 0.2.0__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.
- math4u-0.2.0/LICENSE +21 -0
- math4u-0.2.0/PKG-INFO +97 -0
- math4u-0.2.0/README.md +68 -0
- math4u-0.2.0/pyproject.toml +50 -0
- math4u-0.2.0/src/math4u/__init__.py +133 -0
- math4u-0.2.0/src/math4u/data_structures.py +36 -0
- math4u-0.2.0/src/math4u/exceptions.py +42 -0
- {math4u-0.1.2/src/math4u_package → math4u-0.2.0/src/math4u}/linear_algebra.py +7 -0
- math4u-0.2.0/src/math4u/numerical.py +33 -0
- math4u-0.2.0/src/math4u/oop.py +54 -0
- math4u-0.2.0/src/math4u/recursion.py +61 -0
- math4u-0.2.0/src/math4u/scipy_tools.py +18 -0
- math4u-0.2.0/src/math4u/string_processing.py +28 -0
- math4u-0.2.0/visualization.py +34 -0
- math4u-0.1.2/LICENSE +0 -0
- math4u-0.1.2/PKG-INFO +0 -25
- math4u-0.1.2/README.md +0 -16
- math4u-0.1.2/pyproject.toml +0 -13
- math4u-0.1.2/setup.cfg +0 -4
- math4u-0.1.2/src/math4u.egg-info/PKG-INFO +0 -25
- math4u-0.1.2/src/math4u.egg-info/SOURCES.txt +0 -10
- math4u-0.1.2/src/math4u.egg-info/dependency_links.txt +0 -1
- math4u-0.1.2/src/math4u.egg-info/top_level.txt +0 -1
- math4u-0.1.2/src/math4u_package/__init__.py +0 -0
- {math4u-0.1.2/src/math4u_package → math4u-0.2.0/src/math4u}/calculus.py +0 -0
math4u-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 [ชื่อของคุณ หรือ ชื่อองค์กร]
|
|
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 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.
|
math4u-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: math4u
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Python Package สำหรับการคำนวณและเครื่องมือทางคณิตศาสตร์
|
|
5
|
+
Project-URL: Homepage, https://github.com/username/my_package
|
|
6
|
+
Project-URL: Documentation, https://github.com/username/my_package#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/username/my_package.git
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/username/my_package/issues
|
|
9
|
+
Author-email: Bunyasak Rakjing <boonyasuk1213@gmail.com>
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: calculus,linear-algebra,mathematics,numpy,scipy,sympy
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Requires-Dist: matplotlib
|
|
24
|
+
Requires-Dist: networkx
|
|
25
|
+
Requires-Dist: numpy
|
|
26
|
+
Requires-Dist: scipy
|
|
27
|
+
Requires-Dist: sympy
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# math4u
|
|
31
|
+
|
|
32
|
+
Python Package สำหรับการคำนวณ Calculus และ Linear Algebra
|
|
33
|
+
|
|
34
|
+
## การใช้งาน
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import math4u
|
|
38
|
+
|
|
39
|
+
# =========================
|
|
40
|
+
# Calculus
|
|
41
|
+
# =========================
|
|
42
|
+
|
|
43
|
+
# 1. Derivative
|
|
44
|
+
print(math4u.derivative("x**3 + 2*x"))
|
|
45
|
+
# 3*x**2 + 2
|
|
46
|
+
|
|
47
|
+
# 2. Second Derivative
|
|
48
|
+
print(math4u.second_derivative("x**3 + 2*x"))
|
|
49
|
+
# 6*x
|
|
50
|
+
|
|
51
|
+
# 3. Indefinite Integral
|
|
52
|
+
print(math4u.integrate("x**2 + 2*x"))
|
|
53
|
+
# x**3/3 + x**2
|
|
54
|
+
|
|
55
|
+
# 4. Definite Integral
|
|
56
|
+
print(math4u.definite_integral("x**2", 0, 2))
|
|
57
|
+
# 8/3
|
|
58
|
+
|
|
59
|
+
# 5. Limit
|
|
60
|
+
print(math4u.limit("sin(x)/x", point=0))
|
|
61
|
+
# 1
|
|
62
|
+
|
|
63
|
+
# 6. Taylor Series
|
|
64
|
+
print(math4u.taylor_series("exp(x)", point=0, order=5))
|
|
65
|
+
# x**4/24 + x**3/6 + x**2/2 + x + 1
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# =========================
|
|
69
|
+
# Linear Algebra
|
|
70
|
+
# =========================
|
|
71
|
+
|
|
72
|
+
A = [[1, 2], [3, 4]]
|
|
73
|
+
B = [[5, 6], [7, 8]]
|
|
74
|
+
|
|
75
|
+
# 1. Matrix Addition
|
|
76
|
+
print(math4u.matrix_add(A, B))
|
|
77
|
+
# Matrix([[6, 8], [10, 12]])
|
|
78
|
+
|
|
79
|
+
# 2. Matrix Multiplication
|
|
80
|
+
print(math4u.matrix_multiply(A, B))
|
|
81
|
+
# Matrix([[19, 22], [43, 50]])
|
|
82
|
+
|
|
83
|
+
# 3. Determinant
|
|
84
|
+
print(math4u.determinant(A))
|
|
85
|
+
# -2
|
|
86
|
+
|
|
87
|
+
# 4. Inverse Matrix
|
|
88
|
+
print(math4u.inverse_matrix(A))
|
|
89
|
+
# Matrix([[-2, 1], [3/2, -1/2]])
|
|
90
|
+
|
|
91
|
+
# 5. Transpose
|
|
92
|
+
print(math4u.transpose(A))
|
|
93
|
+
# Matrix([[1, 3], [2, 4]])
|
|
94
|
+
|
|
95
|
+
# 6. Solve Linear System
|
|
96
|
+
print(math4u.solve_linear_system([[2, 1], [1, -1]], [5, 1]))
|
|
97
|
+
# (2, 1)
|
math4u-0.2.0/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# math4u
|
|
2
|
+
|
|
3
|
+
Python Package สำหรับการคำนวณ Calculus และ Linear Algebra
|
|
4
|
+
|
|
5
|
+
## การใช้งาน
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
import math4u
|
|
9
|
+
|
|
10
|
+
# =========================
|
|
11
|
+
# Calculus
|
|
12
|
+
# =========================
|
|
13
|
+
|
|
14
|
+
# 1. Derivative
|
|
15
|
+
print(math4u.derivative("x**3 + 2*x"))
|
|
16
|
+
# 3*x**2 + 2
|
|
17
|
+
|
|
18
|
+
# 2. Second Derivative
|
|
19
|
+
print(math4u.second_derivative("x**3 + 2*x"))
|
|
20
|
+
# 6*x
|
|
21
|
+
|
|
22
|
+
# 3. Indefinite Integral
|
|
23
|
+
print(math4u.integrate("x**2 + 2*x"))
|
|
24
|
+
# x**3/3 + x**2
|
|
25
|
+
|
|
26
|
+
# 4. Definite Integral
|
|
27
|
+
print(math4u.definite_integral("x**2", 0, 2))
|
|
28
|
+
# 8/3
|
|
29
|
+
|
|
30
|
+
# 5. Limit
|
|
31
|
+
print(math4u.limit("sin(x)/x", point=0))
|
|
32
|
+
# 1
|
|
33
|
+
|
|
34
|
+
# 6. Taylor Series
|
|
35
|
+
print(math4u.taylor_series("exp(x)", point=0, order=5))
|
|
36
|
+
# x**4/24 + x**3/6 + x**2/2 + x + 1
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# =========================
|
|
40
|
+
# Linear Algebra
|
|
41
|
+
# =========================
|
|
42
|
+
|
|
43
|
+
A = [[1, 2], [3, 4]]
|
|
44
|
+
B = [[5, 6], [7, 8]]
|
|
45
|
+
|
|
46
|
+
# 1. Matrix Addition
|
|
47
|
+
print(math4u.matrix_add(A, B))
|
|
48
|
+
# Matrix([[6, 8], [10, 12]])
|
|
49
|
+
|
|
50
|
+
# 2. Matrix Multiplication
|
|
51
|
+
print(math4u.matrix_multiply(A, B))
|
|
52
|
+
# Matrix([[19, 22], [43, 50]])
|
|
53
|
+
|
|
54
|
+
# 3. Determinant
|
|
55
|
+
print(math4u.determinant(A))
|
|
56
|
+
# -2
|
|
57
|
+
|
|
58
|
+
# 4. Inverse Matrix
|
|
59
|
+
print(math4u.inverse_matrix(A))
|
|
60
|
+
# Matrix([[-2, 1], [3/2, -1/2]])
|
|
61
|
+
|
|
62
|
+
# 5. Transpose
|
|
63
|
+
print(math4u.transpose(A))
|
|
64
|
+
# Matrix([[1, 3], [2, 4]])
|
|
65
|
+
|
|
66
|
+
# 6. Solve Linear System
|
|
67
|
+
print(math4u.solve_linear_system([[2, 1], [1, -1]], [5, 1]))
|
|
68
|
+
# (2, 1)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "math4u"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Python Package สำหรับการคำนวณและเครื่องมือทางคณิตศาสตร์"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Bunyasak Rakjing", email = "boonyasuk1213@gmail.com" }
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
keywords = [
|
|
18
|
+
"mathematics",
|
|
19
|
+
"calculus",
|
|
20
|
+
"linear-algebra",
|
|
21
|
+
"numpy",
|
|
22
|
+
"scipy",
|
|
23
|
+
"sympy",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Development Status :: 3 - Alpha",
|
|
28
|
+
"Intended Audience :: Developers",
|
|
29
|
+
"License :: OSI Approved :: MIT License",
|
|
30
|
+
"Programming Language :: Python :: 3",
|
|
31
|
+
"Programming Language :: Python :: 3.8",
|
|
32
|
+
"Programming Language :: Python :: 3.9",
|
|
33
|
+
"Programming Language :: Python :: 3.10",
|
|
34
|
+
"Programming Language :: Python :: 3.11",
|
|
35
|
+
"Programming Language :: Python :: 3.12",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
dependencies = [
|
|
39
|
+
"sympy",
|
|
40
|
+
"numpy",
|
|
41
|
+
"scipy",
|
|
42
|
+
"matplotlib",
|
|
43
|
+
"networkx",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.urls]
|
|
47
|
+
Homepage = "https://github.com/username/my_package"
|
|
48
|
+
Documentation = "https://github.com/username/my_package#readme"
|
|
49
|
+
Repository = "https://github.com/username/my_package.git"
|
|
50
|
+
"Bug Tracker" = "https://github.com/username/my_package/issues"
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""
|
|
2
|
+
math4u - Calculus, Linear Algebra and Mathematical Tools
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .calculus import (
|
|
6
|
+
derivative,
|
|
7
|
+
second_derivative,
|
|
8
|
+
integrate,
|
|
9
|
+
definite_integral,
|
|
10
|
+
limit,
|
|
11
|
+
taylor_series,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from .linear_algebra import (
|
|
15
|
+
matrix_add,
|
|
16
|
+
matrix_multiply,
|
|
17
|
+
determinant,
|
|
18
|
+
inverse_matrix,
|
|
19
|
+
transpose,
|
|
20
|
+
solve_linear_system,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
from .string_processing import (
|
|
24
|
+
reverse_string,
|
|
25
|
+
count_words,
|
|
26
|
+
count_characters,
|
|
27
|
+
to_uppercase,
|
|
28
|
+
to_lowercase,
|
|
29
|
+
remove_spaces,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
from .data_structures import (
|
|
33
|
+
list_operations,
|
|
34
|
+
tuple_operations,
|
|
35
|
+
dictionary_keys,
|
|
36
|
+
dictionary_values,
|
|
37
|
+
set_union,
|
|
38
|
+
set_intersection,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
from .recursion import (
|
|
42
|
+
factorial,
|
|
43
|
+
fibonacci,
|
|
44
|
+
fibonacci_memo,
|
|
45
|
+
power_recursive,
|
|
46
|
+
sum_recursive,
|
|
47
|
+
gcd_recursive,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
from .oop import (
|
|
51
|
+
Calculator,
|
|
52
|
+
ScientificCalculator,
|
|
53
|
+
AdvancedCalculator,
|
|
54
|
+
SpecialCalculator,
|
|
55
|
+
BasicCalculator,
|
|
56
|
+
HybridCalculator,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
from .exceptions import (
|
|
60
|
+
safe_divide,
|
|
61
|
+
safe_square_root,
|
|
62
|
+
validate_number,
|
|
63
|
+
get_list_item,
|
|
64
|
+
get_dictionary_value,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
from .numerical import (
|
|
68
|
+
create_array,
|
|
69
|
+
array_mean,
|
|
70
|
+
array_sum,
|
|
71
|
+
matrix_multiply_numpy,
|
|
72
|
+
array_statistics,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
from .scipy_tools import (
|
|
76
|
+
symbolic_simplify,
|
|
77
|
+
symbolic_expand,
|
|
78
|
+
numerical_integral,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
__version__ = "0.2.0"
|
|
82
|
+
|
|
83
|
+
__all__ = [
|
|
84
|
+
"derivative",
|
|
85
|
+
"second_derivative",
|
|
86
|
+
"integrate",
|
|
87
|
+
"definite_integral",
|
|
88
|
+
"limit",
|
|
89
|
+
"taylor_series",
|
|
90
|
+
"matrix_add",
|
|
91
|
+
"matrix_multiply",
|
|
92
|
+
"determinant",
|
|
93
|
+
"inverse_matrix",
|
|
94
|
+
"transpose",
|
|
95
|
+
"solve_linear_system",
|
|
96
|
+
"reverse_string",
|
|
97
|
+
"count_words",
|
|
98
|
+
"count_characters",
|
|
99
|
+
"to_uppercase",
|
|
100
|
+
"to_lowercase",
|
|
101
|
+
"remove_spaces",
|
|
102
|
+
"list_operations",
|
|
103
|
+
"tuple_operations",
|
|
104
|
+
"dictionary_keys",
|
|
105
|
+
"dictionary_values",
|
|
106
|
+
"set_union",
|
|
107
|
+
"set_intersection",
|
|
108
|
+
"factorial",
|
|
109
|
+
"fibonacci",
|
|
110
|
+
"fibonacci_memo",
|
|
111
|
+
"power_recursive",
|
|
112
|
+
"sum_recursive",
|
|
113
|
+
"gcd_recursive",
|
|
114
|
+
"Calculator",
|
|
115
|
+
"ScientificCalculator",
|
|
116
|
+
"AdvancedCalculator",
|
|
117
|
+
"SpecialCalculator",
|
|
118
|
+
"BasicCalculator",
|
|
119
|
+
"HybridCalculator",
|
|
120
|
+
"safe_divide",
|
|
121
|
+
"safe_square_root",
|
|
122
|
+
"validate_number",
|
|
123
|
+
"get_list_item",
|
|
124
|
+
"get_dictionary_value",
|
|
125
|
+
"create_array",
|
|
126
|
+
"array_mean",
|
|
127
|
+
"array_sum",
|
|
128
|
+
"matrix_multiply_numpy",
|
|
129
|
+
"array_statistics",
|
|
130
|
+
"symbolic_simplify",
|
|
131
|
+
"symbolic_expand",
|
|
132
|
+
"numerical_integral",
|
|
133
|
+
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
def list_operations(items):
|
|
2
|
+
"""Return basic operations for a list."""
|
|
3
|
+
return {
|
|
4
|
+
"length": len(items),
|
|
5
|
+
"first": items[0] if items else None,
|
|
6
|
+
"last": items[-1] if items else None
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def tuple_operations(items):
|
|
11
|
+
"""Return basic operations for a tuple."""
|
|
12
|
+
return {
|
|
13
|
+
"length": len(items),
|
|
14
|
+
"first": items[0] if items else None,
|
|
15
|
+
"last": items[-1] if items else None
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def dictionary_keys(data):
|
|
20
|
+
"""Return all keys from a dictionary."""
|
|
21
|
+
return list(data.keys())
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def dictionary_values(data):
|
|
25
|
+
"""Return all values from a dictionary."""
|
|
26
|
+
return list(data.values())
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def set_union(set_a, set_b):
|
|
30
|
+
"""Return the union of two sets."""
|
|
31
|
+
return set_a | set_b
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def set_intersection(set_a, set_b):
|
|
35
|
+
"""Return the intersection of two sets."""
|
|
36
|
+
return set_a & set_b
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
def safe_divide(a, b):
|
|
2
|
+
"""Divide two numbers safely."""
|
|
3
|
+
try:
|
|
4
|
+
return a / b
|
|
5
|
+
except ZeroDivisionError:
|
|
6
|
+
return None
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def safe_square_root(value):
|
|
10
|
+
"""Calculate square root with exception handling."""
|
|
11
|
+
import math
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
if value < 0:
|
|
15
|
+
raise ValueError("Value must be non-negative")
|
|
16
|
+
return math.sqrt(value)
|
|
17
|
+
except ValueError:
|
|
18
|
+
return None
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def validate_number(value):
|
|
22
|
+
"""Validate that a value is a number."""
|
|
23
|
+
try:
|
|
24
|
+
return float(value)
|
|
25
|
+
except (TypeError, ValueError):
|
|
26
|
+
return None
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_list_item(items, index):
|
|
30
|
+
"""Get an item from a list safely."""
|
|
31
|
+
try:
|
|
32
|
+
return items[index]
|
|
33
|
+
except IndexError:
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def get_dictionary_value(data, key):
|
|
38
|
+
"""Get a dictionary value safely."""
|
|
39
|
+
try:
|
|
40
|
+
return data[key]
|
|
41
|
+
except KeyError:
|
|
42
|
+
return None
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
import sympy as sp
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
def _matrix(matrix):
|
|
4
5
|
return sp.Matrix(matrix)
|
|
5
6
|
|
|
7
|
+
|
|
6
8
|
def matrix_add(A, B):
|
|
7
9
|
return _matrix(A) + _matrix(B)
|
|
8
10
|
|
|
11
|
+
|
|
9
12
|
def matrix_multiply(A, B):
|
|
10
13
|
return _matrix(A) * _matrix(B)
|
|
11
14
|
|
|
15
|
+
|
|
12
16
|
def determinant(A):
|
|
13
17
|
return _matrix(A).det()
|
|
14
18
|
|
|
19
|
+
|
|
15
20
|
def inverse_matrix(A):
|
|
16
21
|
return _matrix(A).inv()
|
|
17
22
|
|
|
23
|
+
|
|
18
24
|
def transpose(A):
|
|
19
25
|
return _matrix(A).T
|
|
20
26
|
|
|
27
|
+
|
|
21
28
|
def solve_linear_system(A, b):
|
|
22
29
|
A = _matrix(A)
|
|
23
30
|
b = sp.Matrix(b)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def create_array(data):
|
|
5
|
+
"""Create a NumPy array."""
|
|
6
|
+
return np.array(data)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def array_mean(data):
|
|
10
|
+
"""Calculate the mean of an array."""
|
|
11
|
+
return np.mean(data)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def array_sum(data):
|
|
15
|
+
"""Calculate the sum of an array."""
|
|
16
|
+
return np.sum(data)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def matrix_multiply_numpy(A, B):
|
|
20
|
+
"""Multiply two matrices using NumPy."""
|
|
21
|
+
return np.matmul(A, B)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def array_statistics(data):
|
|
25
|
+
"""Return basic statistics of an array."""
|
|
26
|
+
arr = np.array(data)
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
"mean": np.mean(arr),
|
|
30
|
+
"max": np.max(arr),
|
|
31
|
+
"min": np.min(arr),
|
|
32
|
+
"std": np.std(arr)
|
|
33
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
class Calculator:
|
|
2
|
+
"""Basic calculator class."""
|
|
3
|
+
|
|
4
|
+
def __init__(self, value=0):
|
|
5
|
+
self.value = value
|
|
6
|
+
|
|
7
|
+
def add(self, number):
|
|
8
|
+
self.value += number
|
|
9
|
+
return self.value
|
|
10
|
+
|
|
11
|
+
def __str__(self):
|
|
12
|
+
return f"Calculator(value={self.value})"
|
|
13
|
+
|
|
14
|
+
def __repr__(self):
|
|
15
|
+
return f"Calculator({self.value})"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ScientificCalculator(Calculator):
|
|
19
|
+
"""Single inheritance from Calculator."""
|
|
20
|
+
|
|
21
|
+
def square(self):
|
|
22
|
+
return self.value ** 2
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class MathMixin:
|
|
26
|
+
"""Mixin class for mathematical operations."""
|
|
27
|
+
|
|
28
|
+
def cube(self):
|
|
29
|
+
return self.value ** 3
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class AdvancedCalculator(Calculator, MathMixin):
|
|
33
|
+
"""Multiple inheritance."""
|
|
34
|
+
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class SpecialCalculator(AdvancedCalculator):
|
|
39
|
+
"""Multilevel inheritance."""
|
|
40
|
+
|
|
41
|
+
def fourth_power(self):
|
|
42
|
+
return self.value ** 4
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class BasicCalculator(Calculator):
|
|
46
|
+
"""Hierarchical inheritance."""
|
|
47
|
+
|
|
48
|
+
def double(self):
|
|
49
|
+
return self.value * 2
|
|
50
|
+
class HybridCalculator(SpecialCalculator, BasicCalculator):
|
|
51
|
+
"""Hybrid inheritance combining multilevel and hierarchical inheritance."""
|
|
52
|
+
|
|
53
|
+
def fifth_power(self):
|
|
54
|
+
return self.value ** 5
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
def factorial(n):
|
|
2
|
+
"""Calculate factorial using recursion."""
|
|
3
|
+
if n < 0:
|
|
4
|
+
raise ValueError("n must be non-negative")
|
|
5
|
+
if n == 0 or n == 1:
|
|
6
|
+
return 1
|
|
7
|
+
return n * factorial(n - 1)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def fibonacci(n):
|
|
11
|
+
"""Calculate Fibonacci number using recursion."""
|
|
12
|
+
if n < 0:
|
|
13
|
+
raise ValueError("n must be non-negative")
|
|
14
|
+
if n <= 1:
|
|
15
|
+
return n
|
|
16
|
+
return fibonacci(n - 1) + fibonacci(n - 2)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def fibonacci_memo(n, memo=None):
|
|
20
|
+
"""Calculate Fibonacci number using recursion with memoization."""
|
|
21
|
+
if n < 0:
|
|
22
|
+
raise ValueError("n must be non-negative")
|
|
23
|
+
|
|
24
|
+
if memo is None:
|
|
25
|
+
memo = {}
|
|
26
|
+
|
|
27
|
+
if n in memo:
|
|
28
|
+
return memo[n]
|
|
29
|
+
|
|
30
|
+
if n <= 1:
|
|
31
|
+
return n
|
|
32
|
+
|
|
33
|
+
memo[n] = fibonacci_memo(n - 1, memo) + fibonacci_memo(n - 2, memo)
|
|
34
|
+
return memo[n]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def power_recursive(base, exponent):
|
|
38
|
+
"""Calculate power using recursion."""
|
|
39
|
+
if exponent < 0:
|
|
40
|
+
return 1 / power_recursive(base, -exponent)
|
|
41
|
+
|
|
42
|
+
if exponent == 0:
|
|
43
|
+
return 1
|
|
44
|
+
|
|
45
|
+
return base * power_recursive(base, exponent - 1)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def sum_recursive(numbers):
|
|
49
|
+
"""Calculate the sum of a list using recursion."""
|
|
50
|
+
if not numbers:
|
|
51
|
+
return 0
|
|
52
|
+
|
|
53
|
+
return numbers[0] + sum_recursive(numbers[1:])
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def gcd_recursive(a, b):
|
|
57
|
+
"""Calculate the greatest common divisor using recursion."""
|
|
58
|
+
if b == 0:
|
|
59
|
+
return abs(a)
|
|
60
|
+
|
|
61
|
+
return gcd_recursive(b, a % b)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import sympy as sp
|
|
2
|
+
from scipy import integrate
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def symbolic_simplify(expr):
|
|
6
|
+
"""Simplify a mathematical expression using SymPy."""
|
|
7
|
+
return sp.simplify(expr)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def symbolic_expand(expr):
|
|
11
|
+
"""Expand a mathematical expression using SymPy."""
|
|
12
|
+
return sp.expand(expr)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def numerical_integral(function, lower, upper):
|
|
16
|
+
"""Calculate a numerical integral using SciPy."""
|
|
17
|
+
result, error = integrate.quad(function, lower, upper)
|
|
18
|
+
return result
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
def reverse_string(text):
|
|
2
|
+
"""Reverse a string."""
|
|
3
|
+
return text[::-1]
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def count_words(text):
|
|
7
|
+
"""Count the number of words in a string."""
|
|
8
|
+
return len(text.split())
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def count_characters(text):
|
|
12
|
+
"""Count the number of characters in a string."""
|
|
13
|
+
return len(text)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def to_uppercase(text):
|
|
17
|
+
"""Convert text to uppercase."""
|
|
18
|
+
return text.upper()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def to_lowercase(text):
|
|
22
|
+
"""Convert text to lowercase."""
|
|
23
|
+
return text.lower()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def remove_spaces(text):
|
|
27
|
+
"""Remove all spaces from a string."""
|
|
28
|
+
return text.replace(" ", "")
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import matplotlib.pyplot as plt
|
|
2
|
+
import networkx as nx
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def plot_function(x, y):
|
|
6
|
+
"""Plot a function using Matplotlib."""
|
|
7
|
+
plt.plot(x, y)
|
|
8
|
+
plt.xlabel("x")
|
|
9
|
+
plt.ylabel("y")
|
|
10
|
+
plt.title("Function Plot")
|
|
11
|
+
plt.show()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def plot_bar(categories, values):
|
|
15
|
+
"""Create a bar chart using Matplotlib."""
|
|
16
|
+
plt.bar(categories, values)
|
|
17
|
+
plt.xlabel("Category")
|
|
18
|
+
plt.ylabel("Value")
|
|
19
|
+
plt.title("Bar Chart")
|
|
20
|
+
plt.show()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def create_graph(edges):
|
|
24
|
+
"""Create a graph using NetworkX."""
|
|
25
|
+
graph = nx.Graph()
|
|
26
|
+
graph.add_edges_from(edges)
|
|
27
|
+
return graph
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def draw_graph(edges):
|
|
31
|
+
"""Draw a graph using NetworkX and Matplotlib."""
|
|
32
|
+
graph = create_graph(edges)
|
|
33
|
+
nx.draw(graph, with_labels=True)
|
|
34
|
+
plt.show()
|
math4u-0.1.2/LICENSE
DELETED
|
File without changes
|
math4u-0.1.2/PKG-INFO
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: math4u
|
|
3
|
-
Version: 0.1.2
|
|
4
|
-
Summary: A mathematics package for calculus and linear algebra
|
|
5
|
-
Requires-Python: >=3.8
|
|
6
|
-
Description-Content-Type: text/markdown
|
|
7
|
-
License-File: LICENSE
|
|
8
|
-
Dynamic: license-file
|
|
9
|
-
|
|
10
|
-
# math4u
|
|
11
|
-
|
|
12
|
-
A mathematics package for calculus and linear algebra.
|
|
13
|
-
|
|
14
|
-
## Features
|
|
15
|
-
|
|
16
|
-
- Calculus functions
|
|
17
|
-
- Linear algebra functions
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
pip install math4u
|
|
23
|
-
|
|
24
|
-
## Usage
|
|
25
|
-
import math4u
|
math4u-0.1.2/README.md
DELETED
math4u-0.1.2/pyproject.toml
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=61"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "math4u"
|
|
7
|
-
version = "0.1.2"
|
|
8
|
-
description = "A mathematics package for calculus and linear algebra"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.8"
|
|
11
|
-
|
|
12
|
-
[tool.setuptools.packages.find]
|
|
13
|
-
where = ["src"]
|
math4u-0.1.2/setup.cfg
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: math4u
|
|
3
|
-
Version: 0.1.2
|
|
4
|
-
Summary: A mathematics package for calculus and linear algebra
|
|
5
|
-
Requires-Python: >=3.8
|
|
6
|
-
Description-Content-Type: text/markdown
|
|
7
|
-
License-File: LICENSE
|
|
8
|
-
Dynamic: license-file
|
|
9
|
-
|
|
10
|
-
# math4u
|
|
11
|
-
|
|
12
|
-
A mathematics package for calculus and linear algebra.
|
|
13
|
-
|
|
14
|
-
## Features
|
|
15
|
-
|
|
16
|
-
- Calculus functions
|
|
17
|
-
- Linear algebra functions
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
pip install math4u
|
|
23
|
-
|
|
24
|
-
## Usage
|
|
25
|
-
import math4u
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
LICENSE
|
|
2
|
-
README.md
|
|
3
|
-
pyproject.toml
|
|
4
|
-
src/math4u.egg-info/PKG-INFO
|
|
5
|
-
src/math4u.egg-info/SOURCES.txt
|
|
6
|
-
src/math4u.egg-info/dependency_links.txt
|
|
7
|
-
src/math4u.egg-info/top_level.txt
|
|
8
|
-
src/math4u_package/__init__.py
|
|
9
|
-
src/math4u_package/calculus.py
|
|
10
|
-
src/math4u_package/linear_algebra.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
math4u_package
|
|
File without changes
|
|
File without changes
|