#include <fstream.h>
//----------------------------------------------------------------------------------------------------------------------------
// Truncation error demonstrated by numerrical approximation of Taylor series expansion
// by Ching-Han Chen
// 2006-03-07
//-------------------------------------------------------------------------------------------------------------------------
void main()
{
float x;
x=1.0+0.1;
cout<<x<<endl;
x=1.0+0.1+(0.1*0.1)/(2.0*1.0);
cout<<x<<endl;
x=1.0+0.1+(0.1*0.1)/(2.0*1.0)+(0.1*0.1*0.1)/(3.0*2.0*1.0);
cout<<x<<endl;
x=1.0+0.1+(0.1*0.1)/(2.0*1.0)+(0.1*0.1*0.1)/(3.0*2.0*1.0)+(0.1*0.1*0.1*0.1)/(4.0*3.0*2.0*1.0);
cout<<x<<endl;
int i,j;
float s1,s2;
x=1.1;
for(i=0;i<100;i++)
{
s1=s2=1;
for(j=i+2;j>=1;j--)
{
s1=0.1*s1;
s2=s2*j;
}
x=x+s1/s2;
}
cout<<x<<endl;
}