IN PYTHON PLEASE AND THE ANSWER SHOULD BE MATCHING THE SAME NUMBERS IN THE QUESTIONS Write a Python function to compute f(x) = 1 − cos(x) for inputs in the range −1 < x < 1 with fractional error under 10*eps. Check your function by verifying that, to 14 significant digits, it returns f(10−4) = 4.9999999958333 × 10−9 and f(0.9) = 0.37839003172934. Hint: Subtracting 1 − cos(x) directly is accurate if cos(x) is not close to 1, but incurs subtractive cancellation when x is close to 0.
IN PYTHON PLEASE AND THE ANSWER SHOULD BE MATCHING THE SAME NUMBERS IN THE QUESTIONS Write a Python function to compute f(x) = 1 − cos(x) for inputs in the range −1 < x < 1 with fractional error under 10*eps. Check your function by verifying that, to 14 significant digits, it returns f(10−4) = 4.9999999958333 × 10−9 and f(0.9) = 0.37839003172934. Hint: Subtracting 1 − cos(x) directly is accurate if cos(x) is not close to 1, but incurs subtractive cancellation when x is close to 0.
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...
Related questions
Question
IN PYTHON PLEASE AND THE ANSWER SHOULD BE MATCHING THE SAME NUMBERS IN THE QUESTIONS
Write a Python function to compute f(x) = 1 − cos(x) for inputs in the range −1 < x < 1 with fractional error under 10*eps. Check your function by verifying that, to 14 significant digits, it returns f(10−4) = 4.9999999958333 × 10−9 and f(0.9) = 0.37839003172934.
Hint: Subtracting 1 − cos(x) directly is accurate if cos(x) is not close to 1, but incurs subtractive cancellation when x is close to 0.
The IMAGE BELOW IS NOT THE CORRECT ANSWER IT DOESN’T MATCH THE EXAMPLE EXACT NUMBERS AS SHOWN ABOVE THE CODE I NEED SHOULD OUTPUT THE SAME EXACT ANSWER AS PROVIDED IN THE QUESTION AND NOT WHAT IN THE IMAGE ATTACHED
THANK YOU FOR YOUR TIME!

Transcribed Image Text:# import numpy as np
import numpy as np
# function to calculate the value
def f(x):
return 1 np.cos(x) # return the result
print (f(10**-4)) # call the function for x=10^-4
print (f(0.9)) # call the function for x=0.9
4.999999969612645e-09
0.3783900317293356
Expert Solution

Step 1
Python code to solve the equation
f(x) = 1- cox(x)
Step by step
Solved in 2 steps with 2 images

Recommended textbooks for you

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY