cubicequation


Namecubicequation JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryA Python module for the exact solutions of a cubic equation
upload_time2024-11-05 16:56:46
maintainerNone
docs_urlNone
authorGien van den Enden
requires_python>=3.11
licenseGNU General Public License v3 or later (GPLv3+)
keywords cubic equation math symbolic
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python cubic equation solver for exact values

A Python module for the exact solutions of a cubic equation: a x^3 + b x^2 + c x + d = 0

## Usage

### Calculate cubic solution
The solutions are three symexpress3 objects: x1Optimized, x2Optimized, x3Optimized
```py
>>> import cubicequation
>>> objCubic = cubicequation.CubicEquation()
>>> objCubic.a = "1"
>>> objCubic.b = "2"
>>> objCubic.c = "3"
>>> objCubic.d = "4"
>>> objCubic.calcSolutions()
>>> print( f"x1: {objCubic.x1Optimized}\nx2: {objCubic.x2Optimized}\nx3: {objCubic.x3Optimized}\n" )
x1: (-2/3) + (15 * 6^^(1/2) + 35)^^(1/3) * (-1/3) + (1/3) * (15 * 6^^(1/2) + (-35))^^(1/3)
x2: (-2/3) + (1/6) * (15 * 6^^(1/2) + 35)^^(1/3) + (-1/6) * (15 * 6^^(1/2) + 35)^^(1/3) * i * 3^^(1/2) + (-1/6) * i * 3^^(1/2) * (15 * 6^^(1/2) + (-35))^^(1/3) + (-1/6) * (15 * 6^^(1/2) + (-35))^^(1/3)
x3: (-2/3) + (15 * 6^^(1/2) + 35)^^(1/3) * (1/6) + (15 * 6^^(1/2) + 35)^^(1/3) * i * 3^^(1/2) * (1/6) + (1/6) * i * 3^^(1/2) * (15 * 6^^(1/2) + (-35))^^(1/3) + (-1/6) * (15 * 6^^(1/2) + (-35))^^(1/3)
```

### Numeric input values
The parameters may be real numbers or symexpress3 strings
```py
>>> import cubicequation
>>> objCubic = cubicequation.CubicEquation()
>>> objCubic.a = 1.10
>>> objCubic.b = 2.25
>>> objCubic.c = "2 + 1 + 3"
>>> objCubic.d = "4/2"
>>> objCubic.calcSolutions()
>>> print( f"x1: {objCubic.x1Optimized}\nx2: {objCubic.x2Optimized}\nx3: {objCubic.x3Optimized}\n" )
x1: (-15/22) + (-5/11) * ((11/25) * (3373/2)^^(1/2) + (-1349/200))^^(1/3) + (5/11) * ((11/25) * (3373/2)^^(1/2) + (1349/200))^^(1/3)
x2: (-15/22) + (5/22) * ((11/25) * (3373/2)^^(1/2) + (-1349/200))^^(1/3) + (-5/22) * i * 3^^(1/2) * ((11/25) * (3373/2)^^(1/2) + (-1349/200))^^(1/3) + (-5/22) * i * 3^^(1/2) * ((11/25) * (3373/2)^^(1/2) + (1349/200))^^(1/3) + (-5/22) * ((11/25) * (3373/2)^^(1/2) + (1349/200))^^(1/3)
x3: (-15/22) + (5/22) * ((11/25) * (3373/2)^^(1/2) + (-1349/200))^^(1/3) + (5/22) * i * 3^^(1/2) * ((11/25) * (3373/2)^^(1/2) + (-1349/200))^^(1/3) + (5/22) * i * 3^^(1/2) * ((11/25) * (3373/2)^^(1/2) + (1349/200))^^(1/3) + (-5/22) * ((11/25) * (3373/2)^^(1/2) + (1349/200))^^(1/3)
```

### Calculate real values
```py
>>> import cubicequation
>>> objCubic = cubicequation.CubicEquation()
>>> objCubic.a = 1.10
>>> objCubic.b = 2.25
>>> objCubic.c = "2 + 1 + 3"
>>> objCubic.d = "4/2"
>>> objCubic.calcSolutions()
>>> print( f"x1: {objCubic.x1Value}\nx2: {objCubic.x2Value}\nx3: {objCubic.x3Value}\n" )
x1: -0.3767589142748171
x2: (-0.8343478155898642-2.0321695851742962j)
x3: (-0.8343478155898642+2.0321695851742962j)
```

