Computing Integral with Gauss-Chebyshev Quadrature in MATLAB

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 3K views
Fidelio
Messages
3
Reaction score
0
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!
 
Physics news on Phys.org
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?