Solving a cubic equation using trigonometry « Next Oldest | Next Newest »

A while ago I've posted a program that uses ACOSH to solve a quadratic equation:

Recently I stumbled across a way to solve a cubic equation using trigonometry. Some of you might find that interesting as well.

Cheers

Thomas

Equations

A general cubic equation can be transformed to the following form using a substitution:



The trick is to use the following identity:



Here we set:



With the following substitution we can get a closed-form solution:







A similar formula can be found using the following identity:





Programs

``` 00 { 31-Byte Prgm }           00 { 34-Byte Prgm }
01>LBL "CuEq"                 01>LBL "CuEqH"
02 2                          02 2
03 /                          03 /
04 X<>Y                       04 X<>Y
05 -3                         05 3
06 /                          06 /
07 /                          07 /
08 LASTX                      08 LASTX
09 SQRT                       09 SQRT
10 /                          10 /
11 LASTX                      11 LASTX
12 X<>Y                       12 X<>Y
13 ASIN                       13 ASINH
14 3                          14 3
15 /                          15 /
16 SIN                        16 SINH
17 *                          17 *
18 2                          18 -2
19 *                          19 *
20 END                        20 END
```

Examples

x3 + 6x - 2 = 0

```CuEq:    3.27480002074E-1 i0
CuEqH:   3.27480002074E-1
```

x3 + 3x - 4 = 0

```CuEq:    1 i0
CuEqH:   1
```

References

Edited: 22 Mar 2011, 12:51 p.m. after one or more responses were posted

Thomas,

Very nice.

Worthy of an article?

- Pauli

Doesn't general cubic equation contain a squared element also?

Quote:
To solve the general cubic (1), it is reasonable to begin by attempting to eliminate the a2 term by making a substitution of the form .

This leads to formulas for p and q based upon ai.

Cheers

Thomas

Quote:
Doesn't general cubic equation contain a squared element also?

Indeed, the presented formula shows a "depressed cubic".

By the way, this was the basis for HP15C minichallenge: Impossibly Short

Thanks for pointing that out. The challenges of this forum are always a marvelous source of inspiration. However here's my source:

Mathematical Omnibus: Thirty Lectures on Classic Mathematics

Dmitry Fuchs, Serge Tabachnikov

Chapter 2. Equations

Lecture 4. Equations of Degree Three and Four

Though I haven't read the whole book yet I can only recommend it.

Best regards

Thomas

Last fall I spent much time studying the solution of polynomials, from cubic and up. I spent a lot time looking at the algorithms that solve general cubic polynomials. I used Matlab as the primary tool and then attempted to port solutions to Excel VBA and the HP41C.

I came to the conclusion that to solve cubic polynomials you best need a tool that automatically handles complex numbers. Matlab does that well and the graphing HP calculators too (although I only used PROOT to do that and wrote about it in the HP's SOLVE newsletter). The HP-42S is probably useful. J.M. Baillard has developed really cool HP41C programs that solve for the roots of polynomials (with real and complex coefficients. You can find them on this web site's HP41C program library section.

Namir

Quote:
I came to the conclusion that to solve cubic polynomials you best need a tool that automatically handles complex numbers

Like the 41Z module perhaps? :-)

Well, notwithstanding all the references you mention (well worthy of their effort) the 41Z includes ZPROOT, adapted from Valentin Albillo's original program for the 41.

Cheers,
'AM

And the 41Z module too!!!

:-)

Namir

We can combine this with a synthetically dividing the cubic equation by the root and then use the quadratic formula to find the other two roots.

Very nice.

 Possibly Related Threads… Thread Author Replies Views Last Post [HP Prime] Tips for Solving Differential Equations More Efficiently Chris Pem10 8 2,886 11-21-2013, 08:25 PM Last Post: Chris Pem10 Equation Library/App for the Prime Harold A Climer 3 1,729 10-30-2013, 10:14 AM Last Post: CompSystems Equation Library on the PRIME Harold A Climer 0 1,056 10-26-2013, 10:01 AM Last Post: Harold A Climer HP-PRIME CAS SOLVING fabrice48 8 2,786 10-19-2013, 01:21 PM Last Post: Han Meltiple Equation Solver PRIME Vs. HP 50G Harold A Climer 5 1,829 10-07-2013, 05:11 PM Last Post: CR Haeger HP Prime Solving Nonlinear System of Equations for Complex Results Helge Gabert 11 4,224 09-30-2013, 03:44 AM Last Post: From Hong Kong EOT--TI N-Spire Equation Limit Matt Agajanian 2 1,306 09-22-2013, 12:37 PM Last Post: Matt Agajanian Does Prime Have a Multiple Equation Solver? Norman Dziedzic 2 1,374 09-20-2013, 09:43 AM Last Post: Norman Dziedzic Equation of the parabola given three points Gerson W. Barbosa 27 6,519 09-18-2013, 01:58 PM Last Post: Gerson W. Barbosa Quadratic & Cubic Regression RPN progs Matt Agajanian 9 2,948 09-17-2013, 11:37 AM Last Post: Jeff O.

Forum Jump: