baazuka

12-27-2011, 09:43 AM

i have been given this fortran assignment..but geting errors

please do the corrections for me..i have tried allot but failed...

i haave attached the question paper for your reference

heres the coode

!hello..this is a questions of newton iteration

!in this i need to generate the first 10 roots of the given equation F=theeta*(1/(1-(a*h/sigma)))

!as you can see that the equation is a function of theeta and i also been given an equation for theeta

! theeta=(1-1/(((n-0.5)**2)*(3.142**2)*(k**2)))*3.142*(n-0.5)

!annd now you can see that theeta is a function of n..that is the number of roots..for for the first root.i have n=1 and so on..10

!also i need to have the derivative of the function because it will be needed for the newton iteration

!DF=1/(cos(theeta**2)) as u c that it depends on theeta as well

! so u see that i need to have the roots(theeta) for each value of n..and all these values of rooots need to be stored in an array

!then having done all this..these values of roots will be needed to calculate the values of the fnal equation which i have ommited for now

! i have made three function subprograms for these equations that i have mentioned.and this subroutine..but i am getting errors and warnings

!please make corrections and add comments for identification so that i can know my mistakes

PROGRAM NEWTON

real theeta(10),f(100),df(100),eps

theeta(1)=0.1

EPS=0.00001

CALL NEWT(theeta,X,EPS)

STOP

END

!-------------------------------------------------!

SUBROUTINE NEWT(theeta,X,EPS)

real theeta(10),f(100),df(100)

integer L

do L=1,10

X=theeta(L)-(F(theeta(L))/DF(theeta(L)))

DO WHILE(ABS(X-theeta(L)) .GT. EPS)

theeta(L)=X

X=theeta(L)-(F(theeta(L))/DF(theeta(L)))

END DO

end do

RETURN

END

!--------------------------------

function theeta(n)

integer n(10)

real k,a,h,sigma,theeta

dimension theeta(10)

a=0.1

h=23.0

sigma=46.0

k=1-(a*h/sigma)

do i=1,10

theeta(i)=(1-1/(((i-0.5)**2)*(3.142**2)*(k**2)))*3.142*(i-0.5)

end do

return

end

!-------------------------------------------------------------------------

FUNCTION F(theeta)

real a,h,sigma,f(9),theeta(9)

integer m

a=0.1

h=23.0

sigma=46.0

do m=2,10

F(m)=theeta(m)*(1/(1-(a*h/sigma)))

enddo

WRITE(6,10)theeta,F

10 FORMAT(22X,F16.7,4X,F16.7)

RETURN

END

!-------------

FUNCTION DF(theeta)

real df(9),theeta(9)

integer j

do j=2,10

DF(j)=1/(cos(theeta(j)**2))

end do

RETURN

END

please do the corrections for me..i have tried allot but failed...

i haave attached the question paper for your reference

heres the coode

!hello..this is a questions of newton iteration

!in this i need to generate the first 10 roots of the given equation F=theeta*(1/(1-(a*h/sigma)))

!as you can see that the equation is a function of theeta and i also been given an equation for theeta

! theeta=(1-1/(((n-0.5)**2)*(3.142**2)*(k**2)))*3.142*(n-0.5)

!annd now you can see that theeta is a function of n..that is the number of roots..for for the first root.i have n=1 and so on..10

!also i need to have the derivative of the function because it will be needed for the newton iteration

!DF=1/(cos(theeta**2)) as u c that it depends on theeta as well

! so u see that i need to have the roots(theeta) for each value of n..and all these values of rooots need to be stored in an array

!then having done all this..these values of roots will be needed to calculate the values of the fnal equation which i have ommited for now

! i have made three function subprograms for these equations that i have mentioned.and this subroutine..but i am getting errors and warnings

!please make corrections and add comments for identification so that i can know my mistakes

PROGRAM NEWTON

real theeta(10),f(100),df(100),eps

theeta(1)=0.1

EPS=0.00001

CALL NEWT(theeta,X,EPS)

STOP

END

!-------------------------------------------------!

SUBROUTINE NEWT(theeta,X,EPS)

real theeta(10),f(100),df(100)

integer L

do L=1,10

X=theeta(L)-(F(theeta(L))/DF(theeta(L)))

DO WHILE(ABS(X-theeta(L)) .GT. EPS)

theeta(L)=X

X=theeta(L)-(F(theeta(L))/DF(theeta(L)))

END DO

end do

RETURN

END

!--------------------------------

function theeta(n)

integer n(10)

real k,a,h,sigma,theeta

dimension theeta(10)

a=0.1

h=23.0

sigma=46.0

k=1-(a*h/sigma)

do i=1,10

theeta(i)=(1-1/(((i-0.5)**2)*(3.142**2)*(k**2)))*3.142*(i-0.5)

end do

return

end

!-------------------------------------------------------------------------

FUNCTION F(theeta)

real a,h,sigma,f(9),theeta(9)

integer m

a=0.1

h=23.0

sigma=46.0

do m=2,10

F(m)=theeta(m)*(1/(1-(a*h/sigma)))

enddo

WRITE(6,10)theeta,F

10 FORMAT(22X,F16.7,4X,F16.7)

RETURN

END

!-------------

FUNCTION DF(theeta)

real df(9),theeta(9)

integer j

do j=2,10

DF(j)=1/(cos(theeta(j)**2))

end do

RETURN

END