You are on page 1of 1

EXPORT ClenshawCurtis(a,b,n)

BEGIN
//pesos de Clenshaw-Curtis
LOCAL i,j,k;
L1:=0;
L2:=0;
L3:=0;
FOR j FROM 1 TO (n/2)+1 DO
L1(j):=j-1;
END;
FOR k FROM 1 TO (n/2)+1 DO
L2(k):=1;
END;
L2(1):=0.5*L2(1);
L2((n/2)+1):=0.5*L2((n/2)+1);
FOR i FROM 2 TO n DO
L3(i):=(4/n)*LIST(((1-4*L1^2)^-1)*cos(2*L1**(i-1)/n)*L2);
END;
L3(1):=(n-1)^1;
L3(n+1):=L3(1);
//nodes evaluats en f(x)
LOCAL th,z,int,l;
L4:=0;
FOR l FROM 0 TO n DO
th:=cos(l*/n);
z:=a+((b a)/2)*(th+1);
L4(l+1):=F1(z);
END;
//integral
int:=((b a)/2)*LIST(L3*L4); A:=int;
RETURN(int);
END;

You might also like