Results 1 to 6 of 6

Math Help - Integral Approximation

  1. #1
    Member
    Joined
    Mar 2012
    From
    USA
    Posts
    92

    Integral Approximation

    I got this assignment and I honestly don't even know where to begin. My teacher isn't making much sense to me at the moment, so if anybody can help me I would greatly appreciate it!
    Attached Thumbnails Attached Thumbnails Integral Approximation-scan0036.jpg  
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Behold, the power of SARDINES!
    TheEmptySet's Avatar
    Joined
    Feb 2008
    From
    Yuma, AZ, USA
    Posts
    3,764
    Thanks
    78

    Re: Integral Approximation

    Quote Originally Posted by renolovexoxo View Post
    I got this assignment and I honestly don't even know where to begin. My teacher isn't making much sense to me at the moment, so if anybody can help me I would greatly appreciate it!
    First we will need a bit more information for i) are you using the forward difference, backward difference, central difference. The central difference approximations are more accurate.

    If you are using the central difference then you formula is

    f'\left(\frac{\pi j}{N }\right) \approx \frac{f\left(\frac{\pi (j+1)}{N }\right)-f\left(\frac{\pi (j-1)}{N }\right)}{\frac{2\pi}{N}}

    This is valid for any j in 1 \le j \le N-1

    Since they didn't give you a point to use fix a j in the interval and calculate

    \frac{\pi j}{N } This will give you point you are approximating the derivative at.

    Calculate the numerical approximation and then calculate the actual derivative and evaluate it at the point.

    The error is the difference between the two values.

    Give this a try and post back if you get stuck.
    Last edited by TheEmptySet; October 9th 2012 at 11:58 AM.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Member
    Joined
    Mar 2012
    From
    USA
    Posts
    92

    Re: Integral Approximation

    As I'm looking at this, it doesn't look like anything we've covered in class. We've done this sort of thing for given data, so I knew what the h values were numerically, rather than in terms like this. I was wondering if this might be something I would need to do in MatLab? We had a matlab demo, but I didn't understand any of it (nor did my classmates) and haven't used matlab. Does this code look like anything I could use or alter to use?

    % f(x), the function to integrate
    % f= @(x) x^4-2*x ;
    % f= @(x) exp(x);
    f=@(x) sin(x);
    % a, the lower limit of integration
    a=0 ;
    % b, the upper limit of integration
    b=pi ;
    % b=1.0;
    % n, the number of segments. Note that this number must be even.
    % n=20 ;
    %************************************************* *********************
    format long g
    h=(b-a)/n ;
    % Sum the odd index function values, and multiply by 4
    sumOdd=0 ;
    for i=1:2:n-1
    sumOdd=sumOdd+f(a+i*h) ;
    end
    % Sum the even index function values, and multiply by 2
    sumEven=0 ;
    for i=2:2:n-2
    sumEven=sumEven+f(a+i*h) ;
    end
    sum=4*sumOdd+2*sumEven+f(a)+f(b) ;
    % Then multiply by h/3
    approx=h/3*sum ;
    %exact = quad(f,a,b) ;
    %exact=exp(b)-exp(a);
    exact=-cos(b)-(-cos(a));
    error=abs(approx-exact);
    disp(approx);
    disp(exact);
    disp(error);
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Super Member
    Joined
    Jun 2009
    Posts
    660
    Thanks
    133

    Re: Integral Approximation

    I'm not familiar with some of the syntax, (specifically those @(x)'s) but there are a couple of obvious comments.
    The numerical method being used is Simpson's Rule.
    The program will not work because n is not defined. You need to remove the % sign from the statement % n= 20.
    Hopefully then it will work, but as they say, (covering myself !), 'there's always one more bug'.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Member
    Joined
    Mar 2012
    From
    USA
    Posts
    92

    Re: Integral Approximation

    Thanks, I'll try it by taking out that %!
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Super Member
    Joined
    Jun 2009
    Posts
    660
    Thanks
    133

    Re: Integral Approximation

    In an idle moment I ran that program on my home PC, (BASIC though rather than Matlab).
    It came up with the results
    Approx = 2.00000678
    Exact = 2
    Error = 0.67844418e-5
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Multivariable integral approximation
    Posted in the Calculus Forum
    Replies: 2
    Last Post: July 12th 2010, 05:33 AM
  2. Approximation (A-C)/(B-D) ~= A/B + ...?
    Posted in the Calculus Forum
    Replies: 0
    Last Post: May 1st 2010, 11:17 AM
  3. NRM approximation
    Posted in the Calculus Forum
    Replies: 1
    Last Post: April 13th 2010, 06:32 AM
  4. Best approximation
    Posted in the Differential Geometry Forum
    Replies: 1
    Last Post: November 2nd 2009, 03:14 AM
  5. Approximation Integral
    Posted in the Calculus Forum
    Replies: 0
    Last Post: July 31st 2008, 01:16 PM

Search Tags


/mathhelpforum @mathhelpforum