> For the complete documentation index, see [llms.txt](https://jona-projects.gitbook.io/kiwicalc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jona-projects.gitbook.io/kiwicalc/equations/cubic-equations.md).

# Cubic Equations

#### Cubic Equations

Let's move to cubic equations, namely, equations in the form \`ax^3+bx^2+cx+d\` where \`a!=0\`. You can solve cubic equations with the `solve_cubic()` method. The method accepts four real coefficients: \`a\`, \`b\`, \`c\`, \`d\`, and returns a tuple of the 3 solutions. If you are only interested in real solutions, you can use the `solve_cubic_real` method. For example, let's solve the equation \`x^3 + 3x^2 - 4x - 8\`.

```python
                        
solutions = solve_cubic(1, 3, -4, -8)
real_solutions = solve_cubic_real(1, 3, -4, -8)
print(solutions)
print(real_solutions)
```

You can also use the `CubicEquation` class, which offers similar methods to the QuadraticEquation class. For instance:

```python
my_equation = CubicEquation("x^3 + 3x^2 - 4x - 8 = 0")
print(my_equation.solution)
print(my_equation.coefficients())
print(my_equation.random())
           
```
