Suppose in the year 2102 that evaluating 0.72 for an input parameter becomes an important operation to do quickly. As such, CPU manufacturers want to approximate this operation in hardware using a single x86 operation, f_p72. As a computer engineer, you are tasked with creating the necessary components to execute the f_p72 instruction. Suppose that the function f_hat (x) carries out the f_p72 instruction for a given floating point input x. That is, f_hat (x) evaluates the approximation of x0.72 Write a short program that evaluates the magnitude of the relative error in approximating 0.72 using f hat for the input x.

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

Python code, the code that I have is wrong. I am getting a error "'relative_error' is inaccurate"

Suppose in the year 2102 that evaluating 0.72 for an input parameter becomes an
important operation to do quickly. As such, CPU manufacturers want to approximate
this operation in hardware using a single x86 operation, f_p72. As a computer engineer,
you are tasked with creating the necessary components to execute the f_p72
instruction. Suppose that the function f_hat (x) carries out the f_p72 instruction for a
given floating point input x. That is, f_hat (x) evaluates the approximation of x0.72
Write a short program that evaluates the magnitude of the relative error in
approximating 0.72 using f_hat for the input x.
f_hat (x) is a function that returns the approximation 0.72 for a given floating point
input x. Store the magnitude of the relative error in using the approximation f_hat in
relative_error.
The setup code gives the following variables:
Name Type
f_hat function
X
Name
floating point
number
Your code snippet should define the following variables:
Description
a function which has the same effect as the f_p72
instruction
a floating point number
Type
relative_error floating point
number
user_code.py
1
2
3
4
5
6
Description
the relative error in approximating x0.72
using f_hat
import math
def f_hat (x):
# This is a placeholder for the actual approximation function
#Replace this with the actual function when available
return x ** 0.72
7
8 x = 10.0# Replace with actual input value
9 actual value = x ** 0.72
approximation f_hat (x)
10
11
12 relative_error = abs((approximation
actual_value)
actual_value) /
Transcribed Image Text:Suppose in the year 2102 that evaluating 0.72 for an input parameter becomes an important operation to do quickly. As such, CPU manufacturers want to approximate this operation in hardware using a single x86 operation, f_p72. As a computer engineer, you are tasked with creating the necessary components to execute the f_p72 instruction. Suppose that the function f_hat (x) carries out the f_p72 instruction for a given floating point input x. That is, f_hat (x) evaluates the approximation of x0.72 Write a short program that evaluates the magnitude of the relative error in approximating 0.72 using f_hat for the input x. f_hat (x) is a function that returns the approximation 0.72 for a given floating point input x. Store the magnitude of the relative error in using the approximation f_hat in relative_error. The setup code gives the following variables: Name Type f_hat function X Name floating point number Your code snippet should define the following variables: Description a function which has the same effect as the f_p72 instruction a floating point number Type relative_error floating point number user_code.py 1 2 3 4 5 6 Description the relative error in approximating x0.72 using f_hat import math def f_hat (x): # This is a placeholder for the actual approximation function #Replace this with the actual function when available return x ** 0.72 7 8 x = 10.0# Replace with actual input value 9 actual value = x ** 0.72 approximation f_hat (x) 10 11 12 relative_error = abs((approximation actual_value) actual_value) /
Expert Solution
steps

Step by step

Solved in 4 steps with 2 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