Exercise 4B (1) Write a function which takes a list of the coefficients of a polynomial P(x) = ª₁ + ª₁x + a² + ... + anxn of arbitrary degree n, and a value of xo, and returns P(xo). You can use the function given in lectures, ensuring you understand how it works.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Exercise 4B
(1) Write a function which takes a list of the coefficients of a polynomial
P(x) = ª₁ + ª₁x + a² + …..
+anxn
of arbitrary degree n, and a value of x, and returns P(x). You can use the function given in lectures,
ensuring you understand how it works.
(2) Use the function to evaluate
(a) P₁(x) = 4x4 + 3x² + 2 at x = 2.
(b) P₂(x) = 2 — ¹x¹ at x = √√/2.
Are these answers exact? Explain why or why not.
(Use a print statements to show the evaluation of your function, and answer the question in a comment.)
(3) The power series for the sine function sin(x) is given by
∞
x2n+1
(2n + 1)!
sin(x) = Σ(−1)”.
n=0
= x
6
+
x5
120
for all x. Use the first four terms in this series in the Horner evaluation function at a suitable value of a to
give an approximation of sin(π/4).
(4) (a) Use your Horner's method function to evaluate the polynomial (x − 1)³ at the point
x = 1.000001.
(b) Is this answer correct?
(c) Briefly explain why, or why not.
(5) In week 3 we wrote a function to convert from binary to decimal. This can be adapted to other
bases, here will explore octal (base 8). The efficiency of the function we wrote can be improved using the
same principle as Horner's method. Write such a function (horner_octal_to_dec) using the ideas of
Horner's method which takes a list whose entries are integers between 0 and 7, where the list represents
a base-8 number, and returns the corresponding decimal integer (so the input [2,5,1] returns the
integer 169).
Transcribed Image Text:Exercise 4B (1) Write a function which takes a list of the coefficients of a polynomial P(x) = ª₁ + ª₁x + a² + ….. +anxn of arbitrary degree n, and a value of x, and returns P(x). You can use the function given in lectures, ensuring you understand how it works. (2) Use the function to evaluate (a) P₁(x) = 4x4 + 3x² + 2 at x = 2. (b) P₂(x) = 2 — ¹x¹ at x = √√/2. Are these answers exact? Explain why or why not. (Use a print statements to show the evaluation of your function, and answer the question in a comment.) (3) The power series for the sine function sin(x) is given by ∞ x2n+1 (2n + 1)! sin(x) = Σ(−1)”. n=0 = x 6 + x5 120 for all x. Use the first four terms in this series in the Horner evaluation function at a suitable value of a to give an approximation of sin(π/4). (4) (a) Use your Horner's method function to evaluate the polynomial (x − 1)³ at the point x = 1.000001. (b) Is this answer correct? (c) Briefly explain why, or why not. (5) In week 3 we wrote a function to convert from binary to decimal. This can be adapted to other bases, here will explore octal (base 8). The efficiency of the function we wrote can be improved using the same principle as Horner's method. Write such a function (horner_octal_to_dec) using the ideas of Horner's method which takes a list whose entries are integers between 0 and 7, where the list represents a base-8 number, and returns the corresponding decimal integer (so the input [2,5,1] returns the integer 169).
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY