I started learning Python
and I have been referring to "A primer on Scientific Programming with Python by HP Langtangen". I just started the topic on functions and I have been assigned a task to develop a function which computes a polynomial by product. The exact question being
Given n+1 roots r0, r1, . . . , rn of a polynomial p(x) of degree n+1, p(x) can be computed by
p(x) = (x - r0)(x - r1) · · · (x - rn-1)(x - rn)
Write a function poly(x, roots) that takes x and a list roots of the roots as arguments and returns p(x)
Is there any way this problem can be solved without using Sympy
?