# Are my values correct for this Trapezoidal and Simpson's rule problem?

$$\int^5_0 100x \sqrt{125 - x^3}$$

Using the Trapezoidal rule, area = 9370

Using Simpson's rule, area = 8969

If my values are incorrect, I can provide you with the work I did and we can find where I messed up. The reason I'm doubting my answers is because there seems to be quite a big gap. (400).

edit...

For the Trapezoidal rule I did the following

1. Plugged in x-value from 0 to 5 to get y-values.
2. I then go from $x_1 - x_0 * \frac{y_0 + y_1}{2}$ and iterate until I get to 5.
3. I take the sum of those values

I couldn't figure out how to get a table to work, but the math went something like this:

[0,1] $(1-0)*\frac{1114-0}{2}$ = 557

[1,2] $(2-1)*\frac{1638-1114}{2}$ = 1638

and so on all the way up to 5. Then I added up the area to get approximately 9370

For Simpson's Rule this is my work

1. Plugged in the x-values to get my y-values
2. I take $y_1 + (4*y_2) + y_3$ I then do this when x = 0, 2, and 4.
3. I add up the results above to get approximately 8969
-
you need to specify how many intervals you have, or better yet put your arithmetic. –  Maesumi Mar 1 '13 at 19:46
I edited my post, but for Trapezoidal I use 5 and for Simpson I use 4 (I believe you have to use an even number for it) –  JoseBruchez Mar 1 '13 at 20:26
With 5 subintervals, trapeze gives me 9370.8 and Simpson 1/3 with 4 subintervals gives 9802.8. –  Dominique Mar 1 '13 at 21:49
@JoseBruchez there should have "dx" after $\int f(x)$. –  pipi Mar 2 '13 at 1:25

If you just want to check your answers, you may like to look at Simpson's Rule Calculator and Trapezoidal Rule Calculator.

With $n=4$, Simpson's Rule is
$$I\approx\frac{h}{3}(f(x_0) + 2f(x_2) + 4(f(x_1) + f(x_3)) + f(x_4))$$ where $h=\frac{5-0}{4}$ is your interval.

Edit
I'll show an easy way to write the expression with n=6, i.e. six subintervals.
Note that with six subintervals there are seven points at which you calculate values, $x_0, x_1, \cdots, x_6$.

First write the expression with the seven function evaluations:
$$\frac{h}{3}(f(x_0) + f(x_1) + f(x_2) + f(x_3) + f(x_4) + f(x_5) + f(x_6)).$$ Then, not including the first and last evaluations, write in alternating factors of $4$ and $2$: $$\frac{h}{3}(f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + 2f(x_4) + 4f(x_5) + f(x_6)).$$ And that's it. The important thing to remember is that when you set $n$ it is the number of subintervals, and that the number of points is $n+1$.

-
Judging by those calculators, my Simpson's rule is wrong by 900. Can you point out where I went wrong? –  JoseBruchez Mar 1 '13 at 20:25
When I was in class, I was under the impression that the professor said to use $\frac{1}{3}$ for $\frac{h}{3}$ I guess that would make h = 1. The calculators threw errors when 1 was inserted to the interval number. –  JoseBruchez Mar 1 '13 at 21:11
That would give you an odd number of subintervals. –  Peter Phipps Mar 1 '13 at 21:21
@JoseBruchez you can't choose $h$ and the number of subintervals. Once you choose one, the other is fixed. So if you have 4 subintervals in Simpson 1/3, you get $h = (b-a)/4$, where $a$ and $b$ are the bounds of integration. –  Dominique Mar 1 '13 at 21:51
Sorry for the late reply, been pretty busy. So would I be able to do something like $\frac{1}{3}*(f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+4f(x_4)+f(x_5))*\frac{5}{6}$? Using the one-third rule? (Note that I'm changing subintervals from 4 to 6. so $\frac{b-a}{6} = \frac{5}{6}$). –  JoseBruchez Mar 7 '13 at 19:42

In order for any of this to be valuable, you need to do one of two things: 1) increase the number of points to be sure that some sort of convergence is happening, and/or 2) compute the exact value of the integral, if at all possible.

For 2), it turns out to be possible. Consider

$$\int_0^a dx \: x \sqrt{a^3-x^3} = a^{7/2} \int_0^1 dx \: x \sqrt{1-x^3}$$

Substitute $u=1-x^3$, $x=(1-u)^{1/3}$, $dx = -(1/3) (1-u)^{-2/3} du$:

$$\int_0^a dx\: x \sqrt{a^3-x^3} = a^{7/2} \int_0^1 du \: u^{1/2} (1-u)^{-1/3}$$

The latter integral is a beta function, so the integral is equal to

$$\int_0^a dx\: x \sqrt{a^3-x^3} = a^{7/2} \frac{\Gamma{\left ( \frac{3}{2}\right )}\Gamma{\left ( \frac{2}{3}\right )}}{\Gamma{\left ( \frac{13}{6}\right )}}$$

When $a=5$, then the integral is $\approx 103.303$. The original integral is $100$ times this, or about $10330.3$.

Now that this step is done, increase the number of points in your trapezoidal and Simpson rule approximations. Are they converging to this result? Remember that there is some funny behavior of the integrand at $x=5$ (vertical tangent), so even if you increase, you may not increase the accuracy. Recall also that just because there is a large gap in the trapezoidal and Simpson approximations, it does not mean you are wrong.

Now, for the approximations. Let's consider trapezoidal rule for $n$ points:

$$\text{trap}(n) = \frac{1}{n} \sum_{k=1}^{5 n-1} f(k/n)$$

where $f(x)=100 x \sqrt{125-x^3}$. I made a table of values from $1$ to $10$:

$$\left( \begin{array}{cc} 1 & 9370.83 \\ 2 & 9994.64 \\ 3 & 10148.8 \\ 4 & 10213. \\ 5 & 10246.6 \\ 6 & 10266.8 \\ 7 & 10280. \\ 8 & 10289.2 \\ 9 & 10295.9 \\ 10 & 10301. \\ \end{array} \right)$$

Note that, as we have established our baseline with the exact result, we can feel good about this result. Your approximation corresponds to $n=1$ and was therefore somewhat off, but correct for the level of approximation sought.

You can do the same for Simpson's rule, except that you should split up odd and even numbered points:

$$\text{simp}(n) = \frac{2}{3 n} \sum_{k=1}^{(5 n-1)/2 - 1} f(2 k/n) + \frac{4}{3 n} \sum_{k=1}^{(5 n-1)/2} f((2 k-1)/n)$$

The result from $n=1$ to $10$ is

$$\left( \begin{array}{cc} 1. & 8969.49 \\ 2. & 8456.51 \\ 3. & 10056.9 \\ 4. & 9617.21 \\ 5. & 10202.2 \\ 6. & 9932.71 \\ 7. & 10252.7 \\ 8. & 10069. \\ 9. & 10277. \\ 10. & 10142. \\ \end{array} \right)$$

Note the oscillatory behavior. Again, because we have established a baseline, we know how good the approximation is. Your result corresponds to $n=1$ and is correct, just a very low level of approximation.

-
Ah, so it just isn't very precise. Why is the trapezoidal rule so much more accurate for the above function? –  JoseBruchez Mar 7 '13 at 19:45
It depends on whether the function you are integrating is locally well-approximated by a parabola. In this case, you have a vertical tangent at one end, so that could explain it. –  Ron Gordon Mar 7 '13 at 19:46