MHB Setup for Simpson's Rule from 0 to $\pi$ with n=6

  • Thread starter Thread starter ineedhelpnow
  • Start date Start date
ineedhelpnow
Messages
649
Reaction score
0
Simpson's Rule-
what would the setup look like for something from 0 to $\pi$ if n=6 and $\Delta x=\pi/6$
 
Physics news on Phys.org
What do you mean by setup?
 
$\frac{\Delta x}{3} [f(x_0) +4f(x_1) +2f(x_2)+...+2f(x_{n-2}) +4f(x_{n-1})+f(x_n)]$

i thought it would be $\frac{\frac{\pi}{6}}{3} [f(0) +4f(\pi/6) +2f(\pi/3)+...$

i don't think i did it right though because arent the coefficients in front of f(x) supposed to be 1-4-2-4-2-4...1. the way I am doing it is 1-4-2-4 and it stops there. it doesn't go back to 1 the way I am setting it up.

if that makes any sense :confused:
 
ineedhelpnow said:
what would the setup look like for something from 0 to $\pi$ if n=6 and $\Delta x=\pi/6$
From what you write later, I assume that you have to apply the Simpson's rule 3 times on 3 subintervals of $[0,\pi]$. The intervals are
\begin{array}{c|c|c|c}
\text{No} & 1 & 2 & 3\\
\hline
\text{Interval} & [0,\pi/3] & [\pi/3,2\pi/3] & [2\pi/3,\pi]\\
\hline
\text{Midpoint} & \pi/6 & \pi/2 & 5\pi/6\\
\end{array}
Applying the Simpson's rule to each interval we get
\begin{align*}
&\frac{\pi/3}{6}\big[f(0)+4f(\pi/6)+f(\pi/3)\big]\\
&\frac{\pi/3}{6}\big[f(\pi/3)+4f(\pi/2)+f(2\pi/3)\big]\\
&\frac{\pi/3}{6}\big[f(2\pi/3)+4f(5\pi/6)+f(\pi)\big]\\
\end{align*}
Summing this up we get
\[
\frac{\pi}{18}\big[f(0)+4f(\pi/6)+2f(\pi/3)+4f(\pi/2)+2f(2\pi/3)+4f(5\pi/6)+f(\pi)\big]\qquad(*)
\]

We can use the formula you gave
ineedhelpnow said:
$\frac{\Delta x}{3} [f(x_0) +4f(x_1) +2f(x_2)+...+2f(x_{n-2}) +4f(x_{n-1})+f(x_n)]$
(see also Wikipedia). Here $x_i=\frac{\pi}{6}i$, $i=0,\dots,6$ and the rule gives
\[
\frac{\pi/6}{3}\big[f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+2f(x_4)+4f(x_5)+f(x_6)\big]
\]
which is the same thing as (*).
 
how do i know to split it into 3 sub intervals
 
ineedhelpnow said:
how do i know to split it into 3 sub intervals
This depends on the directions contained in the problem statement. It is your responsibility to interpret the problem statement:
ineedhelpnow said:
what would the setup look like for something from 0 to $\pi$ if n=6 and $\Delta x=\pi/6$
since the interpretations depends on what your course or book denotes by $n$ and $\Delta x$. The two most natural interpretations are to apply the rule to 3 subintervals (this agrees with Wikipedia's notations) or 6 subintervals. In the latter case the formulas are different from my last post.
 
can i attach a link from photobucket onto here? i want to post a picture from my book but the file size is waaaay to big.
 
i hope i don't get in trouble for referencing an external source but here it is: Mhb Photos by fouziad1 | Photobucket
it might be hard to see so sorry. i didnt have much light.
 
Yes, your textbook is using the same notations as Wikipedia and as I did in post #4. The sum $S_n$ is the composite Simpson's rule. It simply means that you apply the original Simpson's rule on $n/2$ intervals. The original Simpson's rule applied to $[a,b]$ approximates $\int_a^b f(x)\,dx$ as $\frac{b-a}{6}\left[f(a)+4f\left(\frac{a+b}{2}\right)+f(b)\right]$. The composite rule for an even $n$ breaks $[a,b]$ into $n/2$ intervals, applies the original rule to each interval and then sums up the results. That's why the values of $f$ at the inner borders of subintervals are counted twice (once for the left subinterval and once for the right one), while the values of $f$ at the ends of the big interval are counted only once.
 
  • #10
i understand this problem now but if I am given another problem how can i be sure whether or not to break it into n/2 intervals because in the example in the book (i attached the link with the picture) they just use the equation exactly as it is. does it depend on what [a,b] is?

sorry i just really want to understand this properly
 
  • #11
actually i think I am starting to understand what your saying now. thanks for your help :)

yep makes so much sense now. awesome explanation.
 
  • #12
I am not sure I understand your difficulty.
ineedhelpnow said:
if I am given another problem how can i be sure whether or not to break it into n/2 intervals
Yes. That's how your book defines the Simpson's rule for a given $n$.

ineedhelpnow said:
because in the example in the book (i attached the link with the picture) they just use the equation exactly as it is.
How else are they supposed to use it?

ineedhelpnow said:
does it depend on what [a,b] is?
Yes. The rule uses $x_j$ where $j=0,\dots,n$, and $x_j=a+j(b-a)/n$. That's where $a$ and $b$ come in.
 
Back
Top