wassim2015
Programmer
hi, i try to write a program for numerical derivative but my program does not run correctly (wrong results)
please help me,
------------------------------------------------------
program exemple
implicit none
INTEGER::i,j,Dgamma,Dbeta
integer,parameter::N=142
real,dimension(N)::beta,gamma
real,dimension(N)::H,dH1
OPEN(unit=10,file='MP')
open(unit=30,file='resultats')
open(unit=40,file='deriv')
WRITE(30,200)'beta','gamma','H','dH1'
DO i=1,N
READ(10,*)beta(i),gamma(i)
H(i)=0
H(i)=H(i)+(beta(i)*gamma(i))
WRITE(30,300)beta(i),gamma(i),H(i)
enddo
Dgamma=6D0
Dbeta=5D-2
DO i=2,N-1
dH1(i)=0
dH1(i)=(H(i+1)-H(i-1))/(2*Dgamma)
WRITE(40,400)beta(i),gamma(i),H(i),dH1(i)
enddo
CLOSE(10)
close(30)
close(40)
200 format(a10, a10, a10)
300 format(f10.2,f10.2,f10.2)
400 format(f10.2,f10.2,f10.2,f10.2)
end program exemple
------------------------------------
i search how to write a condition to calculate derivative of beta and gamma in the same time
mp file
---------------------------------
0.00 0.00
0.05 0.00
0.05 6.00
0.05 12.00
0.05 18.00
0.05 24.00
0.05 30.00
0.05 36.00
0.05 42.00
0.05 48.00
0.05 54.00
0.05 60.00
0.10 0.00
0.10 6.00
0.10 12.00
0.10 18.00
0.10 24.00
0.10 30.00
0.10 36.00
0.10 42.00
0.10 48.00
0.10 54.00
0.10 60.00
0.15 0.00
0.15 6.00
0.15 12.00
0.15 18.00
0.15 24.00
0.15 30.00
0.15 36.00
0.15 42.00
0.15 48.00
0.15 54.00
0.15 60.00
0.20 0.00
0.20 6.00
0.20 12.00
0.20 18.00
0.20 24.00
0.20 30.00
0.20 42.00
0.20 48.00
0.20 54.00
0.20 60.00
0.25 0.00
0.25 6.00
0.25 12.00
0.25 18.00
0.25 24.00
0.25 30.00
0.25 36.00
0.25 42.00
0.25 48.00
0.25 54.00
0.25 60.00
0.30 0.00
0.30 6.00
0.30 12.00
0.30 18.00
0.30 24.00
0.30 30.00
0.30 36.00
0.30 42.00
0.30 48.00
0.30 54.00
0.30 60.00
0.35 0.00
0.35 6.00
0.35 12.00
0.35 18.00
0.35 30.00
0.35 36.00
0.35 42.00
0.35 48.00
0.35 54.00
0.35 60.00
0.40 0.00
0.40 6.00
0.40 12.00
0.40 18.00
0.40 24.00
0.40 30.00
0.40 36.00
0.40 42.00
0.40 48.00
0.40 54.00
0.40 60.00
0.45 0.00
0.45 6.00
0.45 12.00
0.45 18.00
0.45 24.00
0.45 30.00
0.45 36.00
0.45 42.00
0.45 48.00
0.45 54.00
0.45 60.00
0.50 0.00
0.50 6.00
0.50 12.00
0.50 18.00
0.50 24.00
0.50 30.00
0.50 36.00
0.50 42.00
0.50 48.00
0.50 54.00
0.50 60.00
0.55 0.00
0.55 6.00
0.55 12.00
0.55 18.00
0.55 24.00
0.55 30.00
0.55 36.00
0.55 42.00
0.55 48.00
0.55 54.00
0.55 60.00
0.60 0.00
0.60 6.00
0.60 12.00
0.60 18.00
0.60 24.00
0.60 30.00
0.60 36.00
0.60 42.00
0.60 48.00
0.60 54.00
0.60 60.00
0.65 0.00
0.65 6.00
0.65 12.00
0.65 18.00
0.65 24.00
0.65 30.00
0.65 36.00
0.65 42.00
0.65 48.00
0.65 54.00
0.65 60.00
please help me,
------------------------------------------------------
program exemple
implicit none
INTEGER::i,j,Dgamma,Dbeta
integer,parameter::N=142
real,dimension(N)::beta,gamma
real,dimension(N)::H,dH1
OPEN(unit=10,file='MP')
open(unit=30,file='resultats')
open(unit=40,file='deriv')
WRITE(30,200)'beta','gamma','H','dH1'
DO i=1,N
READ(10,*)beta(i),gamma(i)
H(i)=0
H(i)=H(i)+(beta(i)*gamma(i))
WRITE(30,300)beta(i),gamma(i),H(i)
enddo
Dgamma=6D0
Dbeta=5D-2
DO i=2,N-1
dH1(i)=0
dH1(i)=(H(i+1)-H(i-1))/(2*Dgamma)
WRITE(40,400)beta(i),gamma(i),H(i),dH1(i)
enddo
CLOSE(10)
close(30)
close(40)
200 format(a10, a10, a10)
300 format(f10.2,f10.2,f10.2)
400 format(f10.2,f10.2,f10.2,f10.2)
end program exemple
------------------------------------
i search how to write a condition to calculate derivative of beta and gamma in the same time
mp file
---------------------------------
0.00 0.00
0.05 0.00
0.05 6.00
0.05 12.00
0.05 18.00
0.05 24.00
0.05 30.00
0.05 36.00
0.05 42.00
0.05 48.00
0.05 54.00
0.05 60.00
0.10 0.00
0.10 6.00
0.10 12.00
0.10 18.00
0.10 24.00
0.10 30.00
0.10 36.00
0.10 42.00
0.10 48.00
0.10 54.00
0.10 60.00
0.15 0.00
0.15 6.00
0.15 12.00
0.15 18.00
0.15 24.00
0.15 30.00
0.15 36.00
0.15 42.00
0.15 48.00
0.15 54.00
0.15 60.00
0.20 0.00
0.20 6.00
0.20 12.00
0.20 18.00
0.20 24.00
0.20 30.00
0.20 42.00
0.20 48.00
0.20 54.00
0.20 60.00
0.25 0.00
0.25 6.00
0.25 12.00
0.25 18.00
0.25 24.00
0.25 30.00
0.25 36.00
0.25 42.00
0.25 48.00
0.25 54.00
0.25 60.00
0.30 0.00
0.30 6.00
0.30 12.00
0.30 18.00
0.30 24.00
0.30 30.00
0.30 36.00
0.30 42.00
0.30 48.00
0.30 54.00
0.30 60.00
0.35 0.00
0.35 6.00
0.35 12.00
0.35 18.00
0.35 30.00
0.35 36.00
0.35 42.00
0.35 48.00
0.35 54.00
0.35 60.00
0.40 0.00
0.40 6.00
0.40 12.00
0.40 18.00
0.40 24.00
0.40 30.00
0.40 36.00
0.40 42.00
0.40 48.00
0.40 54.00
0.40 60.00
0.45 0.00
0.45 6.00
0.45 12.00
0.45 18.00
0.45 24.00
0.45 30.00
0.45 36.00
0.45 42.00
0.45 48.00
0.45 54.00
0.45 60.00
0.50 0.00
0.50 6.00
0.50 12.00
0.50 18.00
0.50 24.00
0.50 30.00
0.50 36.00
0.50 42.00
0.50 48.00
0.50 54.00
0.50 60.00
0.55 0.00
0.55 6.00
0.55 12.00
0.55 18.00
0.55 24.00
0.55 30.00
0.55 36.00
0.55 42.00
0.55 48.00
0.55 54.00
0.55 60.00
0.60 0.00
0.60 6.00
0.60 12.00
0.60 18.00
0.60 24.00
0.60 30.00
0.60 36.00
0.60 42.00
0.60 48.00
0.60 54.00
0.60 60.00
0.65 0.00
0.65 6.00
0.65 12.00
0.65 18.00
0.65 24.00
0.65 30.00
0.65 36.00
0.65 42.00
0.65 48.00
0.65 54.00
0.65 60.00