rgwfuncs 0.0.30__tar.gz → 0.0.32__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rgwfuncs
3
- Version: 0.0.30
3
+ Version: 0.0.32
4
4
  Summary: A functional programming paradigm for mathematical modelling and data science
5
5
  Home-page: https://github.com/ryangerardwilson/rgwfunc
6
6
  Author: Ryan Gerard Wilson
@@ -154,43 +154,27 @@ Print a list of available function names in alphabetical order. If a filter is p
154
154
 
155
155
  This section provides comprehensive functions for handling algebraic expressions, performing tasks such as computation, simplification, solving equations, and prime factorization, all outputted in LaTeX format.
156
156
 
157
- ### 1. `python_polynomial_expression_to_latex`
157
+ ### 1. `compute_prime_factors_latex`
158
158
 
159
- Converts a polynomial expression written in Python syntax to a LaTeX formatted string. This function parses algebraic expressions provided as strings using Python’s syntax and translates them into equivalent LaTeX representations, making them suitable for academic or professional documentation. The function supports inclusion of named variables, with an option to substitute specific values into the expression.
159
+ Computes prime factors of a number and presents them in LaTeX format.
160
160
 
161
161
  • Parameters:
162
- - `expression` (str): The algebraic expression to convert to LaTeX. This should be a string formatted with Python syntax acceptable by SymPy.
163
- - `subs` (Optional[Dict[str, float]]): An optional dictionary of substitutions where the keys are variable names in the expression, and the values are the numbers with which to substitute those variables.
162
+ - `n` (int): The integer to factorize.
164
163
 
165
164
  • Returns:
166
- - `str`: The LaTeX formatted string equivalent to the provided expression.
167
-
168
- • Raises:
169
- - `ValueError`: If the expression cannot be parsed due to syntax errors.
165
+ - `str`: Prime factorization in LaTeX.
170
166
 
171
167
  • Example:
172
168
 
173
- from rgwfuncs import python_polynomial_expression_to_latex
174
-
175
- # Convert a simple polynomial expression to LaTeX format
176
- latex_result1 = python_polynomial_expression_to_latex("x**2 + y**2")
177
- print(latex_result1) # Output: "x^{2} + y^{2}"
178
-
179
- # Convert polynomial expression with substituted values
180
- latex_result2 = python_polynomial_expression_to_latex("x**2 + y**2", {"x": 3, "y": 4})
181
- print(latex_result2) # Output: "25"
182
-
183
- # Another example with partial substitution
184
- latex_result3 = python_polynomial_expression_to_latex("x**2 + y**2", {"x": 3})
185
- print(latex_result3) # Output: "y^{2} + 9"
186
-
187
- # Trigonometric functions included with symbolic variables
188
- latex_result4 = python_polynomial_expression_to_latex("sin(x+z**2) + cos(y)", {"x": 55})
189
- print(latex_result4) # Output: "cos y + sin \\left(z^{2} + 55\\right)"
190
-
191
- # Simplified trigonometric functions example with substitution
192
- latex_result5 = python_polynomial_expression_to_latex("sin(x) + cos(y)", {"x": 0})
193
- print(latex_result5) # Output: "cos y"
169
+ from rgwfuncs import compute_prime_factors_latex
170
+ factors_1 = compute_prime_factors_latex(100)
171
+ print(factors_1) # Output: "2^{2} \cdot 5^{2}"
172
+
173
+ factors_2 = compute_prime_factors_latex(60)
174
+ print(factors_2) # Output: "2^{2} \cdot 3 \cdot 5"
175
+
176
+ factors_3 = compute_prime_factors_latex(17)
177
+ print(factors_3) # Output: "17"
194
178
 
195
179
  --------------------------------------------------------------------------------
196
180
 
@@ -218,140 +202,157 @@ Computes the numerical result of a given expression, which can evaluate to a con
218
202
 
219
203
  --------------------------------------------------------------------------------
220
204
 
221
- ### 3. `simplify_polynomial_expression`
205
+ ### 3. `compute_constant_expression_involving_matrices`
222
206
 
223
- Simplifies an algebraic expression in polynomial form and returns it in LaTeX format. Takes an algebraic expression, in polynomial form, written in Python syntax and simplifies it. The result is returned as a LaTeX formatted string, suitable for academic or professional documentation.
207
+ Computes the result of a constant expression involving matrices and returns it as a LaTeX string.
224
208
 
225
209
  • Parameters:
