Complete the code to create a polynomial from roots using np.poly.
import numpy as np roots = [1, 2, 3] poly_coeffs = np.[1](roots) print(poly_coeffs)
The np.poly function returns the coefficients of the polynomial with the given roots.
Complete the code to evaluate the polynomial at x=2 using np.polyval.
import numpy as np coeffs = [1, -6, 11, -6] # coefficients for (x-1)(x-2)(x-3) value = np.[1](coeffs, 2) print(value)
The np.polyval function evaluates a polynomial at given points.
Fix the error in the code to multiply two polynomials using np.polymul.
import numpy as np p1 = [1, -1] # x - 1 p2 = [1, -2] # x - 2 product = np.[1](p1, p2) print(product)
The np.polymul function multiplies two polynomials represented by their coefficients.
Fill both blanks to create a polynomial from roots and then find its roots.
import numpy as np roots = [4, 5, 6] coeffs = np.[1](roots) found_roots = np.[2](coeffs) print(found_roots)
First, np.poly creates polynomial coefficients from roots. Then, np.roots finds roots from coefficients.
Fill all three blanks to create a polynomial from roots, evaluate it at x=3, and multiply by another polynomial.
import numpy as np roots = [1, 2] p1 = np.[1](roots) val = np.[2](p1, 3) p2 = [1, -3] product = np.[3](p1, p2) print(val) print(product)
Use np.poly to get coefficients from roots, np.polyval to evaluate the polynomial at 3, and np.polymul to multiply polynomials.