Calculus/Question
Expert: Scotto - 6/29/2010
QuestionUse Trapizoid Rules to estimate Integral of 0 to 1 of 551x^550 dx. Find the value of n such that the error ETn > M(b-a)^3/12n^2
Can you guide me through this
I have no idea what to do here , we have to write a preogram for it. So what will be the code for this so that ETn > M(b-a)^3/12n^2
M= 550*551*549 ETn = Abosulute Value of 1 - Tn
AnswerIt should be noted that the value of the integral is x^551 evaluated from 1 downto 0,
and that this value is 1.
The error on the Trapezoidal Rule is [(b-a)³/(12n²)]f"(x) for some x in [a,b].
Note that f'(x) = 551*550*x^549 and f"(x) is then 551*550*549*x^548.
For the interval [0,1], the max is at x=1, so x^548 is also 1 at this point.
What we are left with is 551*550*549/(12n²) = 13,864,538/n³.
It seems like the program needs to accept n as input and then output the maximum that the error term could be as 551*550*549/(12n²), or 13,864,538/n².
In C++, it would be (roughly):
/* This program is to approximate the integral of 551*x^550 on the interval [0,1]. */
program approx()
{
int n; /* number of terms used */
double error; /* error involved with that many terms */
double value; /* value of the integral */
double power (double a, double b) /* to compute a^b */
{ return (exp(b*ln(a)); }
double f (double x) /* to compute the value of f */
{ return (551*power(x,550)); }
double trap (int n) /* trapezoidal rule */
{
int sum=0; /* value of the sum */
int i; /* used in for loop */
for (i=0; i<n; i++)
sum += (1/n)*(f(i/n) + f(i+1))/2
return (sum);
}
n = getint("Number of terms? ");
error = 13864538/n^3;
value = trap(n);
}
After writing this, I then thought about how accurate it would be.
If the accuracy were, say, 12 digits, then 0.94^550 and less would be considered 0 when added on to the last few terms.
Thinking of this, I did it in Excel with the x values of
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
0.91
0.92
0.93
0.94
0.95
0.96
0.97
0.98
0.99
0.991
0.992
0.993
0.994
0.995
0.996
0.997
0.998
0.999
1
and the y values of x^n for n =1 to make sure it was correct, then y = (n+1)x^n.
For n = 5, I get an error of 0.016438222%. For n = 50, the error is 2.147271686%.
For n = 250, the error is 4.36908891%. For n = 550, the error is still only 3.21263494%.
That does amaze me on the accuracy.
My approach was to take the intervals of width 0.1 until 0.9 was reached,
then 0.01 until 0.99 was reach, and then 0.001 until 0.999 was reached.
The interval width could then be divided by 10 again when 0.9999 was reached,
and by 10 again until 0.99999 was reached, and then by ...
This division was done since most of the accuracy was in the last few terms and the first terms would only result in rounding error.
A good way to aproach this problem would be to use 1/n instead of where I used 1/10.
For example, if n=2 was used, it would be (f(0)+f(1/2))/2 + (f(1/2)+f(3/4))/4 + (f(3/4)+f(7/8))/8
To get more accuracy, increase n. Thus, the general formula would be to take the first n-1 intervals and then divide the last interval into n subintervals. After taking the first n-1 intervals in that, divide the last interval into n-1 intervals. This could be repeated for as long as it was desired, and on the last one, just use th nth interval like the first n-1 intervals in that interval.
If more explanation is needed on any paragraphs, I'll be glad to give it to you.