Question: 2. Write C code to implement the following algorithm i. Read polynomial coefficients, interval of interest, and step size i Locate roots using subintervals. Prompting

2. Write C code to implement the following algorithm i. Read polynomial coefficients, interval of interest, and step size i Locate roots using subintervals. Prompting the user to enter the necessary information and then reading it. Requires a loop to compute the subinterval endpoints and then to determine if a root occurs on at he endpoint or in the subinterval. When a root is located, write a message that the root is found or otherwise. Use functions to keep the main function from getting long. Need to evaluate the cubic polynomial in a few places in the program. Within the corresponding subinterval, need to search for a root that you can use a search function. You may create your own C code or you may decide to use the algorithm below main: read coefficients, interval endpoints a and b, and step size compute the number of subintervals, n set k to while ks n- compute left subinterval endpoint compute right subinterval endpoint check_roots (left, right, coefficients) increment k by 1 check_roots (b,b,coefficients) check_roots (left, right, coefficients): set f_left to poly (left, coefficients) set f_right to poly(right, coefficients) if f_left is near zero print root at left endpoint else if f left . f right
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
