Vous êtes sur la page 1sur 4

PROGRAM

#include<iostream>
#include<conio.h>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
float xn,dx,t,time,delta,x;
cout<<"enter the length of time"<<endl;
cin>>time;
for(delta=.1;delta<=1;delta+=.1)
{ t=0; xn=0;
cout<<"delta= "<<delta<<endl;
cout<<"time"<<setw(20)<<"anytcl soln"<<setw(20)<<"nm sol"<<endl;

while(t<=time)
{
x=1-exp(-t);
dx=1-xn;
xn=xn+dx*delta;
cout<<t<<setw(20)<<x<<setw(20)<<xn<<endl;
t=t+delta;

}
}
}

OUTPUT
enter the length of time
5
delta= 0.1
time anytcl soln nm sol
0 0 0.1
0.1 0.095163 0.19
0.2 0.181269 0.271
0.3 0.259182 0.3439
0.4 0.32968 0.40951
0.5 0.393469 0.468559
0.6 0.451188 0.521703
0.7 0.503415 0.569533
0.8 0.550671 0.61258
0.9 0.59343 0.651322
1 0.632121 0.686189
1.1 0.667129 0.71757
1.2 0.698806 0.745813
1.3 0.727468 0.771232
1.4 0.753403 0.794109
1.5 0.77687 0.814698
1.6 0.798104 0.833228
1.7 0.817317 0.849905
1.8 0.834701 0.864915
1.9 0.850431 0.878423
2 0.864665 0.890581
2.1 0.877544 0.901523
2.2 0.889197 0.911371
2.3 0.899741 0.920234
2.4 0.909282 0.92821
2.5 0.917915 0.935389
2.6 0.925726 0.94185
2.7 0.932794 0.947665
2.8 0.93919 0.952899
2.9 0.944977 0.957609
3 0.950213 0.961848
3.1 0.954951 0.965663
3.2 0.959238 0.969097
3.3 0.963117 0.972187
3.4 0.966627 0.974968
3.5 0.969803 0.977472
3.6 0.972676 0.979724
3.7 0.975276 0.981752
3.8 0.977629 0.983577
3.9 0.979758 0.985219
4 0.981684 0.986697
4.1 0.983427 0.988028
4.2 0.985004 0.989225
4.3 0.986431 0.990302
4.4 0.987723 0.991272
4.5 0.988891 0.992145
4.6 0.989948 0.99293
4.7 0.990905 0.993637
4.8 0.99177 0.994274
4.9 0.992553 0.994846
5 0.993262 0.995362
delta= 0.2
time anytcl soln nm sol
0 0 0.2
0.2 0.181269 0.36
0.4 0.32968 0.488
0.6 0.451188 0.5904
0.8 0.550671 0.67232
1 0.632121 0.737856
1.2 0.698806 0.790285
1.4 0.753403 0.832228
1.6 0.798104 0.865782
1.8 0.834701 0.892626
2 0.864665 0.914101
2.2 0.889197 0.93128
2.4 0.909282 0.945024
2.6 0.925726 0.95602
2.8 0.93919 0.964816
3 0.950213 0.971852
3.2 0.959238 0.977482
3.4 0.966627 0.981986
3.6 0.972676 0.985588
3.8 0.977629 0.988471
4 0.981684 0.990777
4.2 0.985004 0.992621
4.4 0.987723 0.994097
4.6 0.989948 0.995278
4.8 0.99177 0.996222
5 0.993262 0.996978
delta= 0.3
time anytcl soln nm sol
0 0 0.3
0.3 0.259182 0.51
0.6 0.451188 0.657
0.9 0.59343 0.7599
1.2 0.698806 0.83193
1.5 0.77687 0.882351
1.8 0.834701 0.917646
2.1 0.877544 0.942352
2.4 0.909282 0.959646
2.7 0.932794 0.971753
3 0.950213 0.980227
3.3 0.963117 0.986159
3.6 0.972676 0.990311
3.9 0.979758 0.993218
4.2 0.985004 0.995252
4.5 0.988891 0.996677
4.8 0.99177 0.997674
delta= 0.4
time anytcl soln nm sol
0 0 0.4
0.4 0.32968 0.64
0.8 0.550671 0.784
1.2 0.698806 0.8704
1.6 0.798104 0.92224
2 0.864665 0.953344
2.4 0.909282 0.972006
2.8 0.93919 0.983204
3.2 0.959238 0.989922
3.6 0.972676 0.993953
4 0.981684 0.996372
4.4 0.987723 0.997823
4.8 0.99177 0.998694
delta= 0.5
time anytcl soln nm sol
0 0 0.5
0.5 0.393469 0.75
1 0.632121 0.875
1.5 0.77687 0.9375
2 0.864665 0.96875
2.5 0.917915 0.984375
3 0.950213 0.992188
3.5 0.969803 0.996094
4 0.981684 0.998047
4.5 0.988891 0.999023
5 0.993262 0.999512

Vous aimerez peut-être aussi