polysolve 0.6.2__tar.gz → 0.7.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polysolve
3
- Version: 0.6.2
3
+ Version: 0.7.0
4
4
  Summary: A Python library for representing, manipulating, and solving exponential functions using analytical methods and genetic algorithms, with optional CUDA acceleration.
5
5
  Author-email: Jonathan Rampersad <jonathan@jono-rams.work>
6
6
  License: MIT License
@@ -64,6 +64,7 @@ A Python library for representing, manipulating, and solving polynomial equation
64
64
  ## Key Features
65
65
 
66
66
  * **Numerically Stable Solver**: Makes complex calculations **practical**. Leverage your GPU to power the robust genetic algorithm, solving high-degree polynomials accurately in a reasonable timeframe.
67
+ * **Complex Number Support**: Fully supports complex coefficients and finding roots in the complex plane (e.g., $x^2 + 1 = 0 \to \pm i$).
67
68
  * **Numba Accelerated CPU Solver**: The default genetic algorithm is JIT-compiled with Numba for high-speed CPU performance, right out of the box.
68
69
  * **CUDA Accelerated**: Leverage NVIDIA GPUs for a massive performance boost when finding roots in large solution spaces.
69
70
  * **Create and Manipulate Polynomials**: Easily define polynomials of any degree using integer or float coefficients, and perform arithmetic operations like addition, subtraction, multiplication, and scaling.
@@ -127,12 +128,19 @@ roots_analytic = f1.quadratic_solve()
127
128
  print(f"Analytic roots: {sorted(roots_analytic)}")
128
129
  # > Analytic roots: [-1.0, 2.5]
129
130
 
130
- # 6. Find roots with the genetic algorithm (Numba CPU)
131
- #    This is the default, JIT-compiled CPU solver.
131
+ # 6. Find REAL roots with the genetic algorithm (Numba CPU)
132
+ # This is the default, JIT-compiled CPU solver.
132
133
  ga_opts = GA_Options(num_of_generations=20)
133
134
  roots_ga = f1.get_real_roots(ga_opts, use_cuda=False)
134
- print(f"Approximate roots from GA: {roots_ga[:2]}")
135
- # > Approximate roots from GA: [-1.000..., 2.500...]
135
+ print(f"Approximate real roots: {roots_ga[:2]}")
136
+ # > Approximate real roots: [-1.000..., 2.500...]
137
+
138
+ # 7. Find ALL roots (Real + Complex)
139
+ # Use get_roots() to search the complex plane.
140
+ f_complex = Function(2, [1, 0, 1]) # x^2 + 1
141
+ roots_all = f_complex.get_roots(ga_opts)
142
+ print(f"Approximate complex roots: {roots_all}")
143
+ # > Approximate complex roots: [-1.00...j, 1.00...j]
136
144
 
137
145
  # If you installed a CUDA extra, you can run it on the GPU:
138
146
  # roots_ga_gpu = f1.get_real_roots(ga_opts, use_cuda=True)
@@ -166,7 +174,10 @@ ga_robust_search = GA_Options(
166
174
  # Increase the crossover blend factor to 0.75.
167
175
  # This allows new solutions to be created further
168
176
  # away from their parents, increasing exploration.
169
- blend_alpha=0.75
177
+ blend_alpha=0.75,
178
+
179
+ # Enable complex root finding (default is True)
180
+ find_complex=True
170
181
  )
171
182
 
172
183
  # Pass the custom options to the solver
@@ -12,6 +12,7 @@ A Python library for representing, manipulating, and solving polynomial equation
12
12
  ## Key Features
13
13
 
14
14
  * **Numerically Stable Solver**: Makes complex calculations **practical**. Leverage your GPU to power the robust genetic algorithm, solving high-degree polynomials accurately in a reasonable timeframe.
15
+ * **Complex Number Support**: Fully supports complex coefficients and finding roots in the complex plane (e.g., $x^2 + 1 = 0 \to \pm i$).
15
16
  * **Numba Accelerated CPU Solver**: The default genetic algorithm is JIT-compiled with Numba for high-speed CPU performance, right out of the box.
16
17
  * **CUDA Accelerated**: Leverage NVIDIA GPUs for a massive performance boost when finding roots in large solution spaces.
17
18
  * **Create and Manipulate Polynomials**: Easily define polynomials of any degree using integer or float coefficients, and perform arithmetic operations like addition, subtraction, multiplication, and scaling.
@@ -75,12 +76,19 @@ roots_analytic = f1.quadratic_solve()
75
76
  print(f"Analytic roots: {sorted(roots_analytic)}")
76
77
  # > Analytic roots: [-1.0, 2.5]
77
78
 
78
- # 6. Find roots with the genetic algorithm (Numba CPU)
79
- #    This is the default, JIT-compiled CPU solver.
79
+ # 6. Find REAL roots with the genetic algorithm (Numba CPU)
80
+ # This is the default, JIT-compiled CPU solver.
80
81
  ga_opts = GA_Options(num_of_generations=20)
81
82
  roots_ga = f1.get_real_roots(ga_opts, use_cuda=False)
82
- print(f"Approximate roots from GA: {roots_ga[:2]}")
83
- # > Approximate roots from GA: [-1.000..., 2.500...]
83
+ print(f"Approximate real roots: {roots_ga[:2]}")
84
+ # > Approximate real roots: [-1.000..., 2.500...]
85
+
86
+ # 7. Find ALL roots (Real + Complex)
87
+ # Use get_roots() to search the complex plane.
88
+ f_complex = Function(2, [1, 0, 1]) # x^2 + 1
89
+ roots_all = f_complex.get_roots(ga_opts)
90
+ print(f"Approximate complex roots: {roots_all}")
91
+ # > Approximate complex roots: [-1.00...j, 1.00...j]
84
92
 
85
93
  # If you installed a CUDA extra, you can run it on the GPU:
86
94
  # roots_ga_gpu = f1.get_real_roots(ga_opts, use_cuda=True)
@@ -114,7 +122,10 @@ ga_robust_search = GA_Options(
114
122
  # Increase the crossover blend factor to 0.75.
115
123
  # This allows new solutions to be created further
116
124
  # away from their parents, increasing exploration.
117
- blend_alpha=0.75
125
+ blend_alpha=0.75,
126
+
127
+ # Enable complex root finding (default is True)
128
+ find_complex=True
118
129
  )
119
130
 
120
131
  # Pass the custom options to the solver
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  # --- Core Metadata ---
7
7
  name = "polysolve"
8
- version = "0.6.2"
8
+ version = "0.7.0"
9
9
  authors = [
10
10
  { name="Jonathan Rampersad", email="jonathan@jono-rams.work" },
11
11
  ]