{br} STUCK with your assignment? {br} When is it due? {br} Get FREE assistance. Page Title: {title}{br} Page URL: {url}
+1 917 8105386 [email protected]
Select Page
1. (30 points) Consider the following polynomial with a real variable, x;
�(�) = �& − 6�) + 11� − 6 = (� − 1)(� − 2)(� − 3)
which has roots at x=1, x=2 and x=3. The polynomial and its roots are shown in
the figure below.
a. (5 points) Write a Python function for p(x) that takes x as a formal parameter
and returns p(x).
b. (15 points) Write a Python function for root finding using the Bisection
search that takes a lower bound, xl, and an upper bound, xu, of a search
interval as formal parameters, and returns a root, x1, of p(x) such that
p(x1)~0. x1 can be any root of p(x). At each iteration, the function is expected
to print the iteration number, the new interval midpoint and the absolute
value of p(x) at the midpoint. Iterations should stop when the absolute
value of p(x) at a new midpoint is less than 10-6. The function will return that
midpoint as x1.
c. (10 points) Write a main program that will get the lower and upper bounds,
xl and xu, from a user using the input statement, and call the functions
developed earlier as needed to find a root of the polynomial. In order for the
Bisection search to work, the value of p(x) should have different signs at the
lower and upper bounds. If the value of p(x) has the same sign at the lower
and upper bounds provided by the user, the program should print an error
message and quit. Otherwise, it should call the function developed for
question 1.b to find a root. The program is supposed to print the root right
after locating it