Create a function that will output the three roots of a cubic equation specified by the 4 coefficients listed as input. The output should be sorted using the "sort" function of matlab, to be consistent. Also, the output need only be accurate to the 4th decimal place, and the input "A" will always be non-zero and real.

Example:

A*x^3+B*x^2+C*x+D=0 --> [A,B,C,D]

x^3-6x^2+11x-6=0 --> [1,-6,11,-6]

cubicFormula([1,-6,11,-6]) --> [1,2,3]

Solution Stats

205 Solutions

21 Solvers

Last Solution submitted on Jan 20, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers21

Suggested Problems

More from this Author1

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!