next up previous contents
Nächste Seite: Aufgabe 6 Aufwärts: Lösungen Vorherige Seite: Aufgabe 4   Inhalt

Aufgabe 5

PROGRAM B_05
 IMPLICIT NONE
 REAL :: x0, xj, h, potenz, fac
 INTEGER :: i, j, n, m, iostat

 WRITE (*,'(A)') 'e^x wird durch Potenzreihe x^i/i! fuer i=0,n approximiert'
 WRITE (*,'(A)') 'Tabelle fuer xj = x0 + jh, j=1,m'
 WRITE (*,'(A)',ADVANCE='NO') 'geben Sie ein: n,m,x0,h: '
 DO
  READ (*,*,IOSTAT = iostat) n,m,x0,h
  IF (iostat == 0) EXIT
 END DO
 DO j = 1, m
  xj = x0 + j*h
  potenz = 1.0
  fac = 1.0
  DO i = 1, n
   fac = fac * i
   potenz = potenz + (xj**i)/fac
  ENDDO
  WRITE (*,*) j, potenz, EXP(xj), EXP(xj)-potenz
 ENDDO
END PROGRAM


Reinfried O. Peter 2001-09-07