Question: Using Python A polynomial of degree n with coefficients a0, a1, a2, a3,..., an is the function p(x) = a0 + a1x + a2x 2
Using Python
A polynomial of degree n with coefficients a0, a1, a2, a3,..., an is the function p(x) = a0 + a1x + a2x 2 + a3 x 3 +... + an x n This function can be evaluated at different values of x. For example, if p(x) = 1 + 2x+ x 2, then p(2) = 1 + 2 2 + 22 = 9. If p(x) = 1 + x 2 + x 4, then p(2) = 21 and p(3) = 91. Write a function poly() that takes as input a list of coefficients a0, a1, a2, a3,..., an of a polynomial p(x) and a value x. The function will return p(x), which is the value of the polynomial when evaluated at x. Note that the usage below is for the three examples shown. >>> poly([1, 2, 1], 2) 9 >>> poly([1, 0, 1, 0, 1], 2) 21 >>> poly([1, 0, 1, 0, 1], 3) 91
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