### Example optimized exact values
```py
>>> import cubicequation
>>> objCubic = cubicequation.CubicEquation()
>>> objCubic.a = 1
>>> objCubic.b = 6
>>> objCubic.c = 11
>>> objCubic.d = 6
>>> objCubic.calcSolutions()
>>> print( f"x1: {objCubic.x1Optimized}\nx2: {objCubic.x2Optimized}\nx3: {objCubic.x3Optimized}\n" )
x1: (-3)
x2: (-1)
x3: (-2)
```

### Command line
python -m cubicequation

- *Help*: python -m cubicequation  -h
- *Cubic solution*: python -m cubicequation 1 2 3 4

### Graphical user interface
https://github.com/SWVandenEnden/websym3

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cubicequation",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "Gien van den Enden <swvandenenden@gmail.com>",
    "keywords": "cubic equation, math, symbolic",
    "author": "Gien van den Enden",
    "author_email": "swvandenenden@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9d/c1/21bd8e704286cf1c1c2ff359cf80a376fbb1046bc920199cac38579a5175/cubicequation-0.0.2.tar.gz",
    "platform": null,
    "description": "# Python cubic equation solver for exact values\n\nA Python module for the exact solutions of a cubic equation: a x^3 + b x^2 + c x + d = 0\n\n## Usage\n\n### Calculate cubic solution\nThe solutions are three symexpress3 objects: x1Optimized, x2Optimized, x3Optimized\n```py\n>>> import cubicequation\n>>> objCubic = cubicequation.CubicEquation()\n>>> objCubic.a = \"1\"\n>>> objCubic.b = \"2\"\n>>> objCubic.c = \"3\"\n>>> objCubic.d = \"4\"\n>>> objCubic.calcSolutions()\n>>> print( f\"x1: {objCubic.x1Optimized}\\nx2: {objCubic.x2Optimized}\\nx3: {objCubic.x3Optimized}\\n\" )\nx1: (-2/3) + (15 * 6^^(1/2) + 35)^^(1/3) * (-1/3) + (1/3) * (15 * 6^^(1/2) + (-35))^^(1/3)\nx2: (-2/3) + (1/6) * (15 * 6^^(1/2) + 35)^^(1/3) + (-1/6) * (15 * 6^^(1/2) + 35)^^(1/3) * i * 3^^(1/2) + (-1/6) * i * 3^^(1/2) * (15 * 6^^(1/2) + (-35))^^(1/3) + (-1/6) * (15 * 6^^(1/2) + (-35))^^(1/3)\nx3: (-2/3) + (15 * 6^^(1/2) + 35)^^(1/3) * (1/6) + (15 * 6^^(1/2) + 35)^^(1/3) * i * 3^^(1/2) * (1/6) + (1/6) * i * 3^^(1/2) * (15 * 6^^(1/2) + (-35))^^(1/3) + (-1/6) * (15 * 6^^(1/2) + (-35))^^(1/3)\n```\n\n### Numeric input values\nThe parameters may be real numbers or symexpress3 strings\n```py\n>>> import cubicequation\n>>> objCubic = cubicequation.CubicEquation()\n>>> objCubic.a = 1.10\n>>> objCubic.b = 2.25\n>>> objCubic.c = \"2 + 1 + 3\"\n>>> objCubic.d = \"4/2\"\n>>> objCubic.calcSolutions()\n>>> print( f\"x1: {objCubic.x1Optimized}\\nx2: {objCubic.x2Optimized}\\nx3: {objCubic.x3Optimized}\\n\" )\nx1: (-15/22) + (-5/11) * ((11/25) * (3373/2)^^(1/2) + (-1349/200))^^(1/3) + (5/11) * ((11/25) * (3373/2)^^(1/2) + (1349/200))^^(1/3)\nx2: (-15/22) + (5/22) * ((11/25) * (3373/2)^^(1/2) + (-1349/200))^^(1/3) + (-5/22) * i * 3^^(1/2) * ((11/25) * (3373/2)^^(1/2) + (-1349/200))^^(1/3) + (-5/22) * i * 3^^(1/2) * ((11/25) * (3373/2)^^(1/2) + (1349/200))^^(1/3) + (-5/22) * ((11/25) * (3373/2)^^(1/2) + (1349/200))^^(1/3)\nx3: (-15/22) + (5/22) * ((11/25) * (3373/2)^^(1/2) + (-1349/200))^^(1/3) + (5/22) * i * 3^^(1/2) * ((11/25) * (3373/2)^^(1/2) + (-1349/200))^^(1/3) + (5/22) * i * 3^^(1/2) * ((11/25) * (3373/2)^^(1/2) + (1349/200))^^(1/3) + (-5/22) * ((11/25) * (3373/2)^^(1/2) + (1349/200))^^(1/3)\n```\n\n### Calculate real values\n```py\n>>> import cubicequation\n>>> objCubic = cubicequation.CubicEquation()\n>>> objCubic.a = 1.10\n>>> objCubic.b = 2.25\n>>> objCubic.c = \"2 + 1 + 3\"\n>>> objCubic.d = \"4/2\"\n>>> objCubic.calcSolutions()\n>>> print( f\"x1: {objCubic.x1Value}\\nx2: {objCubic.x2Value}\\nx3: {objCubic.x3Value}\\n\" )\nx1: -0.3767589142748171\nx2: (-0.8343478155898642-2.0321695851742962j)\nx3: (-0.8343478155898642+2.0321695851742962j)\n```\n\n### Example optimized exact values\n```py\n>>> import cubicequation\n>>> objCubic = cubicequation.CubicEquation()\n>>> objCubic.a = 1\n>>> objCubic.b = 6\n>>> objCubic.c = 11\n>>> objCubic.d = 6\n>>> objCubic.calcSolutions()\n>>> print( f\"x1: {objCubic.x1Optimized}\\nx2: {objCubic.x2Optimized}\\nx3: {objCubic.x3Optimized}\\n\" )\nx1: (-3)\nx2: (-1)\nx3: (-2)\n```\n\n### Command line\npython -m cubicequation\n\n- *Help*: python -m cubicequation  -h\n- *Cubic solution*: python -m cubicequation 1 2 3 4\n\n### Graphical user interface\nhttps://github.com/SWVandenEnden/websym3\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 or later (GPLv3+)",
    "summary": "A Python module for the exact solutions of a cubic equation",
    "version": "0.0.2",
    "project_urls": {
        "Source Code": "https://github.com/SWVandenEnden/cubicequation"
    },
    "split_keywords": [
        "cubic equation",
        " math",
        " symbolic"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0966324dcb75669c2ce3854fab88a8abb96321cd0f1b0db9178823795204f4f3",
                "md5": "e1fc4e275b0d48e28b12c360516ad5a0",
                "sha256": "2db2e420d3f6e3e9371eccb85a1a64acb0058f23fab1191a3ab3943e2ecf2c38"
            },
            "downloads": -1,
            "filename": "cubicequation-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e1fc4e275b0d48e28b12c360516ad5a0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 20196,
            "upload_time": "2024-11-05T16:56:42",
            "upload_time_iso_8601": "2024-11-05T16:56:42.855038Z",
            "url": "https://files.pythonhosted.org/packages/09/66/324dcb75669c2ce3854fab88a8abb96321cd0f1b0db9178823795204f4f3/cubicequation-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9dc121bd8e704286cf1c1c2ff359cf80a376fbb1046bc920199cac38579a5175",
                "md5": "e813a39e0250820dbfe79b71bb4134fd",
                "sha256": "eacc4b9d71ec5e0eeddbd12251b515ebbe41c8f7d1707de3afe5673d699545fa"
            },
            "downloads": -1,
            "filename": "cubicequation-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "e813a39e0250820dbfe79b71bb4134fd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 26927,
            "upload_time": "2024-11-05T16:56:46",
            "upload_time_iso_8601": "2024-11-05T16:56:46.581264Z",
            "url": "https://files.pythonhosted.org/packages/9d/c1/21bd8e704286cf1c1c2ff359cf80a376fbb1046bc920199cac38579a5175/cubicequation-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-05 16:56:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SWVandenEnden",
    "github_project": "cubicequation",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cubicequation"
}
        
Elapsed time: 0.37155s