MIDPOINT_STABILITY

!Program name: MIDPOINT_STABILITY

!Integration of function: 1/1+25x^2

!Interval: -3 to 3

! I=0.60169208

 

integer :: k, a, m

real :: h, i, x, n, b

 

a=-3

b=3.

m=20

i=0.

 

h=(b-a)/m

print *, h

 

do k=1,m

   n=a+(k-0.5)*h

   x=n

   i=i+h*func(x)

   print *, k, n, func(x), i

end do

print *, i

stop

end

 

function func(x) result(f)

real :: f

f=1/(1+25*x**2)

end function func 

Comentários

Postagens mais visitadas deste blog

RECURSIVE

HYDROGEN-RADIAL

RUNGE-KUTTA