Skip to main content

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 four 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}\nx4: {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)
x4: (-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

>>> 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}\nx4: {objQuartic.x4Optimized}\n" )
x1: 5
x2: 3
x3: 13
x4: 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)

Command line

python -m quarticequation

  • Help: python -m quarticequation -h
  • Quartic solution: python -m quarticequation 1 2 3 4 5

Graphical user interface

https://github.com/SWVandenEnden/websym3

Project details


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.3.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quarticequation-0.0.3-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file quarticequation-0.0.3.tar.gz.

File metadata

  • Download URL: quarticequation-0.0.3.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for quarticequation-0.0.3.tar.gz
Algorithm Hash digest
SHA256 17d9a1550bb957f627f7e8e2c70a972f5cb4f3d527e5056edb743b3b2ca4a50e
MD5 51f0a41c47d9290f60d50af5604a77c8
BLAKE2b-256 9ce16dfecc108f4e358b94ebda5eb5401dde1acbc0fcf68df89c82807cebacdd

See more details on using hashes here.

File details

Details for the file quarticequation-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for quarticequation-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bcb5cf3e1a1b40c3e2a3bc33c860ea2228fbb793a30b1ff98e9d30ca75945262
MD5 2fe38be712e031f034ee88d6278e506e
BLAKE2b-256 e1c838690dd90a3ab7e706498e719a335cb75c0b80f418fc217ee396044b856b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page