https://github.com/yairchu/quartic
Solve Quartic equations. Implementations in C, Haskell, and Python
https://github.com/yairchu/quartic
math polynomials
Last synced: 11 months ago
JSON representation
Solve Quartic equations. Implementations in C, Haskell, and Python
- Host: GitHub
- URL: https://github.com/yairchu/quartic
- Owner: yairchu
- License: other
- Created: 2011-10-31T22:50:56.000Z (over 14 years ago)
- Default Branch: main
- Last Pushed: 2023-06-12T09:04:16.000Z (about 3 years ago)
- Last Synced: 2025-04-13T11:49:07.886Z (about 1 year ago)
- Topics: math, polynomials
- Language: C
- Homepage:
- Size: 34.2 KB
- Stars: 9
- Watchers: 2
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
# Quartic
Solve Quartic equations (4th degree polynomials) in C, Haskell, and Python.
License: BSD.
(Also solves cubic, quadratic, and linear equations)
The implementations are very close in their structure/design.
Naturally, the Haskell and Python implementations are much shorter than the C implementation.
## C implementation
There's one implementation for complex numbers, and another for real numbers (`double`), which only finds real roots.
## Haskell implementation
This implementation is generic and should work for finite fields too (I think).
### Note about Cubic equations
The solving of cubic equations only finds one root.
Finding all three roots for `Complex Double`s isn't hard but I wanted to keep the code generic.
For that a type-class providing primitive roots of unity would be required.
The class providing the primitive square root of unity, `(-1)`, exists in Haskell and it is `Floating`, but here we would need a primitive cubic root of unity..
## Python implementation
Numpy already has a built-in roots function, so this implementation isn't necessary.
It was only made for comparison with the others.
Also consider https://github.com/NKrvavica/fqs if you require a faster implementation than numpy.