Challenge - 5 Problems
Polynomial Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Evaluate polynomial at a point
What is the output of this MATLAB code that evaluates the polynomial p(x) = 2x^3 - 4x + 1 at x = 2?
MATLAB
p = [2 0 -4 1]; result = polyval(p, 2); disp(result);
Attempts:
2 left
💡 Hint
Remember to substitute x=2 into the polynomial 2x^3 - 4x + 1.
✗ Incorrect
Evaluating 2*(2^3) - 4*2 + 1 = 2*8 - 8 + 1 = 16 - 8 + 1 = 9.
❓ Predict Output
intermediate2:00remaining
Find roots of a quadratic polynomial
What is the output of this MATLAB code that finds the roots of the polynomial p(x) = x^2 - 5x + 6?
MATLAB
p = [1 -5 6]; roots_p = roots(p); disp(sort(roots_p));
Attempts:
2 left
💡 Hint
Recall the factorization of x^2 - 5x + 6.
✗ Incorrect
The polynomial factors as (x-2)(x-3), so roots are 2 and 3.
🔧 Debug
advanced2:00remaining
Identify the error in polynomial evaluation
What error does this MATLAB code produce when trying to evaluate polynomial p(x) = 3x^2 + 2x + 1 at x = [1 2 3]?
MATLAB
p = [3 2 1]; result = polyval(p); disp(result);
Attempts:
2 left
💡 Hint
Check the usage of polyval function and its required inputs.
✗ Incorrect
polyval requires both polynomial coefficients and the points to evaluate at.
❓ Predict Output
advanced2:00remaining
Number of roots for a cubic polynomial
How many roots does the polynomial p(x) = x^3 - 6x^2 + 11x - 6 have according to MATLAB's roots function?
MATLAB
p = [1 -6 11 -6]; r = roots(p); disp(length(r));
Attempts:
2 left
💡 Hint
A cubic polynomial always has how many roots (including complex)?
✗ Incorrect
A cubic polynomial has exactly 3 roots (real or complex).
🧠 Conceptual
expert2:00remaining
Effect of leading zeros in polynomial coefficient vector
What is the output of this MATLAB code that finds roots of the polynomial with leading zeros in coefficients: p = [0 0 1 -3 2]?
MATLAB
p = [0 0 1 -3 2]; r = roots(p); disp(sort(r));
Attempts:
2 left
💡 Hint
MATLAB ignores leading zeros in polynomial coefficient vectors.
✗ Incorrect
Leading zeros do not affect polynomial degree; roots correspond to x^2 - 3x + 2.