Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def P3 (x) : return 3*x*x*x + 13. 6*x*x + 13.2*x + 47.8 Roots of polynomials can be found using function goalSeek if you supply

image text in transcribed
def P3 (x) : return 3*x*x*x + 13. 6*x*x + 13.2*x + 47.8 Roots of polynomials can be found using function goalSeek if you supply the tested polynomial function as the function parameter, set the target parameter equal to zero, and start with a good LowLimit and HighLimit interval enclosing the root. Note that goalSeek requires that the tested function f is such that f(LowLimit) s target s f(HighLimit). All polynomials provided for this task will satisfy this requirement. For this test, you are provided with the file poly.txt containing coefficients of 25 polynomials. The first few lines of the file look as follows: # A B D Lo Hi Formula 3 -1. 8 -7.6 -20.8 -4.28 1 1. 88 3 x 3 - 1.8 x 2 - 7.6 x - 20.8 2 5 14 24 -6.57 0. 73 2 x 3 + 5 x 2 + 14 x + 24 2.7 7.59 9 . 49 3 . 85 -1. 86 5 . 85 2.7 x3 + 7.59 x^2 + 9.49 x + 3.85 1 - 8 - 32 0. 44 10.58 x 3 - 8 x - 32 . . . The first line is a header, you will have to skip it when reading the file. Each of the following lines starts with the four coefficients A, B, C, D, uniquely determining a polynomial Ax3 + Bx2 + Cx+D. The coefficients are followed by the suggested Lo and Hi limits. Each provided polynomial is guaranteed to have exactly one root in the interval Lo s x s Hi. We will use goalSeek to find this root for each of the provided polynomials. The last column is a conventional representation of a polynomial, which you can be pasted in WolframAlpha to confirm that your program correctly finds the roots. For example, here is the response for the first polynomial in the file, in particular it says that the real root is equal to 2.6. Task In this task, we are going to write a program test7.py that finds the roots of cubic polynomials listed in the file poly.txt using goalSeek function

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

s) customer charters and codes of practice

Answered: 1 week ago