Trapezoidal Method

Discussion in 'Homework Help' started by Kayne, Nov 1, 2011.

  1. Kayne

    Thread Starter Active Member

    Mar 19, 2009
    105
    0
    Hi All,

    I would like an answer checked that I have found for the following problem.

     y = 5 \int^1_0 \frac{1}{1+x^2} dx

    using

     \int^1_0 f(x) dx  = (b-a)[\frac{f(a)+f(b)}{2}]

     5*((1-0)*[\frac{{\frac{1}{1+0^2}+\frac{1}{1+1^2}}}{2}])

    5*0.75 = 3.75

    Have I solved this correctly?

    I have tried to chack this in matlab with the code below but I am not getting this answer which now I am not sure which is incorrect.

    X = 0:0.5:1;
    Y = 5*(1./X.^2)
    Z = trapz(X,Y)

    Thanks for your time
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    I think you are supposed to use more than a single trapezoid to approximate the integral. Did you really think one would do the trick?
     
  3. t_n_k

    AAC Fanatic!

    Mar 6, 2009
    5,448
    782
    Plus your matlab code isn't correct.

    For three terms it would be something like .... [I don't use Matlab]

    X=0:0.5:1
    Y=[5 5 5]./(1+X^2) ---- you missed the addition in your post
    Z=trapz(X,Y)

    So to compare values for three terms, your pencil & paper method should have the sum of two trapezoidal approximations with limits from [0 to 0.5] and [0.5 to 1]

    As Papbravo implies you should probably use several terms to come up with a good approximation to the 'exact' integral.

    ans=\frac{5\pi}{4}

    With 11 terms X=[0 0.1 0.2 .... 1.0] I get a value of Z=3.9249075
     
    Last edited: Nov 2, 2011
  4. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    A graduate degree in Mathematics comes in handy on an occasional basis.
     
Loading...