Cody

Problem 42518. Roots of quadratic equation

Solution 1726653

Submitted on 13 Feb 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 = 2; c = 1; y_correct = [-1 -1]; assert(sum(abs(roots(a,b,c)-y_correct))<1e-3)

Not enough input arguments. Error in roots (line 2) y=sort((roots([a b c]))'); Error in roots (line 2) y=sort((roots([a b c]))'); Error in Test1 (line 5) assert(sum(abs(roots(a,b,c)-y_correct))<1e-3)

2   Fail
a = 9; b = 42; c = 5; y_correct = [-4.5444 -0.1223]; assert(sum(abs(roots(a,b,c)-y_correct))<1e-3)

Not enough input arguments. Error in roots (line 2) y=sort((roots([a b c]))'); Error in roots (line 2) y=sort((roots([a b c]))'); Error in Test2 (line 5) assert(sum(abs(roots(a,b,c)-y_correct))<1e-3)

3   Fail
a = 10; b = 42; c = 7; y_correct = [-4.0261 -0.1739]; assert(sum(abs(roots(a,b,c)-y_correct))<1e-3)

Not enough input arguments. Error in roots (line 2) y=sort((roots([a b c]))'); Error in roots (line 2) y=sort((roots([a b c]))'); Error in Test3 (line 5) assert(sum(abs(roots(a,b,c)-y_correct))<1e-3)