Write a short program to evaluate the magnitude of the relative error in evaluating using f_hat for the input x. f_hat(x) is a function that evaluates an approximation to for a given floating point input . x is a floating point number. Store the magnitude of the relative error in using the approximation f_hat in relative_error.

Respuesta :

Answer:

The code is as below. The solution is given in python and can be converted  to other programming language.

Explanation:

As the language is not identified, it is assumed that the requirement of the language is python

As the complete question is missing, here the link to complete question is given in the comments above.

From the complete question, it is given that the approximated solution is for x86 instruction. thus as the x86 instructions are for integers only thus the complete code is as follows: Here the code is given as

#Defining the function

def relerror(x):

   x=float(x);

   y=int(x)

   f_h=y**(0.72);

   f=x**(0.72);

   absol=abs(f_h-f);

   rel=absol/f;

   relp=(absol/f)*100;

   print('The relative error for',x,' as value of x when approximated as x86 routine is ',round(relp,2),'%')

   

   #Main program calling given function

x=input('Please enter a value in float')

relerror(x)

Ver imagen danialamin