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

Short Quadratic Solver (HP-42S) Message #29

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

x^{3} + 6x - 2 = 0

CuEq: 3.27480002074E-1 i0

CuEqH: 3.27480002074E-1

x^{3} + 3x - 4 = 0

CuEq: 1 i0

CuEqH: 1

## References

Cubic Formula

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

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

cf.Cubic Formula

Quote:

To solve the general cubic (1), it is reasonable to begin by attempting to eliminate the *a*_{2} term by making a substitution of the form .

This leads to formulas for *p* and *q* based upon *a*_{i}.

Cheers

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

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

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

Quote:

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

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

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.