Question: Program 1: Finding the roots of a Polynomial (use the filename PolyRoot.java) For this assignment, you'll write a program that finds the root of a

Program 1: Finding the roots of a Polynomial (use the filename PolyRoot.java) For this assignment, you'll write a program that finds the root of a high order polynomial. For polynomials with orders higher than four, there is no general formula for find the roots of the polynomial. In your program, you are going to use an iterative method to find the roots. You will begin with two values that bound the root and from there, shrink the boundary until you are "close enough" to the root. The polynomial that you will find the root for is : p(x)=4x^7 3x^5 2x^4 +7x^3 + 3x^2 9x 3

Program Input: Your program will read in the following values: the lower bound of the starting range (this will be a real number) we will call it lowVal here the upper bound of the starting range (this will be a real number) we will call it highVal here the tolerance (the maximum difference from zero; this will be a small real number less than one, but not smaller than 0.00001) the maximum number of iterations to try (this will be an integer; it will prevent a run away program in case something goes wrong, but not larger than 2,000,000,000). The lower and upper bounds of the range must be chosen so that the following inequality holds: p(lowVal) p(highVal)<0 That is, the value of the polynomial must be positive at one bound and negative at the other. That means that a root (where the polynomial equals zero) must be in this range. You must find you own starting boundary values that meet this requirement for the program to work correctly. The maximum iterations can prevent your program from producing a root estimate within the required tolerance. If that is the case, increase the number of iterations. The size of the range you select will partially determine how many iterations are required to find a root that provides the required tolerance.

Program Output: Your program will display a message showing the root you found.

Program strategy: The part of your program that calculates the root will consist of a loop that continues until the difference between the polynomial value at the latest estimate of the root is less than the absolute value of the tolerance you entered, or the maximum number of iterations has been exceeded. In each iteration, your loop will do the following: calculate the value of the polynomial at the lower bound we will call it pValLow here calculate the value of the polynomial at the upper bound we will call it pValHigh here calculate a new estimate for the the root as newEst=lowValpValLow( lowValhighVal pValLowpValHigh ) calculate the value of the polynomial at the new estimate we will call it pValNew here You now want to shrink the range holding the root by setting the either the lower bound or the upper bound to the new root estimage. You decide which bound to change by comparing the sign of pValNew with pValLow: if pValNew and pValLow have opposite signs (one is positive and one is negative), then new root estimate becomes the new upper bound otherwise, the new root estimate becomes the new lower bound Don't forget to increment the number of iterations by one.

Checking your program: You program have found a correct estimate of the root, if the value of the polynomial at the estimates is less than the tolerance you have given. You can take the root you found with your program and validate that it is close to the real root using an Excel spreadsheet. Create a formula for the polynomial and type your program's result in the cell for x. Excel should show you a value that is close to zero (less than the absolute value of your tolerance). Deliverable: Submit your Java source file through Canvas by the due date specified. You will lose points if you do not use the file name PolyRoot.java for you program. Your program should begin with the following comments: // For Program 1, CS505CL Summer 2017 // Instructor: Prof David Pitts // Your name // Date

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!