Practice Problem 5.5 (solution page 575)
Suppose we wish to write a function to evaluate I polynomial where a polynomial of degree n is defined to have a set of coefficients a0, a1 a2 ….an. For a value x. we evaluate the polynomial by computing
(5.2) a() + a1x + a2x2 + + anxn (5.2)
This evaluation can be implemented by the following function, having as arguments an array of coefficients a, a value x, and the polynomial degree degree (the value n in Equation 5.2). In this function, we compute both the successive terms of the equation and the successive powers of x within a single loop:
- A. For degree n, how many additions and how many multiplications does this code perform?
- B. On our reference machine, with arithmetic operations having the latencies shown in Figure 5.12, we measure the CPE for this function to be 5.00. Explain how this CPE arises based on the data dependencies formed between iterations due to the operations implementing lines 7-8 of the function.
Figure 5.12 Latency, issue time, and capacity characteristics of reference machine operations. Latency indicates the total number of clock cycles required to perform the actual operations, while issue time indicates the minimum number of cycles between two independent operations. The capacity indicates how many of these operations can be issued simultaneously. The times for division depend on the data values.
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Additional Engineering Textbook Solutions
Modern Database Management
Digital Fundamentals (11th Edition)
Concepts of Programming Languages (11th Edition)
Starting Out with C++: Early Objects
Database Concepts (7th Edition)
- 2. C++ Implement a function for integrating a function by means of Riemann sums. Use the formula Write a function that returns the numerical derivative of a given function fat a given point x. using a given tolerance h. Use the formula Yx+h) -f(x-h) f(x) = %3D 2harrow_forwardENGINEERING • COMPUTER-ENGINEERING 2 - calculate the first four iterations for the approximate value of the root of the function f(x) = x*log(x) - 1 using the method below: a) Bissection Method. Use as interval for the root the values [2,3].arrow_forward1] Minimize the following boolean function- F(W, X, Y, Z) = Σm(1, 3, 4, 6, 9, 11, 12, 14) 2] This function is independent ________ number of variables. Fill in the blank.arrow_forward
- computer science questionarrow_forward(b) Based on the function below, answer the following question. Assume that helper(n) runs in O(n) time. 1 void problem_2_2_b (int n) { 2 if (n(floor (sqrt (n))) 6 for (int i = 0; i < 281; ++i) { helper (m); 8 for (int j = m; jarrow_forward2. (a) In this problem consider Newton's method. Write a PYTHON function computing an approximation of the root p of the equation 0 using Newton's method. Specifically the code will compute the terms xn of the = f(x) sequence f(xn) f'(xn)' Xn+1 = Xn n = 0, 1, 2, ..., where xo is a given initial guess (or approximation) of the root p. For stopping criterion use the following: If |xn+1 − xn| ≤ TOL for the first time, then return xn+1 as approximation of the root p. Allow the code to do only NMAX iterations. At every step n, the code should print the values n, xn, f(xn) and n+1- xn. In case where the number of iterations reaches the maximum allowed number of iterations without satisfying the stopping criterion, then the code should print an error message, for example: "Failure: Algorithm fail to converge using only NMAX iterations".arrow_forwardLet f(x)=√√x, g(x) = x + 12 and h(x) = Compute the following function value. (#)(4)arrow_forwardmake c+++ codearrow_forwardProblem 9.8 Write a program in your favourite programming lan- guage which computes a* mod (n) for given natural umbers a, k > 1 and n > 1. Use your software and Fermat's little theorem to show that 57, 645, and 10261 are not prime numbers.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education