a=-1;b=1;
NN=1000;
x[0]=a;x[NN]=b;

sum=0;
Deltax=(b-a)/NN;
For[i=1,i≤NN-1,i++,
x[i]=x[0]+i*Deltax;
f=x[i]^2;
sum=sum+f;
];(*end for i *)
sum=sum*Deltax;

f0=x[0]^2;fN=x[NN]^2;
A=N[(Deltax/2)*(f0+fN)+sum];
Print[A]

a=-1;b=1;
NN=1000;
x[0]=a;x[NN]=b;
Deltax=(b-a)/NN;
f[xdum_]:=xdum^2;
B=(Deltax*0.5)(f[x[0]+f[x[NN]]]);

For[i=0,i≤NN,i++,
x[i]=x[0]+i*Deltax
];

sum=Sum[f[x[i]],{i,1,NN}];(*end of Sum*)
sum=sum*Deltax;

A=sum+B