Compare commits

...

4 Commits

Author SHA1 Message Date
ac591f49ec docs: Added documentation for nth_derivative function
All checks were successful
Run Python Tests / test (3.12) (pull_request) Successful in 10s
Run Python Tests / test (3.10) (pull_request) Successful in 13s
Run Python Tests / test (3.8) (pull_request) Successful in 10s
2025-06-17 14:35:03 -04:00
ec97aefee1 feat: Added nth derivative showcase in __main__ 2025-06-17 14:34:16 -04:00
d27497488f fix: differential in README.md renamed to derivative 2025-06-17 14:30:40 -04:00
41daf4f7e0 Remove CONTRIBUTORS.md 2025-06-17 14:30:11 -04:00
3 changed files with 12 additions and 13 deletions

View File

@ -1,10 +0,0 @@
## Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
[![All Contributors](https://img.shields.io/github/all-contributors/jono-rams/PolySolve?color=ee8449&style=flat-square)](#contributors)
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->

View File

@ -56,17 +56,22 @@ print(f"Value of f1 at x=5 is: {y_val}")
# > Value of f1 at x=5 is: 30.0 # > Value of f1 at x=5 is: 30.0
# 3. Get the derivative: 4x - 3 # 3. Get the derivative: 4x - 3
df1 = f1.differential() df1 = f1.derivative()
print(f"Derivative of f1: {df1}") print(f"Derivative of f1: {df1}")
# > Derivative of f1: 4x - 3 # > Derivative of f1: 4x - 3
# 4. Find roots analytically using the quadratic formula # 4. Get the 2nd derivative: 4
df1 = f1.nth_derivative(2)
print(f"2nd Derivative of f1: {df1}")
# > Derivative of f1: 4
# 5. Find roots analytically using the quadratic formula
# This is exact and fast for degree-2 polynomials. # This is exact and fast for degree-2 polynomials.
roots_analytic = quadratic_solve(f1) roots_analytic = quadratic_solve(f1)
print(f"Analytic roots: {sorted(roots_analytic)}") print(f"Analytic roots: {sorted(roots_analytic)}")
# > Analytic roots: [-1.0, 2.5] # > Analytic roots: [-1.0, 2.5]
# 5. Find roots with the genetic algorithm (CPU) # 6. Find roots with the genetic algorithm (CPU)
# This can solve polynomials of any degree. # This can solve polynomials of any degree.
ga_opts = GA_Options(num_of_generations=20) ga_opts = GA_Options(num_of_generations=20)
roots_ga = f1.get_real_roots(ga_opts, use_cuda=False) roots_ga = f1.get_real_roots(ga_opts, use_cuda=False)

View File

@ -488,6 +488,10 @@ if __name__ == '__main__':
df1 = f1.derivative() df1 = f1.derivative()
print(f"Derivative of f1: {df1}") print(f"Derivative of f1: {df1}")
# Find the second derivative: 4
ddf1 = f1.nth_derivative(2)
print(f"Second derivative of f1: {ddf1}")
# --- Root Finding --- # --- Root Finding ---
# 1. Analytical solution for quadratic # 1. Analytical solution for quadratic
roots_analytic = quadratic_solve(f1) roots_analytic = quadratic_solve(f1)