/* n: 8; xs: [1/12,2/12,4/12,5/12,7/12,8/12,10/12,11/12]; n: 7; xs: [1/12,2/12,4/12,5/12,8/12,10/12,11/12]; n: 6; xs: [1/12,2/12,5/12,7/12,10/12,11/12]; */ n: 3; xs: [1/6,3/6,5/6]; ws: makelist(concat(w,i),i,1,n); ps: makelist(x^i,i,0,n-1); /* polynomials */ fs: makelist(buildq([i:i,ps:ps],lambda([x],ps[i])),i,1,n); integ01: lambda([f],integrate(f(x),x,0,1)); Is: maplist(integ01,fs); /* calculate the integrals */ eq: lambda([f],lreduce("+",maplist(f,xs)*ws)); eqs: maplist(eq,fs)-Is; /* build equations */ solve(eqs,ws); /* solve for the weights */