SLOPE

 

!Program name: SLOPE

!derivative (slope) of a function f(x) = x**n

real *16 xph, x, slope, dx, h

integer :: n

Print *, 'Derivative (slope) of the function x^n'

Print *, 'Give the value of x: '

Read *, x

Print *, 'Give the value of n: '

Read *, n

call epsilon(eps)

print *, 'eps: ', eps

Print *, 'sqrt(eps): ', sqrt(eps)

h=sqrt(eps)*x

Print *, 'h: ', h

xph=x+h

dx=xph-x

Print *, 'xph: ', xph

slope=(xph**n-x**n)/dx

Print *, 'slope=(xph**n-x**n)/dx'

write (*,*) 'slope: ', slope

stop

end

          

subroutine epsilon(eps)

real :: eps

!Epsilon - calculation of the precision

  eps=1.

  do

    eps=eps/2

    If (eps+1 .eq. 1.) exit

  End do

  return

  End subroutine epsilon

Comentários

Postagens mais visitadas deste blog

HYDROGEN-RADIAL

HYDROGEN-POTENTIAL

ONE_PART_QHO