A Python module for the exact solutions of a quartic equation
Project description
Python quartic equation solver for exact values
A Python module for the exact solutions of a quartic equation: a x^4 + b x^3 + c x^2 + d x + e = 0
Usage
Calculate quartic solution
The solutions are three symexpress3 objects: x1Optimized, x2Optimized, x3Optimized, x4Optimized
>>> import quarticequation
>>> objQuartic = quarticequation.QuarticEquation()
>>> objQuartic.a = "1"
>>> objQuartic.b = "2"
>>> objQuartic.c = "3"
>>> objQuartic.d = "4"
>>> objQuartic.e = "5"
>>> objQuartic.calcSolutions()
>>> print( f"x1: {objQuartic.x1Optimized}\nx2: {objQuartic.x2Optimized}\nx3: {objQuartic.x3Optimized}\nx3: {objQuartic.x4Optimized}\n" )
x1: (-1/2) + ((-1) + cos( (1/3) * atan( (1/2) ) ) * 15^^(1/2) + 5^^(1/2) * sin( (1/3) * atan( (1/2) ) ) * (-1))^^(1/2) * (-1/2) + (1/2) * ((-2) + ((-1) + cos( (1/3) * atan( (1/2) ) ) * 15^^(1/2) + 5^^(1/2) * sin( (1/3) * atan( (1/2) ) ) * (-1))^^(-1/2) * 4 + cos( (1/3) * atan( (1/2) ) ) * 15^^(1/2) * (-1) + 5^^(1/2) * sin( (1/3) * atan( (1/2) ) ))^^(1/2)
x2: (-1/2) + ((-1) + cos( (1/3) * atan( (1/2) ) ) * 15^^(1/2) + 5^^(1/2) * sin( (1/3) * atan( (1/2) ) ) * (-1))^^(1/2) * (-1/2) + ((-2) + ((-1) + cos( (1/3) * atan( (1/2) ) ) * 15^^(1/2) + 5^^(1/2) * sin( (1/3) * atan( (1/2) ) ) * (-1))^^(-1/2) * 4 + cos( (1/3) * atan( (1/2) ) ) * 15^^(1/2) * (-1) + 5^^(1/2) * sin( (1/3) * atan( (1/2) ) ))^^(1/2) * (-1/2)
x3: (-1/2) + (1/2) * ((-1) + cos( (1/3) * atan( (1/2) ) ) * 15^^(1/2) + 5^^(1/2) * sin( (1/3) * atan( (1/2) ) ) * (-1))^^(1/2) + (1/2) * ((-2) + (-4) * ((-1) + cos( (1/3) * atan( (1/2) ) ) * 15^^(1/2) + 5^^(1/2) * sin( (1/3) * atan( (1/2) ) ) * (-1))^^(-1/2) + cos( (1/3) * atan( (1/2) ) ) * 15^^(1/2) * (-1) + 5^^(1/2) * sin( (1/3) * atan( (1/2) ) ))^^(1/2)
x3: (-1/2) + (1/2) * ((-1) + cos( (1/3) * atan( (1/2) ) ) * 15^^(1/2) + 5^^(1/2) * sin( (1/3) * atan( (1/2) ) ) * (-1))^^(1/2) + ((-2) + (-4) * ((-1) + cos( (1/3) * atan( (1/2) ) ) * 15^^(1/2) + 5^^(1/2) * sin( (1/3) * atan( (1/2) ) ) * (-1))^^(-1/2) + cos( (1/3) * atan( (1/2) ) ) * 15^^(1/2) * (-1) + 5^^(1/2) * sin( (1/3) * atan( (1/2) ) ))^^(1/2) * (-1/2)```
### Numeric input values
The parameters may be real numbers or symexpress3 strings
```py
>>> import quarticequation
>>> objQuartic = quarticequation.QuarticEquation()
>>> objQuartic.a = 1.0
>>> objQuartic.b = -28
>>> objQuartic.c = "200 + 66"
>>> objQuartic.d = "-1028"
>>> objQuartic.e = "2730 / 2"
>>> objQuartic.calcSolutions()
>>> print( f"x1: {objQuartic.x1Optimized}\nx2: {objQuartic.x2Optimized}\nx3: {objQuartic.x3Optimized}\nx3: {objQuartic.x4Optimized}\n" )
x1: 5
x2: 3
x3: 13
x3: 7
Calculate real values
>>> import quarticequation
>>> objQuartic = quarticequation.QuarticEquation()
>>> objQuartic.a = 1
>>> objQuartic.b = 2
>>> objQuartic.c = 3
>>> objQuartic.d = 4
>>> objQuartic.e = 5
>>> objQuartic.calcSolutions()
>>> print( f"x1: {objQuartic.x1Value}\nx2: {objQuartic.x2Value}\nx3: {objQuartic.x3Value}\nx4: {objQuartic.x4Value}\n" )
x1: (-1.287815479557648+0.8578967583284903j)
x2: (-1.287815479557648-0.8578967583284903j)
x3: (0.2878154795576482+1.4160930801719078j)
x4: (0.28781547955764797-1.4160930801719078j)
Commandline
python -m quarticequation
- Help: python -m quarticequation -h
- Quartic solution: python -m quarticequation 1 2 3 4 5
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
quarticequation-0.0.1.tar.gz
(27.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quarticequation-0.0.1.tar.gz.
File metadata
- Download URL: quarticequation-0.0.1.tar.gz
- Upload date:
- Size: 27.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a1837bf875bf525e4224e9c1e33a23c3e85d9623e41adeeef94c710f990773f
|
|
| MD5 |
ac6949fa57bef2658f13826de58eddfd
|
|
| BLAKE2b-256 |
cf799503d0ee79be16b2eadee2a09ae3547a26a565c2b132c80cf57f27ac365e
|
File details
Details for the file quarticequation-0.0.1-py3-none-any.whl.
File metadata
- Download URL: quarticequation-0.0.1-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46bbae97aa342611ff5b870ef25416797e7855d9c5818800bd3c41a5647c71d9
|
|
| MD5 |
87dc5715ba9199a7659b59cb48cce853
|
|
| BLAKE2b-256 |
bf264b1f4f7fbfb55753be9207fcff0c36761141dfe92c13ec998dec0c403786
|