Friends,(adsbygoogle = window.adsbygoogle || []).push({});

I have written a program in FOTRAN for solving a equation [f(t0,y0)= 1/2*(t-y) by EulerMethod

I'm in the learning stage of FOTRAN.

after executing my program and save the result in txt file

the result For example be

1.000000000000000 1.000000000000000

2.000000000000000 1.000000000000000

3.000000000000000 1.000000000000000

4.000000000000000 1.000000000000000

5.000000000000000 1.000000000000000

6.000000000000000 1.000000000000000

7.000000000000000 1.000000000000000

8.000000000000000 1.000000000000000

9.000000000000000 1.000000000000000

I don't know what the problem in this function; because the other function working perfectly

as f(t0,y0)= (t+y)

So please don't mind if my program has got any silly mistakes.

My code

program EulerMethod

implicit none

real(8)::a,b,h,y_0,t

print*,"Enter the interval a,b ,the value of the step-size h and the value of y_0"

read*,a,b,h,y_0

open(1, file="resultEuler.txt",status='new',position="rewind")

call euler(y_0,a,b,h)

close(1)

contains

subroutine euler(y_0,a,b,h)

implicit none

real(8), intent(inout)::a,h,b,y_0

real(8):: y,t

t=a

y=y_0

do while(t<=b)

y=y+h*f(y,t)

write(1,*)t, y

t=t+h

end do

end subroutine

function f(y,t)

implicit none

real(8)::f,y,t

f=1/2*(t-y)

end function

end program EulerMethod

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Please help me: a problem on my FOTRAN program

**Physics Forums | Science Articles, Homework Help, Discussion**