# \[?\] Solve a cubic equation?

**URL:** <https://community.wolfram.com/t/solve-a-cubic-equation/11527>\
**Category:** Questions\
**Tags:** equation-solving\
**Created:** [November 15, 2017, 9:21am UTC](https://community.wolfram.com/t/solve-a-cubic-equation/11527 "2017-11-15T09:21:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![guneymetin](https://avatars.discourse-cdn.com/v4/letter/g/b782af/32.png) [@guneymetin](https://community.wolfram.com/u/guneymetin)\
**Post date:** [November 15, 2017, 9:21am UTC](https://community.wolfram.com/t/solve-a-cubic-equation/11527/1 "2017-11-15T09:21:51Z")

</div>

Please look at this outcome:

 ![ucuncuDD_forumSoru1.PNG](https://global.discourse-cdn.com/wolfram/original/2X/f/f8a4362900c9fe3af01439657ffb1c9e6ae401e8.png)

As you see, all 3 roots are complex numbers. But this equition has a real root at least 1.  
This is 0.1736 … (exactly sin 10 degrees).

 ![ucuncuDD_forumSoru2.PNG](https://global.discourse-cdn.com/wolfram/original/3X/1/1/111836407b46318ab936aa112921b0db1ffb3181.png)

Where is my fault?  
[1]: [http://community.wolfram.com//c/portal/getImageAttachment?filename=ucuncuDD\_forumSoru1.PNG&userId=1222434](http://community.wolfram.com//c/portal/getImageAttachment?filename=ucuncuDD_forumSoru1.PNG&userId=1222434)  
[2]: [http://community.wolfram.com//c/portal/getImageAttachment?filename=ucuncuDD\_forumSoru2.PNG&userId=1222434](http://community.wolfram.com//c/portal/getImageAttachment?filename=ucuncuDD_forumSoru2.PNG&userId=1222434)

---

<div class="post-metadata">

**Author:** ![priyanfernando](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@priyanfernando](https://community.wolfram.com/u/priyanfernando)\
**Post date:** [November 15, 2017, 9:48am UTC](https://community.wolfram.com/t/solve-a-cubic-equation/11527/2 "2017-11-15T09:48:18Z")

</div>

You can use NSolve:

```
NSolve[(8*t^3 - 6*t + 1 == 0), t]

```

This gives {{t → -0.939693}, {t → 0.173648}, {t → 0.766044}}

For exact solutions:

```
ComplexExpand@Solve[(8*t^3 - 6*t + 1 == 0), t]

```

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [November 15, 2017, 10:25am UTC](https://community.wolfram.com/t/solve-a-cubic-equation/11527/3 "2017-11-15T10:25:28Z")

</div>

Mathematica is a mathematical program that performs computations on complex numbers(complex plain) and therefore we see the imaginary unit **I** everywhere.

If You want solution try with **ComplexExpand** :

```
sol = Solve[8*t^3 - 6*t + 1 == 0, t] // ComplexExpand
(* {{t -> 1/2 Cos[\[Pi]/9] + 1/2 Sqrt[3] Sin[\[Pi]/9]}, {t -> 
1/2 Cos[\[Pi]/9] - 1/2 Sqrt[3] Sin[\[Pi]/9]}, {t -> -Cos[\[Pi]/9]}} *)

sol//N
(* {{t -> 0.766044}, {t -> 0.173648}, {t -> -0.939693}} *)

```

Yours equation has 3 real roots:

```
Plot[8*t^3 - 6*t + 1, {t, -1, 1}, Epilog -> {Red, PointSize[0.02], Point[{t /. sol[[#]] // N, 0} & /@ {1, 2, 3}]}, 
AxesLabel -> {t, f[t]}, PlotLabels -> Placed[{"8*t^3-6*t+1"}, Above]]

```

 ![6760Bez tytułu.png](https://global.discourse-cdn.com/wolfram/original/2X/c/ccb020b77fae0462ca778f5fe8ec520f50a27152.png)

Another example with 1 real and 2 complex roots:

```
sol1 = Solve[t^3 - t + 1 == 0, t] // ComplexExpand
(* {{t -> -(2/(3 (9 - Sqrt[69])))^(1/3) - (1/2 (9 - Sqrt[69]))^(1/3)/3^(
    2/3)}, {t -> (1/2 (9 - Sqrt[69]))^(1/3)/(2 3^(2/3)) + 1/(
    2^(2/3) (3 (9 - Sqrt[69]))^(1/3)) + 
    I (-(3^(1/6)/(2^(2/3) (9 - Sqrt[69])^(1/3))) + (9 - Sqrt[69])^(
       1/3)/(2 2^(1/3) 3^(1/6)))}, {t -> (1/2 (9 - Sqrt[69]))^(1/3)/(
    2 3^(2/3)) + 1/(2^(2/3) (3 (9 - Sqrt[69]))^(1/3)) + 
    I (3^(1/6)/(2^(2/3) (9 - Sqrt[69])^(1/3)) - (9 - Sqrt[69])^(1/3)/(
       2 2^(1/3) 3^(1/6)))}}*)
sol1 // N
(* {{t -> -1.32472}, {t -> 0.662359 - 0.56228 I}, {t -> 0.662359 + 0.56228 I}} *)

Plot[t^3 - t + 1, {t, -2, 2}, Epilog -> {Red, PointSize[0.02], 
Point[{t /. sol1[[#]] // N, 0} & /@ {1}]}, AxesLabel -> {t, f[t]}, PlotLabels -> Placed[{"t^3-t+1"}, Above]]

```

 ![222.png](https://global.discourse-cdn.com/wolfram/original/2X/3/342974dd295306661151bd43a7dd101dfa36bbac.png)

---

<div class="post-metadata">

**Author:** ![guneymetin](https://avatars.discourse-cdn.com/v4/letter/g/b782af/32.png) [@guneymetin](https://community.wolfram.com/u/guneymetin)\
**Post date:** [November 15, 2017, 10:43am UTC](https://community.wolfram.com/t/solve-a-cubic-equation/11527/4 "2017-11-15T10:43:26Z")

</div>

Thanks for your explanations.  
But what I can’t understand is the behavior of Mathematica.  
Is this equition has more than 3 roots, 3 of them are real, other 3 are complex?

---

<div class="post-metadata">

**Author:** ![danl](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/danl/32/41267_2.png) [@danl](https://community.wolfram.com/u/danl)\
**Post date:** [November 15, 2017, 4:05pm UTC](https://community.wolfram.com/t/solve-a-cubic-equation/11527/5 "2017-11-15T16:05:26Z")

</div>

(1) Please post actual code rather than an image of code.

(2) Have a look at the [casus irreducibilus](https://en.wikipedia.org/wiki/Casus_irreducibilis).

(3) One can avoid seemingly complex radicals in the result using an option setting to disable the Cardano/Tartaglia cubic form of result.

```
InputForm[Solve[(8*t^3 - 6*t + 1 == 0), t, Cubics->False]]              

(* Out[2]//InputForm= 
{{t -> Root[1 - 6*#1 + 8*#1^3 & , 1, 0]}, 
 {t -> Root[1 - 6*#1 + 8*#1^3 & , 2, 0]}, 
 {t -> Root[1 - 6*#1 + 8*#1^3 & , 3, 0]}} *)

N[%]                                                                    

(* Out[3]= {{t -> -0.939693}, {t -> 0.173648}, {t -> 0.766044}} *)

```

Alternatively convert the cubic radicals to trigs.

```
InputForm[ComplexExpand[Solve[(8*t^3 - 6*t + 1 == 0), t]]]              

(* Out[5]//InputForm= 
{{t -> Cos[Pi/9]/2 + (Sqrt[3]*Sin[Pi/9])/2}, 
 {t -> Cos[Pi/9]/2 - (Sqrt[3]*Sin[Pi/9])/2}, {t -> -Cos[Pi/9]}} *)

```

---

<div class="post-metadata">

**Author:** ![guneymetin](https://avatars.discourse-cdn.com/v4/letter/g/b782af/32.png) [@guneymetin](https://community.wolfram.com/u/guneymetin)\
**Post date:** [November 20, 2017, 7:00am UTC](https://community.wolfram.com/t/solve-a-cubic-equation/11527/6 "2017-11-20T07:00:50Z")

</div>

Thanks for detailed explanations.

---

<div class="post-metadata">

**Author:** ![guneymetin](https://avatars.discourse-cdn.com/v4/letter/g/b782af/32.png) [@guneymetin](https://community.wolfram.com/u/guneymetin)\
**Post date:** [November 20, 2017, 7:06am UTC](https://community.wolfram.com/t/solve-a-cubic-equation/11527/7 "2017-11-20T07:06:27Z")

</div>

“Casus irreducibilus” explained everything.  
Thank you for detailed explanations.
