View Single Post
Sampath Emani
#1
Feb11-12, 01:04 PM
P: 2
Friends,
i have written a program in FOTRAN for solving a equation [f(x0,y0)= 2*(y**2)+5]
I'm in the learning stage of FOTRAN. So please don't mind if my program has got any silly mistakes.
Please help in executing the program.

program rungekutta


print *,' DIFFERENTIAL EQUATION WITH 1 VARIABLE OF ORDER 1'

print*,"enter the value of x0"
read*,x

print*,"enter the value of y0"
read*,y

print*,"enter the value of step size"
read*,h

print*,"solution for the equation is",rk(x0,y0,h)


call runge(m,f1,n,h,x1)

end

function rk(y) result(r)

!Example: y'=(2*y^2+5)

real y,r

r = (2*(y**2)+5)
end function rk(y)

Subroutine runge(m,f1,n,h,x1)

integer f1,i,j,m,n,h

real x,w1,w2,w3,w4,x0,y;

do i=1, m
ni = (i - 1) * f1 - 1
do j=1, f1
x = x1 + h * (n + j)
w1 = h * f(x0,y0)
w2 = h * f(x0+h/2, y0+w1/2)
w3 = h * f(x0+h/2, y0+w2/2)
w4 = h * f(x0+h, y0+w3)
x = x0 + h

x = y + (w1 + w2 + w2 + w3 + w3 + w4) / 6

end do

end do

end
Phys.Org News Partner Science news on Phys.org
Scientists develop 'electronic nose' for rapid detection of C. diff infection
Why plants in the office make us more productive
Tesla Motors dealing as states play factory poker