program calcul integral par choix entre simpson ou trapez
صفحة 1 من اصل 1
program calcul integral par choix entre simpson ou trapez
program calcul integral
implicit none
character choix
write(*,*)'si vous vouler simpson entrer 1 et si vous
& vouler de trapez entrer 2'
read(*,*)choix
write(*,*)'donner les bornes de l_integrale a et b'
read(*,*)a,b
if(choix=1) then
call trapez (a,b,h,somme,f,aire,hp)
endif
if (choix=2) then
simpson
endif
!-----------------blocs secondaires------------------------------------
SUBROUTINE trapez (a,b,h,somme,f,aire,hp)
implicit none
!------------------------partie declaration--------------------------------
integer:: i,n
real:: a,b,h,somme,f,aire,hp
parameter(n=1000)
!------------------------partie saisie-------------------------------------
write(*,*)'donner les bornes de l_integrale a et b'
read(*,*)a,b
!------------------------partie tgraitement--------------------------------
h=(b-a)/n
somme=0.0
do i=1,n-1
hp=a+i*h
somme=somme+f(hp)
enddo
aire=(h/2)*(f(a)+f(b))+(h*somme)
!------------------------partie affichage-----------------------------------
write(*,*)'l_integrale par méthode de trapez est',aire
end
!------------------------bloc fonctionnel-----------------------------------
function f(x) result(f1)
implicit none
real x,f1
f1=2*x
end
SUBROUTINE simpson (a,b,h,somme1,somme2,f,aire,hp)
implicit none
character choix
write(*,*)'si vous vouler simpson entrer 1 et si vous
& vouler de trapez entrer 2'
read(*,*)choix
write(*,*)'donner les bornes de l_integrale a et b'
read(*,*)a,b
if(choix=1) then
call trapez (a,b,h,somme,f,aire,hp)
endif
if (choix=2) then
simpson
endif
!-----------------blocs secondaires------------------------------------
SUBROUTINE trapez (a,b,h,somme,f,aire,hp)
implicit none
!------------------------partie declaration--------------------------------
integer:: i,n
real:: a,b,h,somme,f,aire,hp
parameter(n=1000)
!------------------------partie saisie-------------------------------------
write(*,*)'donner les bornes de l_integrale a et b'
read(*,*)a,b
!------------------------partie tgraitement--------------------------------
h=(b-a)/n
somme=0.0
do i=1,n-1
hp=a+i*h
somme=somme+f(hp)
enddo
aire=(h/2)*(f(a)+f(b))+(h*somme)
!------------------------partie affichage-----------------------------------
write(*,*)'l_integrale par méthode de trapez est',aire
end
!------------------------bloc fonctionnel-----------------------------------
function f(x) result(f1)
implicit none
real x,f1
f1=2*x
end
SUBROUTINE simpson (a,b,h,somme1,somme2,f,aire,hp)
مواضيع مماثلة
» un program qui permet de calculer integral par methode de simpson
» calcul intégral
» un program qui permet de calculer les integrales par la methode de trapez
» calcul intégral
» un program qui permet de calculer les integrales par la methode de trapez
صفحة 1 من اصل 1
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى