### Explain the maths behind this question.

This is the question:
[b]the function 1/(1-x) can be expanded infinitely in the form 1 + x + x^2 + x^3 + x^4 + ....
If the number of terms are truncated then the approximation is in error by some value that can be calculated by the difference between the two expressions. Write a program that asks for the input value of x, and a maximum error value. The program output is how many terms are required in the expansion.[/b

So what exactly does this question ask for, can someone simplify it and more helpful if u can write a code that performs something similar (or the exact code for this problem).

Much appreciated thanks.
Howlz wrote:
 So what exactly does this question ask for, ... ?

It seems pretty straightforward. You have 2 functions, one exact, and the other approximate. Your program should prompt the user for two parameters; the value at which the functions are evaluated (x), and the maximum difference between the 2 functions when evaluated at x. The program outputs the number of terms the approximate function needs to have in order to meet the maximum difference constraint.

You will need to have a counter that keeps track of the terms in the approximate function. Loop the approximate function, adding a new term in each iteration, until the approximate function value value is close enough to the exact function value.

Howlz also wrote:
 ... can someone ... write ... the exact code for this problem?

No.

If you post the code you have written so far, others will critique it and offer suggestions to improve it. Few will do your homework for you.
Start with the bits that are simple:
 ```Write a program that asks for: input value of x maximum error value```

Next, find the value of
 `1/(1-x) (A)`

That leaves one more part to complete, calculate the sum of the series
 `1 + x + x^2 + x^3 + x^4 + .... (B)`

You will use a loop to calculate this. Since the series is infinite, you need to tell the program when to stop. You do this by comparing the difference between results (A) and (B). When the difference is less than the required error value, you can stop. Then output the result, which is the count of how many terms of the series were required (how many times was the loop executed).
Last edited on
Topic archived. No new replies allowed.