Mathematics · Algebra

Cubic Equation Solver

Solve a real cubic equation ax³+bx²+cx+d=0 and classify its real roots.

Runs locally
Your numbers

Inputs and results stay in this browser. Change one value at a time to explore the relationship.

Your inputCalculatedPassed forward in chains
Real root 11
Real root 22
Real root 33
Cardano discriminant-0.037037
Number of distinct real roots3

Calculation steps

  1. Divide by 1 and substitute x=t−-6/3.
  2. The depressed cubic has p=-1 and q=0.
  3. Discriminant=-0.037037037037037035, producing real roots 1, 1.9999999999999998, 3.

Understand Cubic equation

One idea, three depths

Choose how deeply to explain Cubic equation

Solve a real cubic equation ax³+bx²+cx+d=0 and classify its real roots.

Age 5Explain it to a 5-year-oldStart with a picture

Imagine using Cubic equation to answer this question: solve a real cubic equation ax³+bx²+cx+d=0 and classify its real roots? Enter Cubic coefficient a, Quadratic coefficient b, Linear coefficient c, and 1 other input; the calculator shows Real root 1. For example: x³−6x²+11x−6=0 has roots 1, 2 and 3. The answer tells you Real root 1.

Age 15Explain it to a 15-year-oldConnect it to the formula

Depressing the cubic removes its squared term. The discriminant then determines whether the equation has one, two or three distinct real roots. The rule is x³+px+q=0 after substituting x=t−b/(3a). Its input values are Cubic coefficient a, Quadratic coefficient b, Linear coefficient c, Constant d, and the main result is Real root 1. For example: x³−6x²+11x−6=0 has roots 1, 2 and 3.

CollegeExplain it at college levelState the model precisely

This calculator evaluates the stated cubic equation relation over the valid real-number domain stated below. The implemented relation is x³+px+q=0 after substituting x=t−b/(3a), evaluated from Cubic coefficient a, Quadratic coefficient b, Linear coefficient c, Constant d to produce Real root 1. Depressing the cubic removes its squared term. The discriminant then determines whether the equation has one, two or three distinct real roots. The leading coefficient a cannot be zero; that would make the equation quadratic.

Inputs and valid domain

  • Cubic coefficient a must be a finite real number.
  • Quadratic coefficient b must be a finite real number.
  • Linear coefficient c must be a finite real number.
  • Constant d must be a finite real number.

Important boundary: The leading coefficient a cannot be zero; that would make the equation quadratic.

The formula

x³+px+q=0 after substituting x=t−b/(3a)

How the calculator works through it

It substitutes Cubic coefficient a, Quadratic coefficient b, Linear coefficient c, Constant d into the formula and exposes every numerical step above. The main output is Real root 1, accompanied by Real root 2, Real root 3, Cardano discriminant, Number of distinct real roots.

Read the result correctly

The Real root 1 is the direct answer to “solve a real cubic equation ax³+bx²+cx+d=0 and classify its real roots.” Read it with the units shown beside the inputs; a sign, angle, percentage or rate changes what the number means.

A worked check

x³−6x²+11x−6=0 has roots 1, 2 and 3.

Where this model stops being reliable

The leading coefficient a cannot be zero; that would make the equation quadratic.

Learn it by changing one value

Begin with the worked example, then change one value while keeping the others fixed. Compare the new result and calculation steps to identify which part of the formula changed.

Dictionary terms behind this calculator

Before studying the codeWhat you should know firstUse the calculator immediately, or check the foundations before reading the implementation.

These foundations help you understand why Cubic equation works. They never block the calculator, and “optional” means useful context rather than a hidden requirement.

Hard requirements

  • Reading formulas and substituting values

    Cubic equation uses x³+px+q=0 after substituting x=t−b/(3a). You need to recognise what each side represents before substituting the stated inputs or rearranging the relationship.

    Review this foundation about 4 min

Strong support

Optional enrichment

Learn the missing foundationsI already know these — show the code

Mathematics → algorithm → program

Implement this calculation in code

These are direct reference implementations of the calculator's principal relationship and first output. They run locally and include a small known-answer check where the language supports it.

Algorithm

  1. Divide by the leading coefficient and substitute x=t−b/(3a) to remove the squared term.
  2. Use the Cardano discriminant to choose the one-real-root or three-real-root form.
  3. Return the smallest real root; the complete calculator also displays the other real roots.
Python
            from math import acos, cos, cbrt, pi, sqrt

