80 likes | 221 Views
전자 전기 공학과 최선미. Example 9.2 a) Solve. using the forward Euler method using h=0.01 for o this part by hand calculation.
E N D
전자 전기 공학과 최선미 Example 9.2 a) Solve using the forward Euler method using h=0.01 for o this part by hand calculation. b) Repeat the same for h=0,01,0,001,0,0001 on a computer for Evaluate errors of the three calculations by comparison to the analytical solution given by The Exact Solution is
REAL T,Y,H,EXACT,Error PARAMETER(U=20) PRINT *,'ODE BY Forword EULER METHOD' DATA T,Y,H /0.0,5.0,0.01/ PRINT *,' T Y EXAXCT ERROR' 1 FORMAT(F10.5,F10.5,F10.5,F10.5) OPEN(U,FILE='ANSWER1.TXT') WRITE(U,*)'ODE BY Forword EULER METHOD' WRITE(U,*)' T Y EXACT ERROR' WRITE(U,*)'--------------------------------------------' DO 10 N=1,9 Y=Y+H*(7*EXP(-0.5*T)-20*Y) T=T+H EXACT=5*EXP(-20*T)+7/19.5*(EXP(-0.5*T)-EXP(-20*T)) Error=Y-EXACT PRINT 1,T,Y,EXACT,Error WRITE(U,1)T, Y,EXACT,Error 10 CONTINUE STOP END
ODE BY Forword EULER METHOD T Y EXACT ERROR -------------------------------------------- 0.01000 4.07000 4.15693 -0.08693 0.02000 3.32565 3.46637 -0.14072 0.03000 2.72982 2.90068 -0.17085 0.04000 2.25282 2.43721 -0.18440 0.05000 1.87087 2.05745 -0.18658 0.06000 1.56497 1.74622 -0.18125 0.07000 1.31990 1.49109 -0.17119 0.08000 1.12352 1.28191 -0.15839 0.09000 0.96607 1.11034 -0.14427 Forward Euler dt=0.01) Forward Euler dt=0.001) Forward Euler dt=0.0001) ODE BY Forword EULER METHOD T Y EXACT ERROR -------------------------------------------- 0.00100 4.90700 4.90792 -0.00092 0.00200 4.81586 4.81766 -0.00181 0.00300 4.72653 4.72919 -0.00266 0.00400 4.63899 4.64246 -0.00347 0.00500 4.55320 4.55745 -0.00425 0.00600 4.46912 4.47412 -0.00500 0.00700 4.38671 4.39243 -0.00572 0.00800 4.30595 4.31236 -0.00641 0.00900 4.22681 4.23387 -0.00707 0.01000 4.14924 4.15693 -0.00769 0.01100 4.07322 4.08152 -0.00830 0.01200 3.99872 4.00759 -0.00887 0.01300 3.92570 3.93512 -0.00942 0.01400 3.85414 3.86408 -0.00994 0.01500 3.78401 3.79445 -0.01044 0.01600 3.71528 3.72619 -0.01091 0.01700 3.64792 3.65928 -0.01136 0.01800 3.58190 3.59369 -0.01179 0.01900 3.51720 3.52940 -0.01220 0.02000 3.45379 3.46637 -0.01259 0.02100 3.39164 3.40460 -0.01295 0.02200 3.33074 3.34404 -0.01330 0.02300 3.27104 3.28467 -0.01363 0.02400 3.21254 3.22648 -0.01394 0.02500 3.15521 3.16944 -0.01423 ODE BY Forword EULER METHOD T Y EXACT ERROR -------------------------------------------- 0.00010 4.99070 4.99071 -0.00001 0.00020 4.98142 4.98144 -0.00002 0.00030 4.97216 4.97218 -0.00003 0.00040 4.96291 4.96295 -0.00004 0.00050 4.95368 4.95373 -0.00005 0.00060 4.94448 4.94453 -0.00006 0.00070 4.93529 4.93535 -0.00006 0.00080 4.92612 4.92619 -0.00007 0.00090 4.91696 4.91705 -0.00008 0.00100 4.90783 4.90792 -0.00009 0.00110 4.89871 4.89882 -0.00010 0.00120 4.88962 4.88973 -0.00011 0.00130 4.88054 4.88066 -0.00012 0.00140 4.87148 4.87160 -0.00013 0.00150 4.86243 4.86257 -0.00014 0.00160 4.85341 4.85355 -0.00014 0.00170 4.84440 4.84455 -0.00015 0.00180 4.83541 4.83557 -0.00016 0.00190 4.82644 4.82661 -0.00017 0.00200 4.81749 4.81766 -0.00018 0.00210 4.80855 4.80874 -0.00019 0.00220 4.79963 4.79983 -0.00020 0.00230 4.79073 4.79094 -0.00020 0.00240 4.78185 4.78206 -0.00021 0.00250 4.77299 4.77321 -0.00022
All Figure Error By using Fortran
Forward Euler dt=0.01) Forward Euler dt=0.001) By explicit Euler dt=0.0005) By explicit Euler dt=0.0001) By explicit Euler dt=0.0001) Forward Euler dt=0.0001) By using Mathematica
All Figure Error By using Mathematica