slangmath 1.0.0

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.
@@ -0,0 +1,366 @@
1
+ # SLaNg Math Library - Architecture & Flow
2
+
3
+ ## πŸ“ Library Architecture
4
+
5
+ ```
6
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
7
+ β”‚ YOUR APPLICATION β”‚
8
+ β”‚ (Your Exercise 15.1, etc.) β”‚
9
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
10
+ β”‚
11
+ β”‚ imports
12
+ β–Ό
13
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
14
+ β”‚ HELPER LAYER β”‚
15
+ β”‚ (slang-helpers.js) β”‚
16
+ β”‚ β”‚
17
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
18
+ β”‚ β”‚ polynomial β”‚ β”‚ sum β”‚ β”‚ integralValueβ”‚ β”‚
19
+ β”‚ β”‚ Easy create β”‚ β”‚ Easy create β”‚ β”‚ One-liner β”‚ β”‚
20
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
21
+ β”‚ β”‚
22
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
23
+ β”‚ β”‚volumeUnder β”‚ β”‚ areaOfRegion β”‚ β”‚verification β”‚ β”‚
24
+ β”‚ β”‚ Surface β”‚ β”‚ β”‚ β”‚ tools β”‚ β”‚
25
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
26
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
27
+ β”‚
28
+ β”‚ uses
29
+ β–Ό
30
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
31
+ β”‚ CORE LAYER β”‚
32
+ β”‚ (slang-math.js) β”‚
33
+ β”‚ β”‚
34
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
35
+ β”‚ β”‚ createTerm β”‚ β”‚ integrate β”‚ β”‚ differentiateβ”‚ β”‚
36
+ β”‚ β”‚ createFrac β”‚ β”‚ Fraction β”‚ β”‚ Fraction β”‚ β”‚
37
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
38
+ β”‚ β”‚
39
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
40
+ β”‚ β”‚ evaluate β”‚ β”‚ expand β”‚ β”‚ simplify β”‚ β”‚
41
+ β”‚ β”‚ Equation β”‚ β”‚ Product β”‚ β”‚ Fraction β”‚ β”‚
42
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
43
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
44
+ β”‚
45
+ β”‚ uses
46
+ β–Ό
47
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
48
+ β”‚ ADVANCED LAYER β”‚
49
+ β”‚ (slang-advanced.js) β”‚
50
+ β”‚ β”‚
51
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
52
+ β”‚ β”‚ product β”‚ β”‚ quotient β”‚ β”‚ integration β”‚ β”‚
53
+ β”‚ β”‚ Rule β”‚ β”‚ Rule β”‚ β”‚ by Parts β”‚ β”‚
54
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
55
+ β”‚ β”‚
56
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
57
+ β”‚ β”‚ Taylor β”‚ β”‚ critical β”‚ β”‚ gradient β”‚ β”‚
58
+ β”‚ β”‚ Series β”‚ β”‚ Points β”‚ β”‚ & directionalβ”‚ β”‚
59
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
60
+ β”‚ β”‚
61
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
62
+ β”‚ β”‚ arc β”‚ β”‚ surface β”‚ β”‚
63
+ β”‚ β”‚ Length β”‚ β”‚ Area β”‚ β”‚
64
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
65
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
66
+ ```
67
+
68
+ ## πŸ”„ Data Flow Example
69
+
70
+ ### Example: Computing βˆ«β‚€Β² βˆ«β‚€Β³ xy dy dx
71
+
72
+ ```
73
+ USER CODE:
74
+ integralValue(xy, {x: [0,2], y: [0,3]})
75
+ β”‚
76
+ β–Ό
77
+ HELPER LAYER (slang-helpers.js):
78
+ integralOverRegion(xy, bounds)
79
+ β”‚
80
+ β”œβ”€ Loop through variables
81
+ β”‚ β”‚
82
+ β”‚ β”œβ”€ For y: definiteIntegrateFraction(xy, 0, 3, 'y')
83
+ β”‚ β”‚ β”‚
84
+ β”‚ β”‚ β–Ό
85
+ β”‚ β”‚ CORE LAYER (slang-math.js):
86
+ β”‚ β”‚ definiteIntegrateTerm for each term
87
+ β”‚ β”‚ β”‚
88
+ β”‚ β”‚ β”œβ”€ integrateTerm(term, 'y') // xy β†’ xyΒ²/2
89
+ β”‚ β”‚ β”‚ β”‚
90
+ β”‚ β”‚ β”‚ β–Ό
91
+ β”‚ β”‚ β”‚ Power rule: n β†’ n+1, coeff/(n+1)
92
+ β”‚ β”‚ β”‚
93
+ β”‚ β”‚ β”œβ”€ Evaluate at bounds
94
+ β”‚ β”‚ β”‚ Upper: y=3 β†’ coefficient * 3Β²
95
+ β”‚ β”‚ β”‚ Lower: y=0 β†’ coefficient * 0Β²
96
+ β”‚ β”‚ β”‚ Difference: gets multiplied into coefficient
97
+ β”‚ β”‚ β”‚
98
+ β”‚ β”‚ └─ Remove 'y' variable, keep 'x'
99
+ β”‚ β”‚
100
+ β”‚ β”‚ Result: 4.5x
101
+ β”‚ β”‚
102
+ β”‚ └─ For x: definiteIntegrateFraction(4.5x, 0, 2, 'x')
103
+ β”‚ β”‚
104
+ β”‚ β–Ό
105
+ β”‚ CORE LAYER:
106
+ β”‚ Similar process
107
+ β”‚ β”‚
108
+ β”‚ └─ Result: 9
109
+ β”‚
110
+ └─ simplifyFraction(result)
111
+ β”‚
112
+ β–Ό
113
+ evaluateEquation([[result]], {})
114
+ β”‚
115
+ β–Ό
116
+ RETURN: 9
117
+ ```
118
+
119
+ ## πŸ—οΈ SLaNg Notation Structure
120
+
121
+ ```
122
+ EQUATION (Top level - Array)
123
+ β”‚
124
+ β”œβ”€ PRODUCT 1 (Array) ────────────────┐
125
+ β”‚ β”‚ β”‚
126
+ β”‚ β”œβ”€ FRACTION 1 β”‚ Products are summed
127
+ β”‚ β”‚ β”œβ”€ numerator (numi) β”‚ (a)(b) + (c)(d) + ...
128
+ β”‚ β”‚ β”‚ └─ terms (Array) β”‚
129
+ β”‚ β”‚ β”‚ β”œβ”€ TERM 1 ───┐ β”‚
130
+ β”‚ β”‚ β”‚ β”‚ β”œβ”€ coeff β”‚ β”‚
131
+ β”‚ β”‚ β”‚ β”‚ └─ var {} β”‚ β”‚
132
+ β”‚ β”‚ β”‚ β”‚ Terms β”‚
133
+ β”‚ β”‚ β”‚ β”œβ”€ TERM 2 are added β”‚
134
+ β”‚ β”‚ β”‚ β”‚ β”œβ”€ coeff β”‚ β”‚
135
+ β”‚ β”‚ β”‚ β”‚ └─ var {} β”‚ β”‚
136
+ β”‚ β”‚ β”‚ β”‚ β–Ό β”‚
137
+ β”‚ β”‚ β”‚ └─ TERM 3 Sum β”‚
138
+ β”‚ β”‚ β”‚ β”œβ”€ coeff β”‚
139
+ β”‚ β”‚ β”‚ └─ var {} β”‚
140
+ β”‚ β”‚ β”‚ β”‚
141
+ β”‚ β”‚ └─ denominator (deno) β”‚
142
+ β”‚ β”‚ └─ number β”‚
143
+ β”‚ β”‚ β”‚
144
+ β”‚ └─ FRACTION 2 ──┐ β”‚
145
+ β”‚ β”œβ”€ numi β”‚ Fractions β”‚
146
+ β”‚ └─ deno β”‚ are multiplied β”‚
147
+ β”‚ β–Ό β”‚
148
+ β”‚ Product β”‚
149
+ β”‚ β”‚
150
+ β”œβ”€ PRODUCT 2 ──────────────────────────
151
+ β”‚ └─ ... β”‚
152
+ β”‚ β”‚
153
+ └─ PRODUCT N β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
154
+ ```
155
+
156
+ ## 🎯 Operation Flow Diagrams
157
+
158
+ ### Integration Flow
159
+
160
+ ```
161
+ INPUT: Expression + bounds + variable
162
+ β”‚
163
+ β–Ό
164
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
165
+ β”‚ Deep Clone β”‚ (Prevent mutation)
166
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
167
+ β”‚
168
+ β–Ό
169
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
170
+ β”‚ For each term: β”‚
171
+ β”‚ Apply power β”‚
172
+ β”‚ rule β”‚
173
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
174
+ β”‚
175
+ β–Ό
176
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
177
+ β”‚ Evaluate at β”‚
178
+ β”‚ upper bound β”‚
179
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
180
+ β”‚
181
+ β–Ό
182
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
183
+ β”‚ Evaluate at β”‚
184
+ β”‚ lower bound β”‚
185
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
186
+ β”‚
187
+ β–Ό
188
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
189
+ β”‚ Subtract: β”‚
190
+ β”‚ upper - lower β”‚
191
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
192
+ β”‚
193
+ β–Ό
194
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
195
+ β”‚ Remove variable β”‚
196
+ β”‚ from term β”‚
197
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
198
+ β”‚
199
+ β–Ό
200
+ OUTPUT: Result
201
+ ```
202
+
203
+ ### Differentiation Flow
204
+
205
+ ```
206
+ INPUT: Expression + variable
207
+ β”‚
208
+ β–Ό
209
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
210
+ β”‚ Deep Clone β”‚
211
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
212
+ β”‚
213
+ β–Ό
214
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
215
+ β”‚ For each term: β”‚
216
+ β”‚ β”‚
217
+ β”‚ If var absent: β”‚
218
+ β”‚ return 0 β”‚
219
+ β”‚ β”‚
220
+ β”‚ If var present: β”‚
221
+ β”‚ coeff *= pow β”‚
222
+ β”‚ pow -= 1 β”‚
223
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
224
+ β”‚
225
+ β–Ό
226
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
227
+ β”‚ Simplify: β”‚
228
+ β”‚ Remove zeros β”‚
229
+ β”‚ Combine terms β”‚
230
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
231
+ β”‚
232
+ β–Ό
233
+ OUTPUT: Result
234
+ ```
235
+
236
+ ### Expansion Flow (FOIL)
237
+
238
+ ```
239
+ INPUT: (a + b)(c + d)
240
+ β”‚
241
+ β–Ό
242
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
243
+ β”‚ Nested loop: β”‚
244
+ β”‚ β”‚
245
+ β”‚ For each term β”‚
246
+ β”‚ in first () β”‚
247
+ β”‚ For each β”‚
248
+ β”‚ term in β”‚
249
+ β”‚ second () β”‚
250
+ β”‚ Multiply β”‚
251
+ β”‚ terms β”‚
252
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
253
+ β”‚
254
+ β–Ό
255
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
256
+ β”‚ Collect all β”‚
257
+ β”‚ products: β”‚
258
+ β”‚ a*c β”‚
259
+ β”‚ a*d β”‚
260
+ β”‚ b*c β”‚
261
+ β”‚ b*d β”‚
262
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
263
+ β”‚
264
+ β–Ό
265
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
266
+ β”‚ Combine like β”‚
267
+ β”‚ terms β”‚
268
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
269
+ β”‚
270
+ β–Ό
271
+ OUTPUT: ac + ad + bc + bd
272
+ ```
273
+
274
+ ## πŸ“Š Complexity Analysis
275
+
276
+ ### Time Complexity
277
+
278
+ | Operation | Complexity | Notes |
279
+ |-----------|------------|-------|
280
+ | Create term | O(1) | Just object creation |
281
+ | Evaluate term | O(v) | v = number of variables |
282
+ | Differentiate | O(n) | n = number of terms |
283
+ | Integrate | O(n) | Linear in terms |
284
+ | Expand (a+b)(c+d) | O(nm) | n, m = terms in each |
285
+ | Simplify | O(nΒ²) | Comparing all pairs |
286
+ | Definite integral | O(n) | Plus evaluation |
287
+
288
+ ### Space Complexity
289
+
290
+ | Operation | Complexity | Notes |
291
+ |-----------|------------|-------|
292
+ | Store expression | O(n) | n = number of terms |
293
+ | Deep clone | O(n) | Duplicate all data |
294
+ | Expansion | O(nm) | New terms created |
295
+
296
+ ## πŸ” Design Patterns Used
297
+
298
+ ### 1. **Builder Pattern**
299
+ ```javascript
300
+ polynomial([1, -2, 1], 'x') // Builds complex structure simply
301
+ ```
302
+
303
+ ### 2. **Strategy Pattern**
304
+ ```javascript
305
+ // Different integration strategies
306
+ definiteIntegrateFraction() // Numerical bounds
307
+ integrateFraction() // Symbolic
308
+ ```
309
+
310
+ ### 3. **Visitor Pattern**
311
+ ```javascript
312
+ // Operations "visit" each term
313
+ terms.map(term => differentiateTerm(term, var))
314
+ ```
315
+
316
+ ### 4. **Immutability Pattern**
317
+ ```javascript
318
+ deepClone(obj) // Always work on copies
319
+ ```
320
+
321
+ ## 🎨 Code Organization Principles
322
+
323
+ 1. **Separation of Concerns**
324
+ - Core: Basic operations
325
+ - Helpers: Convenience functions
326
+ - Advanced: Complex algorithms
327
+
328
+ 2. **Single Responsibility**
329
+ - Each function does ONE thing
330
+ - Clear, focused purpose
331
+
332
+ 3. **DRY (Don't Repeat Yourself)**
333
+ - `deepClone` used everywhere
334
+ - `evaluateEquation` reused
335
+ - Helper builders reduce duplication
336
+
337
+ 4. **Progressive Enhancement**
338
+ - Start with core
339
+ - Add helpers
340
+ - Layer advanced features
341
+
342
+ ## πŸš€ Performance Tips
343
+
344
+ 1. **Use helpers**: They're optimized
345
+ 2. **Simplify often**: Reduces term count
346
+ 3. **Clone wisely**: Only when needed (but library does this for you)
347
+ 4. **Cache results**: Don't recompute same integrals
348
+ 5. **Increase steps carefully**: More steps = slower but more accurate
349
+
350
+ ## πŸ“ˆ Scalability
351
+
352
+ The library scales well for:
353
+ - βœ“ Polynomials up to degree ~20
354
+ - βœ“ ~100 terms per expression
355
+ - βœ“ Double/triple integrals
356
+ - βœ“ Functions of 2-3 variables
357
+
358
+ For larger problems:
359
+ - Consider breaking into smaller parts
360
+ - Use numerical methods
361
+ - Cache intermediate results
362
+
363
+ ---
364
+
365
+ This architecture provides a solid foundation for symbolic mathematics
366
+ while remaining simple enough to understand and extend!
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Muhammad Saad Amin - @SENODROOM
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.