226
- - `expression` (str): The algebraic expression, in polynomial form, to simplify. For instance, the expression 'np.diff(8*x**30) where as 'np.diff([2,5,9,11)' is not a polynomial.
227
- - `subs` (Optional[Dict[str, float]]): An optional dictionary of substitutions where keys are variable names and values are the numbers to substitute them with.
210
+ - `expression` (str): The constant expression involving matrices. Example format includes operations such as "+", "-", "*", "/".
228
211
 
229
212
  • Returns:
230
- - `str`: The simplified expression formatted as a LaTeX string.
231
-
232
- • Example Usage:
213
+ - `str`: The LaTeX-formatted string representation of the computed matrix, or an error message if the operations cannot be performed due to dimensional mismatches.
233
214
 
234
- from rgwfuncs import simplify_polynomial_expression
215
+ Example:
235
216
 
236
- # Example 1: Simplifying a polynomial expression without substitutions
237
- simplified_expr1 = simplify_polynomial_expression("2*x + 3*x")
238
- print(simplified_expr1) # Output: "5 x"
217
+ from rgwfuncs import compute_constant_expression_involving_matrices
239
218
 
240
- # Example 2: Simplifying a complex expression involving derivatives
241
- simplified_expr2 = simplify_polynomial_expression("(np.diff(3*x**8)) / (np.diff(8*x**30) * 11*y**3)")
242
- print(simplified_expr2) # Output: r"\frac{1}{110 x^{22} y^{3}}"
219
+ # Example with addition of 2D matrices
220
+ result = compute_constant_expression_involving_matrices("[[2, 6, 9], [1, 3, 5]] + [[1, 2, 3], [4, 5, 6]]")
221
+ print(result) # Output: \begin{bmatrix}3 & 8 & 12\\5 & 8 & 11\end{bmatrix}
243
222
 
244
- # Example 3: Simplifying with substitutions
245
- simplified_expr3 = simplify_polynomial_expression("x**2 + y**2", subs={"x": 3, "y": 4})
246
- print(simplified_expr3) # Output: "25"
223
+ # Example of mixed operations with 1D matrices treated as 2D
224
+ result = compute_constant_expression_involving_matrices("[3, 6, 9] + [1, 2, 3] - [2, 2, 2]")
225
+ print(result) # Output: \begin{bmatrix}2 & 6 & 10\end{bmatrix}
247
226
 
248
- # Example 4: Simplifying with partial substitution
249
- simplified_expr4 = simplify_polynomial_expression("a*b + b", subs={"b": 2})
250
- print(simplified_expr4) # Output: "2 a + 2"
227
+ # Example with dimension mismatch
228
+ result = compute_constant_expression_involving_matrices("[[4, 3, 51]] + [[1, 1]]")
229
+ print(result) # Output: Operations between matrices must involve matrices of the same dimension
251
230
 
252
231
  --------------------------------------------------------------------------------
253
232
 
254
- ### 4. `solve_homogeneous_polynomial_expression`
233
+ ### 4. `compute_constant_expression_involving_ordered_series`
234
+
235
+ Computes the result of a constant expression involving ordered series, and returns it as a Latex string.
255
236
 
256
- Solves a homogeneous polynomial expression for a specified variable and returns solutions in LaTeX format. Assumes that the expression is homoegeneous (i.e. equal to zero), and solves for a designated variable. May optionally include substitutions for other variables in the equation. The solutions are provided as a LaTeX formatted string. The method solves equations for specified variables, with optional substitutions, returning LaTeX-formatted solutions.
257
237
 
258
238
  • Parameters:
259
- - `expression` (str): A string of the homogeneous polynomial expression to solve.
260
- - `variable` (str): The variable to solve for.
261
- - `subs` (Optional[Dict[str, float]]): Substitutions for variables.
239
+ - `expression` (str): A series operation expression. Supports operations such as "+", "-", "*", "/", and `dd()` for discrete differences.
262
240
 
263
241
  • Returns:
264
- - `str`: Solutions formatted in LaTeX.
242
+ - `str`: The string representation of the resultant series after performing operations, or an error message if series lengths do not match.
265
243
 
266
244
  • Example:
267
245
 
268
- from rgwfuncs import solve_homogeneous_polynomial_expression
269
- solutions1 = solve_homogeneous_polynomial_expression("a*x**2 + b*x + c", "x", {"a": 3, "b": 7, "c": 5})
270
- print(solutions1) # Output: "\left[-7/6 - sqrt(11)*I/6, -7/6 + sqrt(11)*I/6\right]"
246
+ from rgwfuncs import compute_constant_expression_involving_ordered_series
247
+
248
+ # Example with addition and discrete differences
249
+ result = compute_constant_expression_involving_ordered_series("dd([2, 6, 9, 60]) + dd([78, 79, 80])")
250
+ print(result) # Output: [4, 3, 51] + [1, 1]
251
+
252
+ # Example with elementwise subtraction
253
+ result = compute_constant_expression_involving_ordered_series("[10, 15, 21] - [5, 5, 5]")
254
+ print(result) # Output: [5, 10, 16]
255
+
256
+ # Example with length mismatch
257
+ result = compute_constant_expression_involving_ordered_series("[4, 3, 51] + [1, 1]")
258
+ print(result) # Output: Operations between ordered series must involve series of equal length
271
259
 
272
- solutions2 = solve_homogeneous_polynomial_expression("x**2 - 4", "x")
273
- print(solutions2) # Output: "\left[-2, 2\right]"
274
-
275
260
  --------------------------------------------------------------------------------
276
261
 
277
- ### 5. `get_prime_factors_latex`
262
+ ### 5. `python_polynomial_expression_to_latex`
278
263
 
279
- Computes prime factors of a number and presents them in LaTeX format.
264
+ Converts a polynomial expression written in Python syntax to a LaTeX formatted string. This function parses algebraic expressions provided as strings using Python’s syntax and translates them into equivalent LaTeX representations, making them suitable for academic or professional documentation. The function supports inclusion of named variables, with an option to substitute specific values into the expression.
280
265
 
281
266
  • Parameters:
282
- - `n` (int): The integer to factorize.
267
+ - `expression` (str): The algebraic expression to convert to LaTeX. This should be a string formatted with Python syntax acceptable by SymPy.
268
+ - `subs` (Optional[Dict[str, float]]): An optional dictionary of substitutions where the keys are variable names in the expression, and the values are the numbers with which to substitute those variables.
283
269
 
284
270
  • Returns:
285
- - `str`: Prime factorization in LaTeX.
271
+ - `str`: The LaTeX formatted string equivalent to the provided expression.
286
272
 
287
- Example:
273
+ Raises:
274
+ - `ValueError`: If the expression cannot be parsed due to syntax errors.
288
275
 
289
- from rgwfuncs import get_prime_factors_latex
290
- factors1 = get_prime_factors_latex(100)
291
- print(factors1) # Output: "2^{2} \cdot 5^{2}"
276
+ Example:
292
277
 
293
- factors2 = get_prime_factors_latex(60)
294
- print(factors2) # Output: "2^{2} \cdot 3 \cdot 5"
278
+ from rgwfuncs import python_polynomial_expression_to_latex
279
+
280
+ # Convert a simple polynomial expression to LaTeX format
281
+ latex_result1 = python_polynomial_expression_to_latex("x**2 + y**2")
282
+ print(latex_result1) # Output: "x^{2} + y^{2}"
283
+
284
+ # Convert polynomial expression with substituted values
285
+ latex_result2 = python_polynomial_expression_to_latex("x**2 + y**2", {"x": 3, "y": 4})
286
+ print(latex_result2) # Output: "25"
287
+
288
+ # Another example with partial substitution
289
+ latex_result3 = python_polynomial_expression_to_latex("x**2 + y**2", {"x": 3})
290
+ print(latex_result3) # Output: "y^{2} + 9"
291
+
292
+ # Trigonometric functions included with symbolic variables
293
+ latex_result4 = python_polynomial_expression_to_latex("sin(x+z**2) + cos(y)", {"x": 55})
294
+ print(latex_result4) # Output: "cos y + sin \\left(z^{2} + 55\\right)"
295
+
296
+ # Simplified trigonometric functions example with substitution
297
+ latex_result5 = python_polynomial_expression_to_latex("sin(x) + cos(y)", {"x": 0})
298
+ print(latex_result5) # Output: "cos y"
295
299
 
296
- factors3 = get_prime_factors_latex(17)
297
- print(factors3) # Output: "17"
298
-
299
300
  --------------------------------------------------------------------------------
300
301
 
301
- ### 6. `compute_matrix_expression`
302
+ ### 6. `simplify_polynomial_expression`
302
303
 
303
- Computes the results of expressions containing 1D or 2D matrix operations and formats them as LaTeX strings.
304
+ Simplifies an algebraic expression in polynomial form and returns it in LaTeX format. Takes an algebraic expression, in polynomial form, written in Python syntax and simplifies it. The result is returned as a LaTeX formatted string, suitable for academic or professional documentation.
304
305
 
305
306
  • Parameters:
306
- - `expression` (str): A string representing a sequence of matrix operations involving either 1D or 2D lists. Supported operations include addition (`+`), subtraction (`-`), multiplication (`*`), and division (`/`).
307
+ - `expression` (str): The algebraic expression, in polynomial form, to simplify. For instance, the expression 'np.diff(8*x**30) where as 'np.diff([2,5,9,11)' is not a polynomial.
308
+ - `subs` (Optional[Dict[str, float]]): An optional dictionary of substitutions where keys are variable names and values are the numbers to substitute them with.
307
309
 
308
310
  • Returns:
309
- - `str`: The LaTeX-formatted string representation of the computed matrix, or an error message if the operations cannot be performed due to dimensional mismatches.
311
+ - `str`: The simplified expression formatted as a LaTeX string.
310
312
 
311
- • Example:
313
+ • Example Usage:
312
314
 
313
- from rgwfuncs import compute_matrix_expression
314
-
315
- # Example with addition of 2D matrices
316
- result = compute_matrix_expression("[[2, 6, 9], [1, 3, 5]] + [[1, 2, 3], [4, 5, 6]]")
317
- print(result) # Output: \begin{bmatrix}3 & 8 & 12\\5 & 8 & 11\end{bmatrix}
318
-
319
- # Example of mixed operations with 1D matrices treated as 2D
320
- result = compute_matrix_expression("[3, 6, 9] + [1, 2, 3] - [2, 2, 2]")
321
- print(result) # Output: \begin{bmatrix}2 & 6 & 10\end{bmatrix}
315
+ from rgwfuncs import simplify_polynomial_expression
322
316
 
323
- # Example with dimension mismatch
324
- result = compute_matrix_expression("[[4, 3, 51]] + [[1, 1]]")
325
- print(result) # Output: Operations between matrices must involve matrices of the same dimension
317
+ # Example 1: Simplifying a polynomial expression without substitutions
318
+ simplified_expr1 = simplify_polynomial_expression("2*x + 3*x")
319
+ print(simplified_expr1) # Output: "5 x"
320
+
321
+ # Example 2: Simplifying a complex expression involving derivatives
322
+ simplified_expr2 = simplify_polynomial_expression("(np.diff(3*x**8)) / (np.diff(8*x**30) * 11*y**3)")
323
+ print(simplified_expr2) # Output: r"\frac{1}{110 x^{22} y^{3}}"
324
+
325
+ # Example 3: Simplifying with substitutions
326
+ simplified_expr3 = simplify_polynomial_expression("x**2 + y**2", subs={"x": 3, "y": 4})
327
+ print(simplified_expr3) # Output: "25"
328
+
329
+ # Example 4: Simplifying with partial substitution
330
+ simplified_expr4 = simplify_polynomial_expression("a*b + b", subs={"b": 2})
331
+ print(simplified_expr4) # Output: "2 a + 2"
326
332
 
327
333
  --------------------------------------------------------------------------------
328
334
 
329
- ### 7. `compute_ordered_series_expression`
335
+ ### 7. `solve_homogeneous_polynomial_expression`
330
336
 
331
- Computes the result of expressions containing operations on ordered series expressed as 1D lists. The syntax of the expression supports the discrete difference operator via the `ddd()` method.
337
+ Solves a homogeneous polynomial expression for a specified variable and returns solutions in LaTeX format. Assumes that the expression is homoegeneous (i.e. equal to zero), and solves for a designated variable. May optionally include substitutions for other variables in the equation. The solutions are provided as a LaTeX formatted string. The method solves equations for specified variables, with optional substitutions, returning LaTeX-formatted solutions.
332
338
 
333
339
  • Parameters:
334
- - `expression` (str): A series operation expression. Supports operations such as "+", "-", "*", "/", and `ddd()` for discrete differences.
340
+ - `expression` (str): A string of the homogeneous polynomial expression to solve.
341
+ - `variable` (str): The variable to solve for.
342
+ - `subs` (Optional[Dict[str, float]]): Substitutions for variables.
335
343
 
336
344
  • Returns:
337
- - `str`: The string representation of the resultant series after performing operations, or an error message if series lengths do not match.
345
+ - `str`: Solutions formatted in LaTeX.
338
346
 
339
347
  • Example:
340
348
 
341
- from rgwfuncs import compute_ordered_series_expression
349
+ from rgwfuncs import solve_homogeneous_polynomial_expression
350
+ solutions1 = solve_homogeneous_polynomial_expression("a*x**2 + b*x + c", "x", {"a": 3, "b": 7, "c": 5})
351
+ print(solutions1) # Output: "\left[-7/6 - sqrt(11)*I/6, -7/6 + sqrt(11)*I/6\right]"
342
352
 
343
- # Example with addition and discrete differences
344
- result = compute_ordered_series_expression("ddd([2, 6, 9, 60]) + ddd([78, 79, 80])")
345
- print(result) # Output: [4, 3, 51] + [1, 1]
353
+ solutions2 = solve_homogeneous_polynomial_expression("x**2 - 4", "x")
354
+ print(solutions2) # Output: "\left[-2, 2\right]"
346
355
 
347
- # Example with elementwise subtraction
348
- result = compute_ordered_series_expression("[10, 15, 21] - [5, 5, 5]")
349
- print(result) # Output: [5, 10, 16]
350
-
351
- # Example with length mismatch
352
- result = compute_ordered_series_expression("[4, 3, 51] + [1, 1]")
353
- print(result) # Output: Operations between ordered series must involve series of equal length
354
-
355
356
  --------------------------------------------------------------------------------
356
357
 
357
358
  ## String Based Functions
@@ -128,43 +128,27 @@ Print a list of available function names in alphabetical order. If a filter is p
128
128
 
129
129
  This section provides comprehensive functions for handling algebraic expressions, performing tasks such as computation, simplification, solving equations, and prime factorization, all outputted in LaTeX format.
130
130
 
131
- ### 1. `python_polynomial_expression_to_latex`
131
+ ### 1. `compute_prime_factors_latex`
132
132
 
133
- Converts a polynomial expression written in Python syntax to a LaTeX formatted string. This function parses algebraic expressions provided as strings using Python’s syntax and translates them into equivalent LaTeX representations, making them suitable for academic or professional documentation. The function supports inclusion of named variables, with an option to substitute specific values into the expression.
133
+ Computes prime factors of a number and presents them in LaTeX format.
134
134
 
135
135
  • Parameters:
136
- - `expression` (str): The algebraic expression to convert to LaTeX. This should be a string formatted with Python syntax acceptable by SymPy.
137
- - `subs` (Optional[Dict[str, float]]): An optional dictionary of substitutions where the keys are variable names in the expression, and the values are the numbers with which to substitute those variables.
136
+ - `n` (int): The integer to factorize.
138
137
 
139
138
  • Returns:
140
- - `str`: The LaTeX formatted string equivalent to the provided expression.
141
-
142
- • Raises:
143
- - `ValueError`: If the expression cannot be parsed due to syntax errors.
139
+ - `str`: Prime factorization in LaTeX.
144
140
 
145
141
  • Example:
146
142
 
147
- from rgwfuncs import python_polynomial_expression_to_latex
148
-
149
- # Convert a simple polynomial expression to LaTeX format
150
- latex_result1 = python_polynomial_expression_to_latex("x**2 + y**2")
151
- print(latex_result1) # Output: "x^{2} + y^{2}"
152
-
153
- # Convert polynomial expression with substituted values
154
- latex_result2 = python_polynomial_expression_to_latex("x**2 + y**2", {"x": 3, "y": 4})
155
- print(latex_result2) # Output: "25"
156
-
157
- # Another example with partial substitution
158
- latex_result3 = python_polynomial_expression_to_latex("x**2 + y**2", {"x": 3})
159
- print(latex_result3) # Output: "y^{2} + 9"
160
-
161
- # Trigonometric functions included with symbolic variables
162
- latex_result4 = python_polynomial_expression_to_latex("sin(x+z**2) + cos(y)", {"x": 55})
163
- print(latex_result4) # Output: "cos y + sin \\left(z^{2} + 55\\right)"
164
-
165
- # Simplified trigonometric functions example with substitution
166
- latex_result5 = python_polynomial_expression_to_latex("sin(x) + cos(y)", {"x": 0})
167
- print(latex_result5) # Output: "cos y"
143
+ from rgwfuncs import compute_prime_factors_latex
144
+ factors_1 = compute_prime_factors_latex(100)
145
+ print(factors_1) # Output: "2^{2} \cdot 5^{2}"
146
+
147
+ factors_2 = compute_prime_factors_latex(60)
148
+ print(factors_2) # Output: "2^{2} \cdot 3 \cdot 5"
149
+
150
+ factors_3 = compute_prime_factors_latex(17)
151
+ print(factors_3) # Output: "17"
168
152
 
169
153
  --------------------------------------------------------------------------------
170
154
 
@@ -192,140 +176,157 @@ Computes the numerical result of a given expression, which can evaluate to a con
192
176
 
193
177
  --------------------------------------------------------------------------------
194
178
 
195
- ### 3. `simplify_polynomial_expression`
179
+ ### 3. `compute_constant_expression_involving_matrices`
196
180
 
197
- Simplifies an algebraic expression in polynomial form and returns it in LaTeX format. Takes an algebraic expression, in polynomial form, written in Python syntax and simplifies it. The result is returned as a LaTeX formatted string, suitable for academic or professional documentation.
181
+ Computes the result of a constant expression involving matrices and returns it as a LaTeX string.
198
182
 
199
183
  • Parameters:
200
- - `expression` (str): The algebraic expression, in polynomial form, to simplify. For instance, the expression 'np.diff(8*x**30) where as 'np.diff([2,5,9,11)' is not a polynomial.
201
- - `subs` (Optional[Dict[str, float]]): An optional dictionary of substitutions where keys are variable names and values are the numbers to substitute them with.
184
+ - `expression` (str): The constant expression involving matrices. Example format includes operations such as "+", "-", "*", "/".
202
185
 
203
186
  • Returns:
204
- - `str`: The simplified expression formatted as a LaTeX string.
205
-
206
- • Example Usage:
187
+ - `str`: The LaTeX-formatted string representation of the computed matrix, or an error message if the operations cannot be performed due to dimensional mismatches.
207
188
 
208
- from rgwfuncs import simplify_polynomial_expression
189
+ Example:
209
190
 
210
- # Example 1: Simplifying a polynomial expression without substitutions
211
- simplified_expr1 = simplify_polynomial_expression("2*x + 3*x")
212
- print(simplified_expr1) # Output: "5 x"
191
+ from rgwfuncs import compute_constant_expression_involving_matrices
213
192
 
214
- # Example 2: Simplifying a complex expression involving derivatives
215
- simplified_expr2 = simplify_polynomial_expression("(np.diff(3*x**8)) / (np.diff(8*x**30) * 11*y**3)")
216
- print(simplified_expr2) # Output: r"\frac{1}{110 x^{22} y^{3}}"
193
+ # Example with addition of 2D matrices
194
+ result = compute_constant_expression_involving_matrices("[[2, 6, 9], [1, 3, 5]] + [[1, 2, 3], [4, 5, 6]]")
195
+ print(result) # Output: \begin{bmatrix}3 & 8 & 12\\5 & 8 & 11\end{bmatrix}
217
196
 
218
- # Example 3: Simplifying with substitutions
219
- simplified_expr3 = simplify_polynomial_expression("x**2 + y**2", subs={"x": 3, "y": 4})
220
- print(simplified_expr3) # Output: "25"
197
+ # Example of mixed operations with 1D matrices treated as 2D
198
+ result = compute_constant_expression_involving_matrices("[3, 6, 9] + [1, 2, 3] - [2, 2, 2]")
199
+ print(result) # Output: \begin{bmatrix}2 & 6 & 10\end{bmatrix}
221
200
 
222
- # Example 4: Simplifying with partial substitution
223
- simplified_expr4 = simplify_polynomial_expression("a*b + b", subs={"b": 2})
224
- print(simplified_expr4) # Output: "2 a + 2"
201
+ # Example with dimension mismatch
202
+ result = compute_constant_expression_involving_matrices("[[4, 3, 51]] + [[1, 1]]")
203
+ print(result) # Output: Operations between matrices must involve matrices of the same dimension
225
204
 
226
205
  --------------------------------------------------------------------------------
227
206
 
228
- ### 4. `solve_homogeneous_polynomial_expression`
207
+ ### 4. `compute_constant_expression_involving_ordered_series`
208
+
209
+ Computes the result of a constant expression involving ordered series, and returns it as a Latex string.
229
210
 
230
- Solves a homogeneous polynomial expression for a specified variable and returns solutions in LaTeX format. Assumes that the expression is homoegeneous (i.e. equal to zero), and solves for a designated variable. May optionally include substitutions for other variables in the equation. The solutions are provided as a LaTeX formatted string. The method solves equations for specified variables, with optional substitutions, returning LaTeX-formatted solutions.
231
211
 
232
212
  • Parameters:
233
- - `expression` (str): A string of the homogeneous polynomial expression to solve.
234
- - `variable` (str): The variable to solve for.
235
- - `subs` (Optional[Dict[str, float]]): Substitutions for variables.
213
+ - `expression` (str): A series operation expression. Supports operations such as "+", "-", "*", "/", and `dd()` for discrete differences.
236
214
 
237
215
  • Returns:
238
- - `str`: Solutions formatted in LaTeX.
216
+ - `str`: The string representation of the resultant series after performing operations, or an error message if series lengths do not match.
239
217
 
240
218
  • Example:
241
219
 
242
- from rgwfuncs import solve_homogeneous_polynomial_expression
243
- solutions1 = solve_homogeneous_polynomial_expression("a*x**2 + b*x + c", "x", {"a": 3, "b": 7, "c": 5})
244
- print(solutions1) # Output: "\left[-7/6 - sqrt(11)*I/6, -7/6 + sqrt(11)*I/6\right]"
220
+ from rgwfuncs import compute_constant_expression_involving_ordered_series
221
+
222
+ # Example with addition and discrete differences
223
+ result = compute_constant_expression_involving_ordered_series("dd([2, 6, 9, 60]) + dd([78, 79, 80])")
224
+ print(result) # Output: [4, 3, 51] + [1, 1]
225
+
226
+ # Example with elementwise subtraction
227
+ result = compute_constant_expression_involving_ordered_series("[10, 15, 21] - [5, 5, 5]")
228
+ print(result) # Output: [5, 10, 16]
229
+
230
+ # Example with length mismatch
231
+ result = compute_constant_expression_involving_ordered_series("[4, 3, 51] + [1, 1]")
232
+ print(result) # Output: Operations between ordered series must involve series of equal length
245
233
 
246
- solutions2 = solve_homogeneous_polynomial_expression("x**2 - 4", "x")
247
- print(solutions2) # Output: "\left[-2, 2\right]"
248
-
249
234
  --------------------------------------------------------------------------------
250
235
 
251
- ### 5. `get_prime_factors_latex`
236
+ ### 5. `python_polynomial_expression_to_latex`
252
237
 
253
- Computes prime factors of a number and presents them in LaTeX format.
238
+ Converts a polynomial expression written in Python syntax to a LaTeX formatted string. This function parses algebraic expressions provided as strings using Python’s syntax and translates them into equivalent LaTeX representations, making them suitable for academic or professional documentation. The function supports inclusion of named variables, with an option to substitute specific values into the expression.
254
239
 
255
240
  • Parameters:
256
- - `n` (int): The integer to factorize.
241
+ - `expression` (str): The algebraic expression to convert to LaTeX. This should be a string formatted with Python syntax acceptable by SymPy.
242
+ - `subs` (Optional[Dict[str, float]]): An optional dictionary of substitutions where the keys are variable names in the expression, and the values are the numbers with which to substitute those variables.
257
243
 
258
244
  • Returns:
259
- - `str`: Prime factorization in LaTeX.
245
+ - `str`: The LaTeX formatted string equivalent to the provided expression.
260
246
 
261
- Example:
247
+ Raises:
248
+ - `ValueError`: If the expression cannot be parsed due to syntax errors.
262
249
 
263
- from rgwfuncs import get_prime_factors_latex
264
- factors1 = get_prime_factors_latex(100)
265
- print(factors1) # Output: "2^{2} \cdot 5^{2}"
250
+ Example:
266
251
 
267
- factors2 = get_prime_factors_latex(60)
268
- print(factors2) # Output: "2^{2} \cdot 3 \cdot 5"
252
+ from rgwfuncs import python_polynomial_expression_to_latex
253
+
254
+ # Convert a simple polynomial expression to LaTeX format
255
+ latex_result1 = python_polynomial_expression_to_latex("x**2 + y**2")
256
+ print(latex_result1) # Output: "x^{2} + y^{2}"
257
+
258
+ # Convert polynomial expression with substituted values
259
+ latex_result2 = python_polynomial_expression_to_latex("x**2 + y**2", {"x": 3, "y": 4})
260
+ print(latex_result2) # Output: "25"
261
+
262
+ # Another example with partial substitution
263
+ latex_result3 = python_polynomial_expression_to_latex("x**2 + y**2", {"x": 3})
264
+ print(latex_result3) # Output: "y^{2} + 9"
265
+
266
+ # Trigonometric functions included with symbolic variables
267
+ latex_result4 = python_polynomial_expression_to_latex("sin(x+z**2) + cos(y)", {"x": 55})
268
+ print(latex_result4) # Output: "cos y + sin \\left(z^{2} + 55\\right)"
269
+
270
+ # Simplified trigonometric functions example with substitution
271
+ latex_result5 = python_polynomial_expression_to_latex("sin(x) + cos(y)", {"x": 0})
272
+ print(latex_result5) # Output: "cos y"
269
273
 
270
- factors3 = get_prime_factors_latex(17)
271
- print(factors3) # Output: "17"
272
-
273
274
  --------------------------------------------------------------------------------
274
275
 
275
- ### 6. `compute_matrix_expression`
276
+ ### 6. `simplify_polynomial_expression`
276
277
 
277
- Computes the results of expressions containing 1D or 2D matrix operations and formats them as LaTeX strings.
278
+ Simplifies an algebraic expression in polynomial form and returns it in LaTeX format. Takes an algebraic expression, in polynomial form, written in Python syntax and simplifies it. The result is returned as a LaTeX formatted string, suitable for academic or professional documentation.
278
279
 
279
280
  • Parameters:
280
- - `expression` (str): A string representing a sequence of matrix operations involving either 1D or 2D lists. Supported operations include addition (`+`), subtraction (`-`), multiplication (`*`), and division (`/`).
281
+ - `expression` (str): The algebraic expression, in polynomial form, to simplify. For instance, the expression 'np.diff(8*x**30) where as 'np.diff([2,5,9,11)' is not a polynomial.
282
+ - `subs` (Optional[Dict[str, float]]): An optional dictionary of substitutions where keys are variable names and values are the numbers to substitute them with.
281
283
 
282
284
  • Returns:
283
- - `str`: The LaTeX-formatted string representation of the computed matrix, or an error message if the operations cannot be performed due to dimensional mismatches.
285
+ - `str`: The simplified expression formatted as a LaTeX string.
284
286
 
285
- • Example:
287
+ • Example Usage:
286
288
 
287
- from rgwfuncs import compute_matrix_expression
288
-
289
- # Example with addition of 2D matrices
290
- result = compute_matrix_expression("[[2, 6, 9], [1, 3, 5]] + [[1, 2, 3], [4, 5, 6]]")
291
- print(result) # Output: \begin{bmatrix}3 & 8 & 12\\5 & 8 & 11\end{bmatrix}
292
-
293
- # Example of mixed operations with 1D matrices treated as 2D
294
- result = compute_matrix_expression("[3, 6, 9] + [1, 2, 3] - [2, 2, 2]")
295
- print(result) # Output: \begin{bmatrix}2 & 6 & 10\end{bmatrix}
289
+ from rgwfuncs import simplify_polynomial_expression
296
290
 
297
- # Example with dimension mismatch
298
- result = compute_matrix_expression("[[4, 3, 51]] + [[1, 1]]")
299
- print(result) # Output: Operations between matrices must involve matrices of the same dimension
291
+ # Example 1: Simplifying a polynomial expression without substitutions
292
+ simplified_expr1 = simplify_polynomial_expression("2*x + 3*x")
293
+ print(simplified_expr1) # Output: "5 x"
294
+
295
+ # Example 2: Simplifying a complex expression involving derivatives
296
+ simplified_expr2 = simplify_polynomial_expression("(np.diff(3*x**8)) / (np.diff(8*x**30) * 11*y**3)")
297
+ print(simplified_expr2) # Output: r"\frac{1}{110 x^{22} y^{3}}"
298
+
299
+ # Example 3: Simplifying with substitutions
300
+ simplified_expr3 = simplify_polynomial_expression("x**2 + y**2", subs={"x": 3, "y": 4})
301
+ print(simplified_expr3) # Output: "25"
302
+
303
+ # Example 4: Simplifying with partial substitution
304
+ simplified_expr4 = simplify_polynomial_expression("a*b + b", subs={"b": 2})
305
+ print(simplified_expr4) # Output: "2 a + 2"
300
306
 
301
307
  --------------------------------------------------------------------------------
302
308
 
303
- ### 7. `compute_ordered_series_expression`
309
+ ### 7. `solve_homogeneous_polynomial_expression`
304
310
 
305
- Computes the result of expressions containing operations on ordered series expressed as 1D lists. The syntax of the expression supports the discrete difference operator via the `ddd()` method.
311
+ Solves a homogeneous polynomial expression for a specified variable and returns solutions in LaTeX format. Assumes that the expression is homoegeneous (i.e. equal to zero), and solves for a designated variable. May optionally include substitutions for other variables in the equation. The solutions are provided as a LaTeX formatted string. The method solves equations for specified variables, with optional substitutions, returning LaTeX-formatted solutions.
306
312
 
307
313
  • Parameters:
308
- - `expression` (str): A series operation expression. Supports operations such as "+", "-", "*", "/", and `ddd()` for discrete differences.
314
+ - `expression` (str): A string of the homogeneous polynomial expression to solve.
315
+ - `variable` (str): The variable to solve for.
316
+ - `subs` (Optional[Dict[str, float]]): Substitutions for variables.
309
317
 
310
318
  • Returns:
311
- - `str`: The string representation of the resultant series after performing operations, or an error message if series lengths do not match.
319
+ - `str`: Solutions formatted in LaTeX.
312
320
 
313
321
  • Example:
314
322
 
315
- from rgwfuncs import compute_ordered_series_expression
323
+ from rgwfuncs import solve_homogeneous_polynomial_expression
324
+ solutions1 = solve_homogeneous_polynomial_expression("a*x**2 + b*x + c", "x", {"a": 3, "b": 7, "c": 5})
325
+ print(solutions1) # Output: "\left[-7/6 - sqrt(11)*I/6, -7/6 + sqrt(11)*I/6\right]"
316
326
 
317
- # Example with addition and discrete differences
318
- result = compute_ordered_series_expression("ddd([2, 6, 9, 60]) + ddd([78, 79, 80])")
319
- print(result) # Output: [4, 3, 51] + [1, 1]
327
+ solutions2 = solve_homogeneous_polynomial_expression("x**2 - 4", "x")
328
+ print(solutions2) # Output: "\left[-2, 2\right]"
320
329
 
321
- # Example with elementwise subtraction
322
- result = compute_ordered_series_expression("[10, 15, 21] - [5, 5, 5]")
323
- print(result) # Output: [5, 10, 16]
324
-
325
- # Example with length mismatch
326
- result = compute_ordered_series_expression("[4, 3, 51] + [1, 1]")
327
- print(result) # Output: Operations between ordered series must involve series of equal length
328
-
329
330
  --------------------------------------------------------------------------------
330
331
 
331
332
  ## String Based Functions
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rgwfuncs"
7
- version = "0.0.30"
7
+ version = "0.0.32"
8
8
  authors = [
9
9
  { name = "Ryan Gerard Wilson", email = "ryangerardwilson@gmail.com" },
10
10
  ]
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = rgwfuncs
3
- version = 0.0.30
3
+ version = 0.0.32
4
4
  author = Ryan Gerard Wilson
5
5
  author_email = ryangerardwilson@gmail.com
6
6
  description = A functional programming paradigm for mathematical modelling and data science