Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Gauss quadrature

  1. May 8, 2012 #1
    Hello, anyone knows where y can find a program to compute the integral

    ∫ ( from -1 to 1) f(x)/ √(1-x^2) using the Gauss-Chebyshev quadrature, on matlab?

    Thanks!
     
  2. jcsd
  3. May 8, 2012 #2

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    Last edited by a moderator: May 6, 2017
  4. May 9, 2012 #3
    thanks so much AlephZero,

    Could you check If it is correct ?

    function int = chebquad(funct,accuracy)
    f = inline(funct);
    old_int = inf;
    for n=1:1000

    x = cos(((2*(1:n) - 1)/(2*n))*pi);
    w = pi/n;
    fx = f(x);
    int = sum(w.*fx);
    if abs(int_old-int) < abs(tol*int),
    converge='y';
    break;
    end
    old_int = int;
    end

    And now If I want to compute this integral [tex] \int_1^2 dx \frac { e^{2x} }{ ( (2-x) ( (1-x))^{1/2} } [/tex] with an accuracy 10^-8 what could I do?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Gauss quadrature
Loading...