def cubic_equation(a: float, b: float, c: float, d: float) -> float:
    if a == 0:
        raise ValueError("a cannot be zero")
    A, B, C = b / a, c / a, d / a
    p = B - A * A / 3
    q = 2 * A**3 / 27 - A * B / 3 + C
    discriminant = q * q / 4 + p**3 / 27
    if discriminant >= 0:
        return cbrt(-q / 2 + sqrt(discriminant)) + cbrt(-q / 2 - sqrt(discriminant)) - A / 3
    radius = 2 * sqrt(-p / 3)
    theta = acos((3 * q / (2 * p)) * sqrt(-3 / p))
    return min(radius * cos((theta + 2 * pi * k) / 3) - A / 3 for k in range(3))

assert abs(cubic_equation(1, -6, 11, -6) - 1) < 1e-9
          
Current calculator valuesUpdates when you change an input above.
              
            
C
            #include <assert.h>
#include <math.h>

double cubic_equation(double a, double b, double c, double d) {
    double A=b/a, B=c/a, C=d/a;
    double p=B-A*A/3.0, q=2*A*A*A/27.0-A*B/3.0+C;
    double disc=q*q/4.0+p*p*p/27.0;
    if (disc >= 0.0)
        return cbrt(-q/2+sqrt(disc))+cbrt(-q/2-sqrt(disc))-A/3;
    double r=2*sqrt(-p/3), theta=acos((3*q/(2*p))*sqrt(-3/p));
    double best=INFINITY;
    for(int k=0;k<3;k++) best=fmin(best,r*cos((theta+2*M_PI*k)/3)-A/3);
    return best;
}

int main(void) { assert(fabs(cubic_equation(1,-6,11,-6)-1)<1e-9); }
          
Current calculator valuesUpdates when you change an input above.
              
            
C++
            #include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <numbers>

double cubic_equation(double a, double b, double c, double d) {
    const double A=b/a, B=c/a, C=d/a;
    const double p=B-A*A/3.0, q=2*A*A*A/27.0-A*B/3.0+C;
    const double disc=q*q/4.0+p*p*p/27.0;
    if (disc >= 0.0)
        return std::cbrt(-q/2+std::sqrt(disc))+std::cbrt(-q/2-std::sqrt(disc))-A/3;
    const double r=2*std::sqrt(-p/3), theta=std::acos((3*q/(2*p))*std::sqrt(-3/p));
    std::array<double,3> roots{};
    for(int k=0;k<3;k++) roots[k]=r*std::cos((theta+2*std::numbers::pi*k)/3)-A/3;
    return *std::min_element(roots.begin(), roots.end());
}

int main() { assert(std::abs(cubic_equation(1,-6,11,-6)-1)<1e-9); }
          
Current calculator valuesUpdates when you change an input above.
              
            
Linux x86-64 assembly

x86-64 NASM · System V ABI · Linux · double arguments and result in XMM registers

            ; double cubic_equation(double a, double b, double c, double d)
; Newton iteration returns one real root. xmm0=a, xmm1=b, xmm2=c, xmm3=d.
global cubic_equation
section .text
cubic_equation:
    movapd xmm7, xmm0       ; a
    movapd xmm6, xmm1       ; b
    movapd xmm5, xmm2       ; c
    movapd xmm4, xmm3       ; d
    pxor xmm0, xmm0         ; starting guess x=0
    mov ecx, 40
.iterate:
    movapd xmm1, xmm0
    mulsd xmm1, xmm0
    movapd xmm2, xmm1
    mulsd xmm2, xmm0
    mulsd xmm2, xmm7
    mulsd xmm1, xmm6
    addsd xmm2, xmm1
    movapd xmm1, xmm0
    mulsd xmm1, xmm5
    addsd xmm2, xmm1
    addsd xmm2, xmm4        ; f(x)
    movapd xmm1, xmm0
    mulsd xmm1, xmm0
    addsd xmm1, xmm1
    movapd xmm3, xmm0
    mulsd xmm3, xmm0
    addsd xmm1, xmm3
    mulsd xmm1, xmm7        ; 3ax²
    movapd xmm3, xmm0
    addsd xmm3, xmm3
    mulsd xmm3, xmm6
    addsd xmm1, xmm3
    addsd xmm1, xmm5        ; f'(x)
    divsd xmm2, xmm1
    subsd xmm0, xmm2
    loop .iterate
    ret
          
