Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 5, Problem 5.18HW
Program Plan Intro
Given C Code:
double poly(double a[], double x, long degree)
{
long i;
double result = a[0];
double xpwr = x;
for (i = 1; i <= degree; i++)
{
result += a[i] * xpwr;
xpwr = x * xpwr;
}
return result;
}
double polyh(double a[], double x, long degree)
{
long i;
double result = a[degree];
for(i=degree-1; i>=0; i--)
result = a[i] + x*result;
return result;
}
Cycles per element (CPE):
- The CPE denotes performance of program that helps in improving code.
- It helps to understand detailed level loop performance for an iterative program.
- It is appropriate for programs that use a repetitive computation.
- The processor’s activity sequencing is controlled by a clock that provides regular signal of some frequency.
Loop unrolling:
- It denotes a program transformation that would reduce count of iterations for a loop.
- It increases count of elements computed in each iteration.
- It reduces number of operations that is not dependent to program directly.
- It reduces count of operations in critical paths of overall computations.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a user-defined MatLab function I=Simp38(FunName,a,b) using the composite Simpson's 3/8 method. FunName is a handle function that calculates the value of the function to be integrated, a and b are the limits of integration and I is the value of the integral. The function should calculate the value of the integral in iterations. In the first iteration the interval [a,b] is divided in two subintervals and in every iterations that follows the number of subintervals should be doubled. Stop the iterations when the difference in the value between two successive iterations is smaller than 1%.
My apologies for misunderstanding. Here's the translation:
"A function,
f:f(x,y)=x2+2y2−12x+xy
is defined on the domain: Ω = {(x, y): -1 ≤ x ≤ 1, -1 ≤ y ≤ x}.
Create a contour plot of the function and plot the boundary of Ω with a dashed line:
In Python
Answer the given question with a proper explanation and step-by-step solution.
for the question above, the function defined in Python failed to pass the test, could you fix it?
Chapter 5 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Knowledge Booster
Similar questions
- Please show the work necessary to get the answer.arrow_forwardCreate a limit evaluation problem that requires substitution with an answer of 1. Please show the steps to solve the problem.arrow_forwardGive at least ten (10) examples of diverse circumstances to which you can relate as a function. We request that you abstain from duplicating the Google answer.arrow_forward
- Subject: Design Algorithm and analysis TOPIC: Asymptotic Notationsarrow_forwardLanguage is Matlabarrow_forwardCreate a MATLAB code that solves roots of non-linear equations using False-Position Method. The code should have the following features: Nonlinear function can be declared directly on the MLX file Accepts 2 initial limits of interval (bracketing values xu and xl) and the error tolerance Check if the initial limits of the interval has opposing function values. Check if the initial limits of the interval are roots of the inputted function. Displays the iteration table. (For more information, watch the Week 3 Lecture Video: ALTERNATIVE CODING FOR BISECTION METHOD ). Gives the following output values: approximate root, percent approximate relative error, number of iterations required to meet the condition (percent approximate relative error < error tolerance). Gives a non-convergence message when the condition (percent approximate relative error < error tolerance) is not met after 150 iterations.arrow_forward
- Give a complete problem formulation for each of the following problems. Choose a formulation that is precise enough to be implemented. d. A container ship is in port, loaded high with containers. There 13 rows of containers, each 13 containers wide and 5 containers tall. You control a crane that can move to any location above the ship, pick up the container under it, and move it onto the dock. You want the ship unloaded.arrow_forwardDevelop a user-defined MatLab function I =Comptrapez(FunName,a,b) of integrating afunction by using the composite trapezoidal method. FunName is a handle function that calculates the value of the function to be integrated, a and b are the limits of integration and I is the value of the integral. The function should calculate the value of the integral in iterations. In the first iteration the interval [a,b] is divided in two subintervals and in every iterations that follows the number of subintervals should be doubled. Stop the iterations when the difference in the value between two successive iterations is smaller than 1%. Thank you very mucharrow_forwardAnswer the given question with a proper explanation and step-by-step solution. Please provide solution in MATLAB.arrow_forward
- 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…arrow_forwardArgue the correctness of the following loop invariant for Do-Math(): result = x-z Be sure to argue both the initial condition and the maintenance condition.arrow_forwardPlease I want the code in python and the ploting of the curve of the empirical analysis by matplotlib and done the inductive proof scheme, so please follow the same instructions written in the question.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
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