Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Root Finding To be done as a team As a team, you are to write a program that will find a root of a cubic

Root Finding To be done as a team

As a team, you are to write a program that will find a root of a cubic polynomial. A cubic polynomial is of the form:

A root of the polynomial is a value, x, such that f(x)=0. For a generic cubic polynomial, there will be one local maximum, and one local minimum, and the curve will go off to negative infinity in one direction, and positive infinity in another.

The polynomial has some number of real roots: the points at which the curve crosses the x-axis. A cubic curve will have either 3 real roots (as above at left), 1 root (above, middle), or in rare cases 2 roots (as above at right). Note that roots are typically single roots, and for single roots, the curve is negative on one side of the root, positive on the other (a double root results in a tangent to the curve, like that above at right).

You should write a program that requests a user for the following input: 1) coefficients of the polynomial: A, B, C, and D, and 2) bounds on one single root: a, b. The user should be expected to input a and b such that a

Before developing your code, your team should come up with at least 4 test cases. Test cases should indicate a curve (the 4 coefficients for the curve), as well as a large starting bound on the root (values of a and b, with b >= a+1). Your code should include documentation of these 4 (or more) test cases in comments, near the top of the program (after your standard header). [10 Points]

To solve this problem, you can use the following procedure, known as bisection. It is a form of what is more generally known as binary search:

Because the root is a single root, either f(a) or f(b) will be positive, and the other will be negative.

You can generate the midpoint of the interval from a to b, by finding the value halfway between a and b. Call this point p.

If you evaluate f(p), it will be either positive or negative (or possibly, be the root itself, if f(p)=0).

This will enable you to narrow the interval to either [a,p] or to [p,b].

You can continue doing this until your interval is less than 10-6 wide.

As a team, you should create a program that performs bisection to determine the root. More specifically, your program should do the following:

1. Read in the coefficients of the polynomial from the user [10 Points]

2. Read in the upper and lower bounds around a single root of the polynomial [10 Points]

3. Determine the value of that root to within 10-6 [50 Points]

4. Print the result of that root finding, as a single number [10 Points]

5. Print out how many iterations it took to find that root. [10 Points]

Be sure to include comments in your code.

Challenge: Cubic polynomials always have one root that can be found through bisection. There also are ways to find maximum and minimum bounds on the sizes of real roots of polynomials (you will need to research this). Modify your program so that it takes in only the coefficients of the polynomial, and reports one of the real roots to within 10-6.

using PUTHON AND DONT USE DEF

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions