1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem on trapezoidal rule ?

  1. May 29, 2009 #1
    problem on trapezoidal rule ????

    1. The problem statement, all variables and given/known data
    The error of the trapezoidal rule is equal to [(b-a)^(3)/n^2]*f''(e)
    so when we want to find the integral to a given accuracy what we do is we find the maximum f'' value at that interval and subb that in the above equation .So that is the maximum error .Then if we want to have a accuracy of 5 decimal places then we find n (no of terms ) S.T
    i think i said it rightly >my question is in a problem in my book
    Integrate (e^(-x^(2)/2) from 0 to 2 (function in standard normal distribution )
    then after calculating we can get that max f'' in that interval is 0.4462 which we get when x=square root(3)
    in my book they have said that
    f''(x)<=1 in that interval instead of saying f''(x)<=0.4462

    WHY IS THAT ???That change makes a huge difference in the required no of terms ....can someone explain why ?

  2. jcsd
  3. May 29, 2009 #2
    Re: problem on trapezoidal rule ????

    The location x=sqr(3) may be a critical point, but it is not the only one, and it may not even be the maximum. Investigate the nature of f''(x) over the whole inteval

    P.S. - you need to look at magnitude of f''(x) over interval.
    Last edited: May 29, 2009
  4. May 29, 2009 #3
    Re: problem on trapezoidal rule ????

    yr after considering the third derivative only i got the maximum as root(3) and the graph of the function f''(x) will also confirm that .i guess it is the maximum in that interval .And the book has mentioned it also .
    But when we calculating the error it has taken f''(x)<=1 instead of 0.44 value .........

  5. May 29, 2009 #4
    Re: problem on trapezoidal rule ????

    Well, you mentioned that f''(sqr(3)) = 0.4462...

    Now, what is the value of f''(0) ?

    Also, what expression did you get for f''(x)
  6. May 29, 2009 #5
    Re: problem on trapezoidal rule ????

    In further review of your original post, I may have been to quick with you.

    Let's review the formula for composite Trapezoidal rule for n subintervals

    [tex]\int_a^b f(x)dx=\frac{h}{2}\cdot \left[ f(a)+f(b)+2\sum_{j=1}^{n-1}f(x_j) \right]-E(a,b,h;f(\mu))[/tex]

    [tex]E(a,b,h;f(\mu)) = \frac{(b-a)h^2}{12}\cdot f''(\mu)[/tex]

    for some [itex]\mu \in [a,b][/itex]

    If we let [itex]h=(b-a)/n[/itex] then we can also say

    [tex]E(a,b,h;f(\mu)) = E(a,b,n;f(\mu))= \frac{(b-a)^3}{12 \cdot n^2}\cdot f''(\mu)[/tex]

    Now, if we want to determine the minimum value of "n" such that [itex]E \le \epsilon[/itex] for some value of [itex]\epsilon[/itex], then we must consider the maximum magnitude value of f''(x) over the interval.

    That is, we want to consider the solution for [itex]n[/itex] of the following:

    [tex]\frac{(b-a)^3}{12 \cdot n^2} \cdot {max}_{\zeta} \left|{f''(\zeta)}\right| \le \epsilon[/tex]

    where [itex] {max}_{\zeta} \left|{f''(\zeta)}\right| [/itex] is the max magnitude of f''(x) for some point [itex]x=\zeta \in [a,b][/itex].

    If your book did not point out that they are interested in the maximum magnitude of f'', then it is wrong. But, go back and check - they may have said or implied that in a confounding way.
    Last edited: May 29, 2009
  7. May 30, 2009 #6
    Re: problem on trapezoidal rule ????

    By using the F''' (third derivative)you can find the critical points of your F'' function .Using that book has found root(3) as a critical point by checking the sign before and after the root(3) it is clear that root(3) provides a maximum . But may be they have taken '1' instead of 0.4462 as it will be easy calculations .....but it is making a huge difference in the required number of terms to gain that accuracy .

    ok i will provide the whle problem here integrate (e^[(-x^2)/2)] from 0 to 2 to accuracy of 5 decimal places.
    If u have time check for the no f terms needed .i got 245 .
  8. May 30, 2009 #7
    Re: problem on trapezoidal rule ????

    rclakmal - I will agree that the maximum of f''(x) in the interval [a,b] = [0,2] is, indeed, at x=sqr(3) and is equal to (approx) 0.4462..

    However, as you said, you were given a requirement to yield an answer accurate to within a tolerance of [itex]\epsilon[/itex]. In your problem, you said you were given the tolerance of [itex]\epsilon = 5 \cdot 10^{-6}[/itex] (actually, that's how you interperted "5 siginificant digits" of accuracy, which, for this problem might be overstated since the true answer is approx 0.8820... But we will use it anyways for this discussion).

    Note here that you were given a positive value of tolerance, but be asured that the actual value of the error could be [itex]\pm \epsilon[/itex]. That expression for error (E) is only an estimate to reduce the actual error (which is actualy an expression of infinite terms invloving an infinite number of derivative terms) down to some qualifiable term and does not necessarly guarantee an explicit quantifiable error (hence the use of [itex]\mu[/itex] in the expression of f''(x))

    My point is, since the error can be plus or minus, you should be looking for a value of [itex]\left|E\right| \le \epsilon[/itex].

    This would mean that you would normally look for the worst case of the absolute value of f''(x) with the interval. This may seem severe, and in many cases it is. Nevertheless, with nothing else to guide us, we must consider this case (who knows where along the interval the error term manifest itself - choose the max absolute value).

    Hence, I would have chosen [itex] max[\left|f''(\mu)\right|] = \left|f''(0)\right| = \left|-1\right| = 1[/itex].

    Now, having said ALL OF THAT - a few points:

    1. I don't know if the author's selection was based on this logic or not - he/she should have clarified that point. You may be right, and the selection was purely one of convience (but then, I find .5 convienent...).

    2. All of this is usually very conservative for sufficiently smooth funtions (OK, true, what the heck is "sufficiently smooth"?) as the number of terms "n" is often overstated in these cases. Looking at the second and third derivative for this function, we do see good behavoir and all of this rhetroic is probably overkill.

    3. Using the expression below, with [itex]\epsilon = 5 \cdot 10^{-6} [/itex], I compute the number of terms required (assuming worst case [itex]\left|f''(\zeta)\right| = 1[/itex]) as n = 366. Using f''(sqr(3)), I yield n= 244.

    [tex] n \ge \sqrt{\frac{\frac{(b-a)^3}{12} \cdot \left|f''(\zeta)\right|}{\epsilon}}[/tex]

    4. Computing the composite Trapezoidal calculation for various values of "n", I come up with these values. You can see that the actual number of cases required is far less than the estimated.

    Code (Text):
    n   Integral       Diff
    10  0.88184
    20  0.88202 -1.82E-04
    40  0.88207 -4.57E-05
    80  0.88208 -1.14E-05
    90  0.88208 -8.01E-07
    100 0.88208 -5.73E-07
    120 0.88208 -7.46E-07
    140 0.88208 -4.50E-07
    160 0.88208 -2.92E-07
    200 0.88208 -3.43E-07
    210 0.88208 -5.68E-08
    220 0.88208 -4.92E-08
    230 0.88208 -4.29E-08
    240 0.88208 -3.77E-08
    250 0.88208 -3.32E-08
    260 0.88208 -2.95E-08
    I hope that helps some.
  9. May 30, 2009 #8
    Re: problem on trapezoidal rule ????

    hey it helped me a lot !!!!!
    ok im going to agree on your point because when we find the error it can be +or - as you have mentioned .and we should use a modulus sign in writing the error.Then your point gets justify automatically as we have to consider the modulus of f''(x) also .

    But as you have clearly shown here ,we are getting that 5 decimal place accuracy from 80 terms .so i think it is a huge error in approximation .Have i made a mistake in writing my error as 5*10^(-6) or is it an unstoppable error in approximating ????

    is there a way to get a more accurate approximation ?
  10. May 30, 2009 #9
    Re: problem on trapezoidal rule ????

    AND thanks again in posting such a good explanation !
  11. May 31, 2009 #10
    Re: problem on trapezoidal rule ????

    You're welcome rclakmal. BTW, I made an error when I calculated the Trap results (I had [itex]f(x) = e^{-x^2}[/itex] and not [itex]f(x) = e^{\frac{-x^2}{2}}[/itex]). The corrected values are below.

    If the task was to calculate to 5 decimal places, then my previous remark regarding your accuracy interpretation is meaningless. Your selection of error tolerance is correct.

    The large difference in the approximated number of terms and the true amount of terms often arises in problems like these - you did nothing wrong (as far as I can tell).

    Code (Text):
    n   Integral     Diff
    10  1.19539
    20  1.19606 6.76E-04
    40  1.19623 1.69E-04
    80  1.19627 4.23E-05
    90  1.19628 2.96E-06
    100 1.19628 2.12E-06
    120 1.19628 2.76E-06
    140 1.19628 1.66E-06
    160 1.19628 1.08E-06
    200 1.19629 1.27E-06
    210 1.19629 2.10E-07
    220 1.19629 1.82E-07
    230 1.19629 1.59E-07
    240 1.19629 1.39E-07
    250 1.19629 1.23E-07
    260 1.19629 1.09E-07
  12. Jun 1, 2009 #11
    Re: problem on trapezoidal rule ????

    So thanks TheoMcCloskey for all the replies !!!!!!!!!!!!!It was a great help!!!
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Problem on trapezoidal rule ?