Cody

Problem 42986. Determine the roots of a cubic equation

Solution 1893486

Submitted on 7 Aug 2019
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
a=1; b=3; c=3; d=1; y_correct = [-1 -1 -1]; assert(sum(abs(cubicRoots(a,b,c,d)-y_correct))<1e-3)

Error using assert The condition input argument must be a scalar logical. Error in Test1 (line 3) assert(sum(abs(cubicRoots(a,b,c,d)-y_correct))<1e-3)

2   Fail
a=1; b=-6; c=11; d=-6; y_correct = [1 2 3]; assert(sum(abs(cubicRoots(a,b,c,d)-y_correct))<1e-3)

Error using assert The condition input argument must be a scalar logical. Error in Test2 (line 3) assert(sum(abs(cubicRoots(a,b,c,d)-y_correct))<1e-3)

3   Fail
a=4; b=4; c=-1; d=-1; y_correct = [-1 -0.5 0.5]; assert(sum(abs(cubicRoots(a,b,c,d)-y_correct))<1e-3)

Error using assert The condition input argument must be a scalar logical. Error in Test3 (line 3) assert(sum(abs(cubicRoots(a,b,c,d)-y_correct))<1e-3)