"We demo a few more examples of integration of f[x] using both Integrate and NIntegrate to show the compatibility of their results"
f[x_]:=Exp[x]−x−2;
Integratef[x_]:=Integrate[f[x],x];
"Set the limits, x0 and x1"
x0=-1
x1=1
Plot[f[x],{x,x0,x1}]
Print["f[x]=",f[x]];
Print["Integratef[x]=",Integratef[x]];
"Define antiderivative of f[x] at x0 and x1"
Fx0=N[Integratef[x]/.{x->x0}];
Fx1=N[Integratef[x]/.{x->x1}];
"Integral as given by difference in antiderivatives are AI= "
AI=Fx1-Fx0

"Integral as given by NIntegrate is NI= "
NI=NIntegrate[f[x],{x,x0,x1}]
"Print both NA and NI ="
{AI, NI}

"Another function, f[x_]:=(1/x) Sin[x]"
f[x_]:=(1/x) Sin[x];
Integratef[x_]:=Integrate[f[x],x];
"Set the limits, x0 and x1"
x0=-1.5Pi
x1=1.5Pi
Plot[f[x],{x,x0,x1}]
Print["f[x]=",f[x]];
Print["Integratef[x]=",Integratef[x]];
"Define antiderivative of f[x] at x0 and x1"
Fx0=N[Integratef[x]/.{x->x0}];
Fx1=N[Integratef[x]/.{x->x1}];
"Integral as given by difference in antiderivatives are AI= "
AI=Fx1-Fx0

"Integral as given by NIntegrate is NI= "
NI=NIntegrate[f[x],{x,x0,x1}]
"Print both NA and NI ="
{AI, NI}

"Another function, f[x_]:=(1/x) Sin[x]"
z=1;
f[x_]:=x*(z^1+x^2)^(-3/2);
Integratef[x_]:=Integrate[f[x],x];
"Set the limits, x0 and x1"
x0=-1.5Pi
x1=1.5Pi
Plot[f[x],{x,x0,x1}]
Print["f[x]=",f[x]];
Print["Integratef[x]=",Integratef[x]];
"Define antiderivative of f[x] at x0 and x1"
Fx0=N[Integratef[x]/.{x->x0}];
Fx1=N[Integratef[x]/.{x->x1}];
"Integral as given by difference in antiderivatives are AI= "
AI=Fx1-Fx0

"Integral as given by NIntegrate is NI= "
NI=NIntegrate[f[x],{x,x0,x1}]
"Print both NA and NI ="
{AI, NI}

"Another function, f[x_]:=Tan[π x]−x−6;"
f[x_]:=Tan[π x]−x−6;;
Integratef[x_]:=Integrate[f[x],x];
"Set the limits, x0 and x1"
x0=0
x1=(1/2.0);
Plot[f[x],{x,x0,x1}]
Print["f[x]=",f[x]];
Print["Integratef[x]=",Integratef[x]];
"Define antiderivative of f[x] at x0 and x1"
Fx0=N[Integratef[x]/.{x->x0}];
Fx1=N[Integratef[x]/.{x->x1}];
"Integral as given by difference in antiderivatives are AI= "
AI=Fx1-Fx0

"Integral as given by NIntegrate is NI= "
NI=NIntegrate[f[x],{x,x0,x1}]
"Print both NA and NI ="
{AI, NI}

"Integration involving points near singularity often give rise to numerical error "