math4u 0.2.0__tar.gz → 0.2.2__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.2/PKG-INFO +339 -0
- math4u-0.2.2/README.md +310 -0
- math4u-0.2.2/math4u-0.2.1.zip +0 -0
- {math4u-0.2.0 → math4u-0.2.2}/pyproject.toml +1 -1
- {math4u-0.2.0 → math4u-0.2.2}/src/math4u/__init__.py +25 -1
- math4u-0.2.0/PKG-INFO +0 -97
- math4u-0.2.0/README.md +0 -68
- {math4u-0.2.0 → math4u-0.2.2}/LICENSE +0 -0
- {math4u-0.2.0 → math4u-0.2.2}/src/math4u/calculus.py +0 -0
- {math4u-0.2.0 → math4u-0.2.2}/src/math4u/data_structures.py +0 -0
- {math4u-0.2.0 → math4u-0.2.2}/src/math4u/exceptions.py +0 -0
- {math4u-0.2.0 → math4u-0.2.2}/src/math4u/linear_algebra.py +0 -0
- {math4u-0.2.0 → math4u-0.2.2}/src/math4u/numerical.py +0 -0
- {math4u-0.2.0 → math4u-0.2.2}/src/math4u/oop.py +0 -0
- {math4u-0.2.0 → math4u-0.2.2}/src/math4u/recursion.py +0 -0
- {math4u-0.2.0 → math4u-0.2.2}/src/math4u/scipy_tools.py +0 -0
- {math4u-0.2.0 → math4u-0.2.2}/src/math4u/string_processing.py +0 -0
- {math4u-0.2.0 → math4u-0.2.2/src/math4u}/visualization.py +0 -0
math4u-0.2.2/PKG-INFO
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: math4u
|
|
3
|
+
Version: 0.2.2
|
|
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(
|
|
97
|
+
[[2, 1], [1, -1]],
|
|
98
|
+
[5, 1]
|
|
99
|
+
))
|
|
100
|
+
# (2, 1)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# =========================
|
|
104
|
+
# String Processing
|
|
105
|
+
# =========================
|
|
106
|
+
|
|
107
|
+
# 1. Reverse String
|
|
108
|
+
print(math4u.reverse_string("Hello"))
|
|
109
|
+
# olleH
|
|
110
|
+
|
|
111
|
+
# 2. Count Words
|
|
112
|
+
print(math4u.count_words("Hello Python World"))
|
|
113
|
+
# 3
|
|
114
|
+
|
|
115
|
+
# 3. Count Characters
|
|
116
|
+
print(math4u.count_characters("Hello"))
|
|
117
|
+
# 5
|
|
118
|
+
|
|
119
|
+
# 4. Uppercase
|
|
120
|
+
print(math4u.to_uppercase("hello"))
|
|
121
|
+
# HELLO
|
|
122
|
+
|
|
123
|
+
# 5. Lowercase
|
|
124
|
+
print(math4u.to_lowercase("HELLO"))
|
|
125
|
+
# hello
|
|
126
|
+
|
|
127
|
+
# 6. Remove Spaces
|
|
128
|
+
print(math4u.remove_spaces("Hello World"))
|
|
129
|
+
# HelloWorld
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# =========================
|
|
133
|
+
# Data Structures
|
|
134
|
+
# =========================
|
|
135
|
+
|
|
136
|
+
# List
|
|
137
|
+
print(math4u.list_operations([10, 20, 30]))
|
|
138
|
+
|
|
139
|
+
# Tuple
|
|
140
|
+
print(math4u.tuple_operations((1, 2, 3)))
|
|
141
|
+
|
|
142
|
+
# Dictionary Keys
|
|
143
|
+
print(math4u.dictionary_keys({
|
|
144
|
+
"a": 1,
|
|
145
|
+
"b": 2
|
|
146
|
+
}))
|
|
147
|
+
|
|
148
|
+
# Dictionary Values
|
|
149
|
+
print(math4u.dictionary_values({
|
|
150
|
+
"a": 1,
|
|
151
|
+
"b": 2
|
|
152
|
+
}))
|
|
153
|
+
|
|
154
|
+
# Set Union
|
|
155
|
+
print(math4u.set_union({1, 2}, {2, 3}))
|
|
156
|
+
|
|
157
|
+
# Set Intersection
|
|
158
|
+
print(math4u.set_intersection({1, 2}, {2, 3}))
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
# =========================
|
|
162
|
+
# Recursive Functions
|
|
163
|
+
# =========================
|
|
164
|
+
|
|
165
|
+
# Factorial
|
|
166
|
+
print(math4u.factorial(5))
|
|
167
|
+
# 120
|
|
168
|
+
|
|
169
|
+
# Fibonacci
|
|
170
|
+
print(math4u.fibonacci(6))
|
|
171
|
+
# 8
|
|
172
|
+
|
|
173
|
+
# Power
|
|
174
|
+
print(math4u.power_recursive(2, 5))
|
|
175
|
+
# 32
|
|
176
|
+
|
|
177
|
+
# Recursive Sum
|
|
178
|
+
print(math4u.sum_recursive([1, 2, 3, 4]))
|
|
179
|
+
# 10
|
|
180
|
+
|
|
181
|
+
# Greatest Common Divisor
|
|
182
|
+
print(math4u.gcd_recursive(48, 18))
|
|
183
|
+
# 6
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
# =========================
|
|
187
|
+
# Recursive Function with Memoization
|
|
188
|
+
# =========================
|
|
189
|
+
|
|
190
|
+
print(math4u.fibonacci_memo(10))
|
|
191
|
+
# 55
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
# =========================
|
|
195
|
+
# Object-Oriented Programming
|
|
196
|
+
# =========================
|
|
197
|
+
|
|
198
|
+
# Calculator
|
|
199
|
+
calc = math4u.Calculator(10)
|
|
200
|
+
print(calc.add(5))
|
|
201
|
+
# 15
|
|
202
|
+
|
|
203
|
+
# Single Inheritance
|
|
204
|
+
scientific = math4u.ScientificCalculator(4)
|
|
205
|
+
print(scientific.square())
|
|
206
|
+
# 16
|
|
207
|
+
|
|
208
|
+
# Multiple Inheritance
|
|
209
|
+
advanced = math4u.AdvancedCalculator(3)
|
|
210
|
+
print(advanced.cube())
|
|
211
|
+
# 27
|
|
212
|
+
|
|
213
|
+
# Multilevel Inheritance
|
|
214
|
+
special = math4u.SpecialCalculator(2)
|
|
215
|
+
print(special.fourth_power())
|
|
216
|
+
# 16
|
|
217
|
+
|
|
218
|
+
# Hierarchical Inheritance
|
|
219
|
+
basic = math4u.BasicCalculator(5)
|
|
220
|
+
print(basic.double())
|
|
221
|
+
# 10
|
|
222
|
+
|
|
223
|
+
# Hybrid Inheritance
|
|
224
|
+
hybrid = math4u.HybridCalculator(2)
|
|
225
|
+
print(hybrid.fifth_power())
|
|
226
|
+
# 32
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
# =========================
|
|
230
|
+
# Exception Handling
|
|
231
|
+
# =========================
|
|
232
|
+
|
|
233
|
+
# Safe Division
|
|
234
|
+
print(math4u.safe_divide(10, 2))
|
|
235
|
+
# 5.0
|
|
236
|
+
|
|
237
|
+
print(math4u.safe_divide(10, 0))
|
|
238
|
+
# None
|
|
239
|
+
|
|
240
|
+
# Safe Square Root
|
|
241
|
+
print(math4u.safe_square_root(16))
|
|
242
|
+
# 4.0
|
|
243
|
+
|
|
244
|
+
print(math4u.safe_square_root(-1))
|
|
245
|
+
# None
|
|
246
|
+
|
|
247
|
+
# Validate Number
|
|
248
|
+
print(math4u.validate_number("25"))
|
|
249
|
+
# 25.0
|
|
250
|
+
|
|
251
|
+
# Get List Item
|
|
252
|
+
print(math4u.get_list_item([10, 20, 30], 1))
|
|
253
|
+
# 20
|
|
254
|
+
|
|
255
|
+
# Get Dictionary Value
|
|
256
|
+
print(math4u.get_dictionary_value(
|
|
257
|
+
{"name": "Math"},
|
|
258
|
+
"name"
|
|
259
|
+
))
|
|
260
|
+
# Math
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
# =========================
|
|
264
|
+
# NumPy
|
|
265
|
+
# =========================
|
|
266
|
+
|
|
267
|
+
# Create Array
|
|
268
|
+
print(math4u.create_array([1, 2, 3]))
|
|
269
|
+
|
|
270
|
+
# Mean
|
|
271
|
+
print(math4u.array_mean([1, 2, 3, 4]))
|
|
272
|
+
# 2.5
|
|
273
|
+
|
|
274
|
+
# Sum
|
|
275
|
+
print(math4u.array_sum([1, 2, 3, 4]))
|
|
276
|
+
# 10
|
|
277
|
+
|
|
278
|
+
# Matrix Multiplication
|
|
279
|
+
print(math4u.matrix_multiply_numpy(
|
|
280
|
+
[[1, 2], [3, 4]],
|
|
281
|
+
[[5, 6], [7, 8]]
|
|
282
|
+
))
|
|
283
|
+
|
|
284
|
+
# Statistics
|
|
285
|
+
print(math4u.array_statistics([1, 2, 3, 4, 5]))
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
# =========================
|
|
289
|
+
# SciPy and SymPy
|
|
290
|
+
# =========================
|
|
291
|
+
|
|
292
|
+
import sympy as sp
|
|
293
|
+
|
|
294
|
+
x = sp.Symbol("x")
|
|
295
|
+
|
|
296
|
+
# Symbolic Simplify
|
|
297
|
+
print(math4u.symbolic_simplify(
|
|
298
|
+
(x**2 - 1) / (x - 1)
|
|
299
|
+
))
|
|
300
|
+
# x + 1
|
|
301
|
+
|
|
302
|
+
# Symbolic Expand
|
|
303
|
+
print(math4u.symbolic_expand(
|
|
304
|
+
(x + 1)**2
|
|
305
|
+
))
|
|
306
|
+
# x**2 + 2*x + 1
|
|
307
|
+
|
|
308
|
+
# Numerical Integral
|
|
309
|
+
print(math4u.numerical_integral(
|
|
310
|
+
lambda x: x**2,
|
|
311
|
+
0,
|
|
312
|
+
1
|
|
313
|
+
))
|
|
314
|
+
# 0.333333...
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
# =========================
|
|
318
|
+
# Matplotlib
|
|
319
|
+
# =========================
|
|
320
|
+
|
|
321
|
+
x = [1, 2, 3, 4]
|
|
322
|
+
y = [1, 4, 9, 16]
|
|
323
|
+
|
|
324
|
+
math4u.visualization.plot_function(x, y)
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
# =========================
|
|
328
|
+
# NetworkX
|
|
329
|
+
# =========================
|
|
330
|
+
|
|
331
|
+
edges = [
|
|
332
|
+
("A", "B"),
|
|
333
|
+
("B", "C"),
|
|
334
|
+
("C", "A")
|
|
335
|
+
]
|
|
336
|
+
|
|
337
|
+
graph = math4u.visualization.create_graph(edges)
|
|
338
|
+
|
|
339
|
+
math4u.visualization.draw_graph(edges)
|
math4u-0.2.2/README.md
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
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(
|
|
68
|
+
[[2, 1], [1, -1]],
|
|
69
|
+
[5, 1]
|
|
70
|
+
))
|
|
71
|
+
# (2, 1)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# =========================
|
|
75
|
+
# String Processing
|
|
76
|
+
# =========================
|
|
77
|
+
|
|
78
|
+
# 1. Reverse String
|
|
79
|
+
print(math4u.reverse_string("Hello"))
|
|
80
|
+
# olleH
|
|
81
|
+
|
|
82
|
+
# 2. Count Words
|
|
83
|
+
print(math4u.count_words("Hello Python World"))
|
|
84
|
+
# 3
|
|
85
|
+
|
|
86
|
+
# 3. Count Characters
|
|
87
|
+
print(math4u.count_characters("Hello"))
|
|
88
|
+
# 5
|
|
89
|
+
|
|
90
|
+
# 4. Uppercase
|
|
91
|
+
print(math4u.to_uppercase("hello"))
|
|
92
|
+
# HELLO
|
|
93
|
+
|
|
94
|
+
# 5. Lowercase
|
|
95
|
+
print(math4u.to_lowercase("HELLO"))
|
|
96
|
+
# hello
|
|
97
|
+
|
|
98
|
+
# 6. Remove Spaces
|
|
99
|
+
print(math4u.remove_spaces("Hello World"))
|
|
100
|
+
# HelloWorld
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# =========================
|
|
104
|
+
# Data Structures
|
|
105
|
+
# =========================
|
|
106
|
+
|
|
107
|
+
# List
|
|
108
|
+
print(math4u.list_operations([10, 20, 30]))
|
|
109
|
+
|
|
110
|
+
# Tuple
|
|
111
|
+
print(math4u.tuple_operations((1, 2, 3)))
|
|
112
|
+
|
|
113
|
+
# Dictionary Keys
|
|
114
|
+
print(math4u.dictionary_keys({
|
|
115
|
+
"a": 1,
|
|
116
|
+
"b": 2
|
|
117
|
+
}))
|
|
118
|
+
|
|
119
|
+
# Dictionary Values
|
|
120
|
+
print(math4u.dictionary_values({
|
|
121
|
+
"a": 1,
|
|
122
|
+
"b": 2
|
|
123
|
+
}))
|
|
124
|
+
|
|
125
|
+
# Set Union
|
|
126
|
+
print(math4u.set_union({1, 2}, {2, 3}))
|
|
127
|
+
|
|
128
|
+
# Set Intersection
|
|
129
|
+
print(math4u.set_intersection({1, 2}, {2, 3}))
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# =========================
|
|
133
|
+
# Recursive Functions
|
|
134
|
+
# =========================
|
|
135
|
+
|
|
136
|
+
# Factorial
|
|
137
|
+
print(math4u.factorial(5))
|
|
138
|
+
# 120
|
|
139
|
+
|
|
140
|
+
# Fibonacci
|
|
141
|
+
print(math4u.fibonacci(6))
|
|
142
|
+
# 8
|
|
143
|
+
|
|
144
|
+
# Power
|
|
145
|
+
print(math4u.power_recursive(2, 5))
|
|
146
|
+
# 32
|
|
147
|
+
|
|
148
|
+
# Recursive Sum
|
|
149
|
+
print(math4u.sum_recursive([1, 2, 3, 4]))
|
|
150
|
+
# 10
|
|
151
|
+
|
|
152
|
+
# Greatest Common Divisor
|
|
153
|
+
print(math4u.gcd_recursive(48, 18))
|
|
154
|
+
# 6
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
# =========================
|
|
158
|
+
# Recursive Function with Memoization
|
|
159
|
+
# =========================
|
|
160
|
+
|
|
161
|
+
print(math4u.fibonacci_memo(10))
|
|
162
|
+
# 55
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
# =========================
|
|
166
|
+
# Object-Oriented Programming
|
|
167
|
+
# =========================
|
|
168
|
+
|
|
169
|
+
# Calculator
|
|
170
|
+
calc = math4u.Calculator(10)
|
|
171
|
+
print(calc.add(5))
|
|
172
|
+
# 15
|
|
173
|
+
|
|
174
|
+
# Single Inheritance
|
|
175
|
+
scientific = math4u.ScientificCalculator(4)
|
|
176
|
+
print(scientific.square())
|
|
177
|
+
# 16
|
|
178
|
+
|
|
179
|
+
# Multiple Inheritance
|
|
180
|
+
advanced = math4u.AdvancedCalculator(3)
|
|
181
|
+
print(advanced.cube())
|
|
182
|
+
# 27
|
|
183
|
+
|
|
184
|
+
# Multilevel Inheritance
|
|
185
|
+
special = math4u.SpecialCalculator(2)
|
|
186
|
+
print(special.fourth_power())
|
|
187
|
+
# 16
|
|
188
|
+
|
|
189
|
+
# Hierarchical Inheritance
|
|
190
|
+
basic = math4u.BasicCalculator(5)
|
|
191
|
+
print(basic.double())
|
|
192
|
+
# 10
|
|
193
|
+
|
|
194
|
+
# Hybrid Inheritance
|
|
195
|
+
hybrid = math4u.HybridCalculator(2)
|
|
196
|
+
print(hybrid.fifth_power())
|
|
197
|
+
# 32
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
# =========================
|
|
201
|
+
# Exception Handling
|
|
202
|
+
# =========================
|
|
203
|
+
|
|
204
|
+
# Safe Division
|
|
205
|
+
print(math4u.safe_divide(10, 2))
|
|
206
|
+
# 5.0
|
|
207
|
+
|
|
208
|
+
print(math4u.safe_divide(10, 0))
|
|
209
|
+
# None
|
|
210
|
+
|
|
211
|
+
# Safe Square Root
|
|
212
|
+
print(math4u.safe_square_root(16))
|
|
213
|
+
# 4.0
|
|
214
|
+
|
|
215
|
+
print(math4u.safe_square_root(-1))
|
|
216
|
+
# None
|
|
217
|
+
|
|
218
|
+
# Validate Number
|
|
219
|
+
print(math4u.validate_number("25"))
|
|
220
|
+
# 25.0
|
|
221
|
+
|
|
222
|
+
# Get List Item
|
|
223
|
+
print(math4u.get_list_item([10, 20, 30], 1))
|
|
224
|
+
# 20
|
|
225
|
+
|
|
226
|
+
# Get Dictionary Value
|
|
227
|
+
print(math4u.get_dictionary_value(
|
|
228
|
+
{"name": "Math"},
|
|
229
|
+
"name"
|
|
230
|
+
))
|
|
231
|
+
# Math
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
# =========================
|
|
235
|
+
# NumPy
|
|
236
|
+
# =========================
|
|
237
|
+
|
|
238
|
+
# Create Array
|
|
239
|
+
print(math4u.create_array([1, 2, 3]))
|
|
240
|
+
|
|
241
|
+
# Mean
|
|
242
|
+
print(math4u.array_mean([1, 2, 3, 4]))
|
|
243
|
+
# 2.5
|
|
244
|
+
|
|
245
|
+
# Sum
|
|
246
|
+
print(math4u.array_sum([1, 2, 3, 4]))
|
|
247
|
+
# 10
|
|
248
|
+
|
|
249
|
+
# Matrix Multiplication
|
|
250
|
+
print(math4u.matrix_multiply_numpy(
|
|
251
|
+
[[1, 2], [3, 4]],
|
|
252
|
+
[[5, 6], [7, 8]]
|
|
253
|
+
))
|
|
254
|
+
|
|
255
|
+
# Statistics
|
|
256
|
+
print(math4u.array_statistics([1, 2, 3, 4, 5]))
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
# =========================
|
|
260
|
+
# SciPy and SymPy
|
|
261
|
+
# =========================
|
|
262
|
+
|
|
263
|
+
import sympy as sp
|
|
264
|
+
|
|
265
|
+
x = sp.Symbol("x")
|
|
266
|
+
|
|
267
|
+
# Symbolic Simplify
|
|
268
|
+
print(math4u.symbolic_simplify(
|
|
269
|
+
(x**2 - 1) / (x - 1)
|
|
270
|
+
))
|
|
271
|
+
# x + 1
|
|
272
|
+
|
|
273
|
+
# Symbolic Expand
|
|
274
|
+
print(math4u.symbolic_expand(
|
|
275
|
+
(x + 1)**2
|
|
276
|
+
))
|
|
277
|
+
# x**2 + 2*x + 1
|
|
278
|
+
|
|
279
|
+
# Numerical Integral
|
|
280
|
+
print(math4u.numerical_integral(
|
|
281
|
+
lambda x: x**2,
|
|
282
|
+
0,
|
|
283
|
+
1
|
|
284
|
+
))
|
|
285
|
+
# 0.333333...
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
# =========================
|
|
289
|
+
# Matplotlib
|
|
290
|
+
# =========================
|
|
291
|
+
|
|
292
|
+
x = [1, 2, 3, 4]
|
|
293
|
+
y = [1, 4, 9, 16]
|
|
294
|
+
|
|
295
|
+
math4u.visualization.plot_function(x, y)
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
# =========================
|
|
299
|
+
# NetworkX
|
|
300
|
+
# =========================
|
|
301
|
+
|
|
302
|
+
edges = [
|
|
303
|
+
("A", "B"),
|
|
304
|
+
("B", "C"),
|
|
305
|
+
("C", "A")
|
|
306
|
+
]
|
|
307
|
+
|
|
308
|
+
graph = math4u.visualization.create_graph(edges)
|
|
309
|
+
|
|
310
|
+
math4u.visualization.draw_graph(edges)
|
|
Binary file
|
|
@@ -78,56 +78,80 @@ from .scipy_tools import (
|
|
|
78
78
|
numerical_integral,
|
|
79
79
|
)
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
from . import visualization
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
__version__ = "0.2.2"
|
|
85
|
+
|
|
82
86
|
|
|
83
87
|
__all__ = [
|
|
88
|
+
# Calculus
|
|
84
89
|
"derivative",
|
|
85
90
|
"second_derivative",
|
|
86
91
|
"integrate",
|
|
87
92
|
"definite_integral",
|
|
88
93
|
"limit",
|
|
89
94
|
"taylor_series",
|
|
95
|
+
|
|
96
|
+
# Linear Algebra
|
|
90
97
|
"matrix_add",
|
|
91
98
|
"matrix_multiply",
|
|
92
99
|
"determinant",
|
|
93
100
|
"inverse_matrix",
|
|
94
101
|
"transpose",
|
|
95
102
|
"solve_linear_system",
|
|
103
|
+
|
|
104
|
+
# String Processing
|
|
96
105
|
"reverse_string",
|
|
97
106
|
"count_words",
|
|
98
107
|
"count_characters",
|
|
99
108
|
"to_uppercase",
|
|
100
109
|
"to_lowercase",
|
|
101
110
|
"remove_spaces",
|
|
111
|
+
|
|
112
|
+
# Data Structures
|
|
102
113
|
"list_operations",
|
|
103
114
|
"tuple_operations",
|
|
104
115
|
"dictionary_keys",
|
|
105
116
|
"dictionary_values",
|
|
106
117
|
"set_union",
|
|
107
118
|
"set_intersection",
|
|
119
|
+
|
|
120
|
+
# Recursion
|
|
108
121
|
"factorial",
|
|
109
122
|
"fibonacci",
|
|
110
123
|
"fibonacci_memo",
|
|
111
124
|
"power_recursive",
|
|
112
125
|
"sum_recursive",
|
|
113
126
|
"gcd_recursive",
|
|
127
|
+
|
|
128
|
+
# OOP
|
|
114
129
|
"Calculator",
|
|
115
130
|
"ScientificCalculator",
|
|
116
131
|
"AdvancedCalculator",
|
|
117
132
|
"SpecialCalculator",
|
|
118
133
|
"BasicCalculator",
|
|
119
134
|
"HybridCalculator",
|
|
135
|
+
|
|
136
|
+
# Exception Handling
|
|
120
137
|
"safe_divide",
|
|
121
138
|
"safe_square_root",
|
|
122
139
|
"validate_number",
|
|
123
140
|
"get_list_item",
|
|
124
141
|
"get_dictionary_value",
|
|
142
|
+
|
|
143
|
+
# NumPy
|
|
125
144
|
"create_array",
|
|
126
145
|
"array_mean",
|
|
127
146
|
"array_sum",
|
|
128
147
|
"matrix_multiply_numpy",
|
|
129
148
|
"array_statistics",
|
|
149
|
+
|
|
150
|
+
# SciPy and SymPy
|
|
130
151
|
"symbolic_simplify",
|
|
131
152
|
"symbolic_expand",
|
|
132
153
|
"numerical_integral",
|
|
154
|
+
|
|
155
|
+
# Visualization
|
|
156
|
+
"visualization",
|
|
133
157
|
]
|
math4u-0.2.0/PKG-INFO
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
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)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|