Current calculator valuesUpdates when you change an input above.
              
            
MATLAB
            function result = cubic_equation(a, b, c, x)
    values = roots([a, b, c, x]);
    realValues = real(values(abs(imag(values)) < 1e-9));
    result = min(realValues);
end
          
Current calculator valuesUpdates when you change an input above.
              
            
Wolfram Language
            ClearAll[mwCalculate];
mwCalculate[a_, b_, c_, d_] := Min[x /. NSolve[a*x^3 + b*x^2 + c*x + d == 0, x, Reals]];
          
Current calculator valuesUpdates when you change an input above.
              
            

Continue in mathematical software

The downloaded file includes your current inputs and first calculated result. It is created locally.

Floating-point answers can differ slightly by language, compiler and processor. Compare within a suitable tolerance rather than assuming every decimal representation will be identical.

Supporting sourcesAcademic referencesPrimary standards, textbooks and complete citations

Standards, reading and academic references

Use the calculator as the worked interaction, then consult the primary standards and academic textbooks listed below. MW SysArc links to the original sources; the explanation on this page is original and does not reproduce them.

Algebra and Trigonometry 2e

Read the related free OpenStax mathematics chapters
Cite this book
APA 7
Abramson, J. (2021). Algebra and trigonometry 2e. OpenStax. https://openstax.org/books/algebra-and-trigonometry-2e/pages/1-introduction-to-prerequisites
MLA 9
Abramson, Jay. Algebra and Trigonometry 2e. OpenStax, 2021, https://openstax.org/books/algebra-and-trigonometry-2e/pages/1-introduction-to-prerequisites.
Chicago author-date
Abramson, Jay. 2021. Algebra and Trigonometry 2e. Houston, TX: OpenStax. https://openstax.org/books/algebra-and-trigonometry-2e/pages/1-introduction-to-prerequisites.

OpenStax entries are free to read online. Follow the licence shown on each linked source before redistributing or adapting its content.

Reuse the page responsiblyCite this pageAPA, MLA, Chicago, Harvard, BibTeX and RIS

These formats cite this calculator page itself. They are separate from the academic references above, which support the mathematical method and terminology.

APA 7

MW SysArc. (2026, July 21). Cubic Equation Solver. MW SysArc Tools. https://math.mwsysarc.com/algebra/cubic-equation-solver

MLA 9

MW SysArc. “Cubic Equation Solver.” MW SysArc Tools, 21 July 2026, https://math.mwsysarc.com/algebra/cubic-equation-solver. Accessed 31 Aug. 2026.

Chicago 17

MW SysArc. “Cubic Equation Solver.” MW SysArc Tools. Published July 21, 2026. Accessed August 31, 2026. https://math.mwsysarc.com/algebra/cubic-equation-solver.

Harvard

MW SysArc (2026) ‘Cubic Equation Solver’, MW SysArc Tools. Published 21 July 2026. Available at: https://math.mwsysarc.com/algebra/cubic-equation-solver (Accessed: 31 August 2026).

BibTeX and RIS records

BibTeX

@misc{mwsysarc_cubic_equation_2026,
  author = {{MW SysArc}},
  title = {Cubic Equation Solver},
  howpublished = {MW SysArc Tools},
  year = {2026},
  url = {https://math.mwsysarc.com/algebra/cubic-equation-solver},
  note = {Published July 21, 2026; accessed August 31, 2026}
}

RIS

TY  - ELEC
AU  - MW SysArc
TI  - Cubic Equation Solver
T2  - MW SysArc Tools
PY  - 2026
DA  - 2026-07-21
Y2  - 2026-08-31
UR  - https://math.mwsysarc.com/algebra/cubic-equation-solver
N1  - Published July 21, 2026
ER  -

Clear answers

Frequently asked questions

What does the Cubic equation do?

Solve a real cubic equation ax³+bx²+cx+d=0 and classify its real roots.

How does the Cubic equation work?

The calculator applies x³+px+q=0 after substituting x=t−b/(3a). Depressing the cubic removes its squared term. The discriminant then determines whether the equation has one, two or three distinct real roots.

What can I learn from the Cubic equation?

It connects the mathematical rule to your chosen numbers and shows each calculation step. Change one input at a time to see how the result responds.

Does MW SysArc receive or store what I enter?

No. The calculation runs locally in your browser. MW SysArc does not receive or store your calculation inputs.

How should I use the result?

Use the steps to understand the method, then verify important school or professional work using the notation and rounding rules required in your setting.

Last reviewed . Calculations tested .

MW SysArc Certified