function. Therefore, in this homework you need to write a C+ program that does the following: Read the value of x (first column) and number of terms n (second column) from a file called input.txt input.txt x 3 8 5 11 13 4 8 13 8 2 Compute the value of exp (x) based on both the formula above and the predefined function exp(x) in cmath library and compute the difference between these two values that represents the error. 62

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
tat..
The exponential function exp(x) can be characterized in a variety of equivalent
ways. Most commonly, it is defined by the following power series:
expo==1+x+
2 3!
n!
However, based on above formula, n should be infinity that cannot be reached.
Choosing the suitable number of terms in the summation affects the value of the
function. Therefore, in this homework you need to write a C++ program that does
the following:
Read the value of x (first column) and number of terms n (second column) from a
file called input.txt
input.txt x
3
8
11
6
13
4
8
13
8
2|
Compute the value of exp (x) based on both the formula above and the predefined
function exp(x) in cmath library and compute the difference between these two
values that represents the error.
The program should have three user-defined functions to perform the following
tasks:
1. Compute the n! to be used in the above series
2. Compute the estimated exponential function as given by the above series.
3. Compute the error, difference between estimated and predefined values.
Formats the output as shown below (Use 4 decimal places for all real numbers)
C. C:\Windows\system32\cmd.exe
estimated exp(x)
predefined exp(x)
error
20.0092
20.0855
e.0764
147.6038
148.4132
e.8093
406.6275
403.4288
3.1987
ө.3891
94.3681
7.0000
7.3891
3075.3260
2980.9580
41.0000
2980.9580
2939.958e
41.0000
2980.9580
2939.9580
Press any key to continue .
Transcribed Image Text:tat.. The exponential function exp(x) can be characterized in a variety of equivalent ways. Most commonly, it is defined by the following power series: expo==1+x+ 2 3! n! However, based on above formula, n should be infinity that cannot be reached. Choosing the suitable number of terms in the summation affects the value of the function. Therefore, in this homework you need to write a C++ program that does the following: Read the value of x (first column) and number of terms n (second column) from a file called input.txt input.txt x 3 8 11 6 13 4 8 13 8 2| Compute the value of exp (x) based on both the formula above and the predefined function exp(x) in cmath library and compute the difference between these two values that represents the error. The program should have three user-defined functions to perform the following tasks: 1. Compute the n! to be used in the above series 2. Compute the estimated exponential function as given by the above series. 3. Compute the error, difference between estimated and predefined values. Formats the output as shown below (Use 4 decimal places for all real numbers) C. C:\Windows\system32\cmd.exe estimated exp(x) predefined exp(x) error 20.0092 20.0855 e.0764 147.6038 148.4132 e.8093 406.6275 403.4288 3.1987 ө.3891 94.3681 7.0000 7.3891 3075.3260 2980.9580 41.0000 2980.9580 2939.958e 41.0000 2980.9580 2939.9580 Press any key to continue .
Expert Solution
steps

Step by step

Solved in 3 steps with 1 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