An archived instance of a Calc II forum

A long personal integral

mark

(10 pts)

In this problem, you’re going to find one approximation to a familiar integral. You’re not given the number of terms to use, but rather the accuracy to which you would like to estimate the integral. Of course, we have inequalities at the bottom of this webpage that relate the number of terms to the accuracy. We can also use Desmos to find absolute bounds on first and second derivatives, if necessary.

In this problem, we care very much about the actual numerical estimate to within the desired accuracy and we would like to obtain that estimate without over burdening our computer.

To get your integral, sum type, and desired accuracy, choose your name from the following drop down menu:

audrey

I’m asked to compute

\int_1^3 e^{-2x^2}\,dx

to within an error of 0.001 of the actual value using a midpoint sum. I know that, if I use n terms, I should have

\displaystyle \text{error} \leq M_2\frac{(b-a)^3}{24n^2},

where M_2 is a bound on the second derivative. Using this Desmos graph, I can see that |f''(x)|<2 for all x in the interval. Thus, I’ll take M_2=2. Then,

\displaystyle \text{error} \leq 2\frac{(3-1)^3}{24n^2} = \frac{2}{3n^2} \stackrel{\color{lightgray}\text{want}}{\leq} 0.001.

If I solve that last inequality for n, I get

n > \sqrt{\frac{2}{3\times0.001}} \approx 25.8199.

Thus, I’ll choose n=26. My sum should like

\sum_{i=1}^{26} e^{\large -2(1+\frac{1}{26} + \frac{2i}{26})^2}\frac{1}{26}.

Using this Sage code, I find this to be about 0.0283796867109198.


Note, if I had a trapezoidal sum, I would’ve had the inequality

\displaystyle \text{error} \leq 2\frac{(3-1)^3}{12n^2} = \frac{4}{3n^2} \stackrel{\color{lightgray}\text{want}}{\leq} 0.001

and would’ve needed 37 terms, which I could have evaluated this way.

jcastel1

My integral is \int_0^{2}\sqrt {1+x^4}dx I used midpoint sum and an error of .001:

Using Desmos I found my M_2=3 so for the error I got:

\text{error} \leq 3\frac{(2-0)^3}{24n^2} = \frac{1}{n^2} \stackrel{\color{lightgray}\text{want}}{\leq} 0.001

When I solved for n I got:

n > \sqrt{\frac{1}{0.001}} \approx 31.6227766

I chose n=32. My sum is:

\sum_{i=1}^{32}\sqrt {1+\left(\frac{\frac {i}{16}+(\frac {i-1}{16})}2\right)^4}*\frac1{16}

Using this sage code I got:3.65285288434969

smarsha1

I was instructed to estimate the integral: \int_{-1}^{1} \sqrt{1+x^4} \, dx within an error of 0.001 using a trapezoidal sum.

I found this using the formula: \displaystyle \text{error} \leq M_2\frac{(b-a)^3}{12n^2}.

with M_2 = 12 which I got from Desmos.

using M_2 = 12 I got:

\displaystyle \text{error} \leq 12\frac{(1-(-1))^3}{12n^2} = 12\frac{8}{12n^2}= \frac{8}{x^2}{\leq} 0.001.
which gives me: n > \sqrt{\frac{8}{0.001}} \approx 89.4427191.

and thus I choose n to be 90.

This gave me a sum of:

\displaystyle \sum_{i=1}^{n} \frac{f(x_i) + f(x_{i-1})}{2}\Delta x = \displaystyle \sum_{i=1}^{90} \frac{f(\frac{8}{i^2}) + f(\frac{8}{(i-1)^2})}{2}\times\frac{1}{45}

mark

@smarsha1 Can you find the decimal value of the sum??

mcollin5

I was asked to compute

\int_0^1 sin(\pi x)\,dx

Within 0.001 of the actual value using a midpoint sum.
Using the error formula:

\displaystyle \text{error} \leq M_2\frac{(b-a)^3}{24n^2},

and knowing that M_2 is a bound on the second derivative, I saw that |f''(x)|<10
the error formula then becomes:

\displaystyle \text{error} \leq 10\frac{(1-0)^3}{24n^2} = \frac{10}{24n^2} \stackrel{\color{lightgray}\text{want}}{\leq} 0.001.

Solving for the inequality I get:

n > \sqrt{\frac{10}{24\times0.001}} \approx 20.4124.

So, n=21 and the summation formula would look like:

