MATLAB Computing Integral with Gauss-Chebyshev Quadrature in MATLAB

AI Thread Summary
A user seeks assistance with MATLAB code to compute the integral of f(x)/√(1-x^2) using Gauss-Chebyshev quadrature. They provide links to resources for integration points and weights, as well as some MATLAB code for review. The provided code includes a loop for calculating the integral but requires verification for correctness. Additionally, the user inquires about adapting the method to compute a different integral with specified accuracy. The discussion focuses on implementing and verifying numerical integration techniques in MATLAB.
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 \int_1^2 dx \frac { e^{2x} }{ ( (2-x) ( (1-x))^{1/2} } with an accuracy 10^-8 what could I do?
 

Similar threads

Replies
4
Views
4K
Replies
2
Views
3K
Replies
32
Views
4K
Replies
8
Views
2K
Replies
5
Views
2K
Replies
4
Views
1K
Back
Top