Integration over (a,b)
An integral of the form,
,
can always be transformed to an integral over
by the transformation
:
> restart:
> xt:=((b-a)*t+b+a)/2;
> subs(t=-1,xt);
> subs(t=1,xt);
> diff(xt,t);
> gt:=t->(b-a)*f(((b-a)*t+b+a)/2)/2;int(gt(t),t=-1..1);
Indeed:
> f:=x->sin(2.*x)*exp(-x);
> int(f(x),x=1..3);
> a:=1.;b:=3;gt:=t->(b-a)*f(((b-a)*t+b+a)/2)/2;
> int(gt(t),t=-1..1);
This shows that indeed, the integral in
produces the same result as the integral in
.
We can now apply Gaussian quadrature on the integral in
:
> r[1]:=-0.8611363116:r[2]:=-0.3399810436:r[3]:=-r[2]:r[4]:=-r[1]:c[1]:=0.3478548451:c[2]:=0.6521451549:c[3]:=c[2]:c[4]:=c[1]:
> gauss4:=0:for i from 1 to 4 do gauss4:=gauss4+c[i]*gt(r[i]): od: gauss4;
>