\sum_{i=1}^{21} sin(\pi( \frac{(\frac{i}{21} + \frac{i-1}{21})}{2}) \frac{1}{21}

With the sage code the answer is about 0.637213809507369

rmeares

I’m asked to compute \int_1^2sin(\pi x)dx using a trapezoidal sum within an error of 0.001 of the actual value.

To start I will be using the formula \text{error} \leq M_2\frac{(b-a)^3}{12n^2} with M_2=10 according to a graph of the second derivative of f(x).

Or formula now becomes,

\text{error} \leq 10\frac{(2-1)^3}{12n^2}

=\text{error} \leq\frac{5}{6n^2}

=\frac{5}{6n^2} \stackrel{\color{lightgray}\text{want}}{\leq} 0.001

=n > \sqrt{\frac{5}{6\times0.001}} \approx 28.868

Using n=29, the final summation formula will be,

\sum_{i=1}^{29} \frac{sin(\pi x_i)+sin(\pi x_{i-1})}{2}\times\frac{1}{4}

With sage code the answer is 0.636931711762451

bjohnso9

I was asked to compute:

\int_0^{2} \sqrt{16-x^2}\ dx

within an error of 0.001 using a trapezoidal sum. I calculated the upper bound (M_2) to be approximately 1. Then, using the error formula, I calculated:

0.001 \leq \frac {2^3}{12n^2} = \sqrt{ \frac {8}{12*0.001}} < n \\\\\ n \approx 26

I then set up the sum:

\sum_{i=1}^{26} \frac {\sqrt{16- \left(\frac{i}{13}\right)^2}+\sqrt{16- \left(\frac{i-1}{13}\right)^2}}{2}* \frac{1}{13}

I then used sage code to approximate the numerical value:

\approx 7.65260713979800
mpasour

I have the integral

\int_0^4 cos(x^4)dx

I first used the trig half angle formulas to get

\int_0^4 \frac{1}{4}(cos(2x))^2

I was asked to compute an error of 0.001 for a trapezoidal sum which is calulated using the formula

\text{error} \leq M_2\frac{(b-a)^3}{12n^2}

Then using this graph from desmos I found that
M_2=3

So to calculate my error I plugged in

0.001 \leq 3\frac{(4-0)^3}{12n^2}=3\frac{4^3}{3n^2}=\frac{192}{12n^2}=\frac{16}{n^2}\leq0.001

After solving for n, I get

n > \sqrt{\frac{16}{0.001}}\approx126.491106407

I chose n=127. My sum should look like:

\sum_{i=1}^{127}\frac{\frac14(1+cos(2i))^2}{2}*1

Using the sage code, I found this to be 0.630995877757818

Graham

My integral:

\int_{-1}^{1} \frac{1}{1+x^4}dx

I was asked to estimate using a midpoint sum. But first I had to find the minimum value of n for an error of less than 0.001. Here’s the error formula for a midpoint sum:

\text{error} \leq M_2\frac{(b-a)^3}{24n^2}.

I found the second derivative of the function inside my integral:

32x^6(1 + x^4)^{-3}

Which looked like this in Desmos:

I thus assigned M_2 a value of 4.

I plugged in the appropriate values and solved for n:

0.001 \le 4*\frac{2^3}{24n^2}
n^2 \ge 4*\frac{2^3}{24*0.001}
n \ge \sqrt{4*\frac{2^3}{24*0.001}}
n \ge 36.51 \ \ \ \ \ \ \ n = 37

An n value of 37 certainly gets me well within 0.001 of the value the Prof. McClure’s numerical integrator gives, but I also got within 0.001 with n values as low as 19. I’m not sure if this means I did the error calculation wrong, or if it means the formula sometimes gives an n value higher than necessary for the given error.

Anyway, I coded my homemade numerical integrator for this problem in C++. Check out the code:

#include <iostream>

using namespace std;

inline double toTheFourthPower(double x){
x *= x;
x *= x;
return x;
}

int main(){
cout << “What value of n do you want?” << endl;
int n;
cin >> n;

double deltaX = 2.0/n;
double midpoint = -1 + deltaX/2;

double sum = 0;
for (int i = 0; i < n; i++){
    sum += 1/(1 + toTheFourthPower(midpoint));
    midpoint += deltaX;
}
sum *= deltaX;

cout << "Here is my estimate: " << sum << endl;

return 0;
}

rrudisi1

I was given

\int_0^{2}\sqrt {1+x^4}dx

and was asked for the trapezoidal error and sum.
I got M_2=3 and so the error was

\displaystyle \text{error} \leq M_2\frac{(b-a)^3}{12n^2}.
\displaystyle \text{error} \leq 3\frac{(2-0))^3}{12n^2} = \frac{24}{12n^2}= \frac{2}{n^2}{\leq} 0.001.
n > \sqrt{\frac{2}{0.001}} \approx 44.7214

Which I let be 45. The sum is

\sum_{i=1}^{45} \frac {\sqrt{1+ \frac{2i}{45}}+\sqrt{1+ \frac{2i-1}{45}}}{2}* \frac{2}{45}

Which using this sage code gave me 3.65316510

Sage code for a trapezoidal sum.

Define the function, the endpoints a and b, and number of terms n

f(x) = sqrt(1+x^4)
a = 0.0; b = 2.0;
n = 45;

The rest should be automatic

dx = (b-a)/n;
x(i) = a + idx
sum = 0;
for i in range(1,n+1):
sum = sum + f( (x(i) + x(i-1))/2 )
N(sum
dx)

smarsha1

With Sage, I got the decimal value of the sum as: 2.17880062836033

tyoung4

My integral was:

\int_{-1}^{1} cos(x^4)dx

I was asked to find n so that error is within 0.001 for a trapezoidal sum.

First, I found M_2 by finding the second derivative:

f''(x) =-16x^6cos(x^4)-12x^2sin(x^4)

The bounds of f''(x) is a little less than 19, so I chose M_2=19

Then I plugged everything in:

0.001≤19 \frac{2^3}{12n^2} => n ≥ \sqrt{ \frac{(19)(2^3)}{(12)(0.001)}} ≈ 112.54

Naturally, I chose n = 113

After plugging it in to a computer program, I found that:

\sum_{i=1}^{113} \frac{cos(x_i^4)+cos(x_{i-1}^4)}{2} \frac{1}{2} ≈ 1.89350550833214

Here is a link to the Desmos I created for this problem:

asouhrad

My integral is

\int_0^{2} \sqrt {16-x^{2}} dx

estimated to within an error of 0.001 of the actual value using a midpoint sum.

Thus I needed to use the formula \text{error} \leq M_2\frac{(b-a)^3}{24n^2}

I found M_2= 1 through using Desmos.

Plugging in M_2 I found

n > \sqrt{\frac{8}{24(0.001)}}\approx18.25741858

or

n = 18

Plugging in n I get:

\sum_{i=1}^{18} \sqrt{16-\frac{(\frac{i}{2}+\frac{i-1}{2})^2}{2}} \frac{1}{2} ≈ 7.65318877518204

when utilizing sage code.

mark