Integrate[(1-x)/(1+x*x),{x,1,Pi}]

Integrate[(1-x)/(1+x*x),{x,1,Pi}]//N

Integrate[Sin[x]*(1-x)/(1+x*x),{x,1,Pi}]//N

NIntegrate[Sin[x]*(1-x)/(1+x*x),{x,1,Pi}]

Timing[
Integrate[Sin[x]*(1-x)/(1+x*x),{x,1,Pi}]//N
]

nodes5=Table[exp,{10}]

nodes5=Table[i exp,{i,10}]

nodes5=Table[i exp,{i,4,10}]

nodes5=Table[i exp,{i,4.5,10.2,.66}]

nodes5=Table[i exp,{i,{a,b,3,exp2,Sin[5]}}]

Timing[
NIntegrate[Sin[x]*(1-x)/(1+x*x),{x,1,Pi}]
]

Challenge #3

weights5={0.0333333333333333,0.266666666666667,0.4000000000000000,0.2666666666666667,0.0333333333333333};
weights9={0.0079365079365079,0.0731093246080091,0.1396825396825397,0.1808589293602449,0.1968253968253968,0.1808589293602449,0.1396825396825397,0.0731093246080091,0.0079365079365079};

nodes5=Table[Cos[i Pi/(5-1)],{i,0.,5-1}];
nodes9=Table[Cos[i Pi/(9-1)],{i,0.,9-1}];

f2[x_]:=Sin[x]*(1-x)/(1+x*x)

a=1;b=Pi;
Function[{a,b},...]
(b-a)Map[
#1 f2[(a+b)/2 + #2(b-a)/2]&,
{weights,nodes}]

Map[f,{{w1,w2,w3},{n1,n2,n3}}]

Map[f,{{w1,w2,w3},{n1,n2,n3}},{2}]

MapIndexed[f,{{w1,w2,w3},{n1,n2,n3}}]

Map[f,Transpose[{{w1,w2,w3},{n1,n2,n3}}]]

Map[#[[1]] f2[(a+b)/2 + #[[2]](b-a)/2]&,Transpose[{{w1,w2,w3},{n1,n2,n3}}]]

Apply[Plus,
MapThread[#1 f2[(a+b)/2 + #2(b-a)/2]&,{{w1,w2,w3},{n1,n2,n3}}]
]

integrateP[a_,b_,t_,f_]:=
(b-a)Apply[Plus,
MapThread[#1 f[(a+b)/2 + #2(b-a)/2]&,{weights5,nodes5}]
]

integrateP[1.,Pi,0,f2]

With[{var1=exp1,var2=exp2},
var1*var2]

Clear[integrateP]

integrateP[a_,b_,t_,f_]:=
With[
{k5=(b-a)Apply[Plus,
MapThread[#1 f[(a+b)/2 + #2(b-a)/2]&,{weights5,nodes5}]
],
k9=(b-a)Apply[Plus,
MapThread[#1 f[(a+b)/2 + #2(b-a)/2]&,{weights9,nodes9}]
]},
If[Abs[k9-k5]<t,k9,
integrateP[a,(a+b)/2,t/2,f]+
integrateP[(a+b)/2,b,t/2,f]]
]

integrateP[1,Pi,10^-10,f2]

nodes5

nodes9