
clc,clear

n = 4; % 节点个数：(n+1)
syms x
f = exp(x); % 注意f(x)的形式！

y = Get_Gauss_Chebyshev(f,n);

fprintf('\n %d点Gauss-Chebyshev求积公式计算结果为: %f\n\n',n+1,eval(y))

function y = Get_Gauss_Chebyshev(f,n)

    k = 0:n;
    x = cos( (2*k+1)/(2*n+2)*pi );
    
    y = pi/(n+1)*sum( subs(f,x) );

end