(a) Write a C++ function with the following header double polyval(std::vector coeff, double x) which evaluates any specified real polynomial at a given point. The parameter coeff stores the coefficients of the polynomial from the lowest term to the highest and the parameter x stores the point at which the polynomial is to be evaluated. For instance, the expression polyval({-4,2,7,-8,8,4}, 1.5) evaluates to 58.625, i.e. the value of P(x) 4r +8r-8r + 7 +2r - 4 at z=1.5 (5 marks) (b) Write a C++ program that allows the user to enter (the coefficients of) a real polynomial and compute the real zero (if it exists and is unique) within a specified interval using the bisection method. You may use the code from part (a). For instance, if the user would like to find the real zero of the polynomial p(x) = 4r + 8r - 8z + 7z + 2r - 4 within the interval l-3,-1], then the following should be the output of the program: what is the degree of the polynomial? 5 Enter the coefficients from the lowest term to the highest: -4 27 -8 8 4 Enter the endpoints of the interval: -3 -1 Enter the tolerance: 1E-8 The zero of the polynomial -2.87255 Also, if the user tries to look for a real zero of the same polynomial within the interval 2. 5). then the program should issue a message indicating the failure of the method: what is the degree of the polynomial? 5
(a) Write a C++ function with the following header double polyval(std::vector coeff, double x) which evaluates any specified real polynomial at a given point. The parameter coeff stores the coefficients of the polynomial from the lowest term to the highest and the parameter x stores the point at which the polynomial is to be evaluated. For instance, the expression polyval({-4,2,7,-8,8,4}, 1.5) evaluates to 58.625, i.e. the value of P(x) 4r +8r-8r + 7 +2r - 4 at z=1.5 (5 marks) (b) Write a C++ program that allows the user to enter (the coefficients of) a real polynomial and compute the real zero (if it exists and is unique) within a specified interval using the bisection method. You may use the code from part (a). For instance, if the user would like to find the real zero of the polynomial p(x) = 4r + 8r - 8z + 7z + 2r - 4 within the interval l-3,-1], then the following should be the output of the program: what is the degree of the polynomial? 5 Enter the coefficients from the lowest term to the highest: -4 27 -8 8 4 Enter the endpoints of the interval: -3 -1 Enter the tolerance: 1E-8 The zero of the polynomial -2.87255 Also, if the user tries to look for a real zero of the same polynomial within the interval 2. 5). then the program should issue a message indicating the failure of the method: what is the degree of the polynomial? 5
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
![(a) Write a C++ function with the following header
double polyval(std::vectorcdouble> coeff, double x)
which evaluates any specified real polynomial at a given point. The parameter coeff
stores the coefficients of the polynomial from the lowest term to the highest and the
parameter x stores the point at which the polynomial is to be evaluated. For instance,
the expression
polyval({-4,2,7,-8,8,4}, 1.5)
evaluates to 58.625, i.e. the value of P(r) = 4r + 8r - 8r+ 7r + 2r
I = 1.5
4 at
(5 marks)
(b) Write a C+ program that allows the user to enter (the coefficients of) a real polynomial
and compute the real zero (if it exists and is unique) within a specified interval using the
bisection method. You may use the code from part (a). For instance, if the user would
like to find the real zero of the polynomial p(r) = 4r + 8r* - 8z + 7 + 2r - 4
within the interval l-3, -1], then the following should be the output of the program:
What is the degree of the polynomial? 5
Enter the coefficients from the lowest term to the highest:
-4 27 -8 8 4
Enter the endpoints of the interval:
-3 -1
Enter the tolerance:
1E-8
The zero of the polynomial - -2.87255
Also, if the user tries to look for a real zero of the same polynomial within the interval
2. 51. then the program should issue a message indicating the failure of the method:
What is the degree of the polynomial? 5](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe9bdff84-0b0a-4902-9f2a-b91646ccd71d%2Fcb4ce242-27c4-4411-babd-6d3643b4226d%2Fb14ykca_processed.jpeg&w=3840&q=75)
Transcribed Image Text:(a) Write a C++ function with the following header
double polyval(std::vectorcdouble> coeff, double x)
which evaluates any specified real polynomial at a given point. The parameter coeff
stores the coefficients of the polynomial from the lowest term to the highest and the
parameter x stores the point at which the polynomial is to be evaluated. For instance,
the expression
polyval({-4,2,7,-8,8,4}, 1.5)
evaluates to 58.625, i.e. the value of P(r) = 4r + 8r - 8r+ 7r + 2r
I = 1.5
4 at
(5 marks)
(b) Write a C+ program that allows the user to enter (the coefficients of) a real polynomial
and compute the real zero (if it exists and is unique) within a specified interval using the
bisection method. You may use the code from part (a). For instance, if the user would
like to find the real zero of the polynomial p(r) = 4r + 8r* - 8z + 7 + 2r - 4
within the interval l-3, -1], then the following should be the output of the program:
What is the degree of the polynomial? 5
Enter the coefficients from the lowest term to the highest:
-4 27 -8 8 4
Enter the endpoints of the interval:
-3 -1
Enter the tolerance:
1E-8
The zero of the polynomial - -2.87255
Also, if the user tries to look for a real zero of the same polynomial within the interval
2. 51. then the program should issue a message indicating the failure of the method:
What is the degree of the polynomial? 5

Transcribed Image Text:Enter the coefficients from the lowest term to the highest:
-4 2 7 -8 8 4
Enter the endpoints of the interval:
25
Enter the tolerance:
1E-8
Unable to determine whether a root exists.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education