---------------------------------------------------------------------------------------------------------------------------------------
PROGRAM dIF
IMPLICIT NONE
REAL::x,fp,y1,y2,n,e,yp
!f(x)=(x**3)-2x+1
PRINT*
PRINT*," F(x) = x^3 - 2x + 1"
PRINT*
PRINT*," input n :"
READ*,n
PRINT*," , "
PRINT*," baraye F(x), noghte x ra vared konid:"
READ*,x
y2=((x+(1/n))**3)-2*(x+(1/n))+1
y1=((x-(1/n))**3)-2*(x-(1/n))+1
fp=(y2-y1)*n/2
PRINT*,"-------------------------------------------------"
PRINT*," moshtagh F(x) dar noghte",x," = ",fp
yp=3*(x**2)-2
e=(ABS(yp-fp)/yp)*100
PRINT*
PRINT*," Error =",e,"%"
PRINT*,"-------------------------------------------------"
PRINT*
END