Exercise 1.3 : Approximation of functions The function can be approximated by the series )=1+x+デ++ as long as x<1. We would like to explore how many terms are needed to make the difference between f(x) and this series approximation smaller than a given tolerance. For example, for an error of 1x 10- and x=0 only one term from the series is needed, while for x= 1/2 = 2 1-(1/2) and 1 1 1+えttt son=5 terms is enough for an error of I x 10- and x 1/2 - 1.9375 (a) Write a function void numberofTerms (double x, double error, int n)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.7: Do While Loops
Problem 6E: (Numerical analysis) Here’s a challenging problem for those who know a little calculus. The...
icon
Related questions
Question
Exercise 1.3 : Approximation of functions
The function
(1) =
can be approximated by the series
()~1+x+パ++
as long as x] < 1. We would like to explore how many terms are needed to make the difference between f(x) and this series
approximation smaller than a given tolerance.
For example, for an error of 1x 10- and x=0 only one term from the series is needed, while for x=1/2
= 2
1-(1/2)
and
1.
1.
1+ラt *
- 1.9375
22
so n=5 terms is enough for an error of 1 x 10" and x1/2
(a) Write a function
void numberofTerms (double x, double error, int n)
that will for any value of x less then 1 in magnitude compare the series to the exact function and determine the minimum
number of terms needed to make their difference less than a specified error. Make sure you protect your function
against bad inputs using control structures.
(b) Write a driver program that tests the function numberofTerms written in 1.3(a).
Transcribed Image Text:Exercise 1.3 : Approximation of functions The function (1) = can be approximated by the series ()~1+x+パ++ as long as x] < 1. We would like to explore how many terms are needed to make the difference between f(x) and this series approximation smaller than a given tolerance. For example, for an error of 1x 10- and x=0 only one term from the series is needed, while for x=1/2 = 2 1-(1/2) and 1. 1. 1+ラt * - 1.9375 22 so n=5 terms is enough for an error of 1 x 10" and x1/2 (a) Write a function void numberofTerms (double x, double error, int n) that will for any value of x less then 1 in magnitude compare the series to the exact function and determine the minimum number of terms needed to make their difference less than a specified error. Make sure you protect your function against bad inputs using control structures. (b) Write a driver program that tests the function numberofTerms written in 1.3(a).
The report should contain the following sections:
1. list of files: list of each file contained in your submission.
2. usage: This section should explain how to use your program.
3. implementation: this section should provide a brief description of each of your program organization
and its implementation.
4. Bugs: This section should mention any known bugs. If you are unaware of any bugs, simple
place "NONE" under this heading.
Transcribed Image Text:The report should contain the following sections: 1. list of files: list of each file contained in your submission. 2. usage: This section should explain how to use your program. 3. implementation: this section should provide a brief description of each of your program organization and its implementation. 4. Bugs: This section should mention any known bugs. If you are unaware of any bugs, simple place "NONE" under this heading.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr