! Fortran Programe
PROGRAM Approx_Der
IMPLICIT NONE
REAL :: x,deltaX, y, One_side_Diff, Central_Diff
x=3.75
deltaX = 0.1
One_side_Diff = (y(x)-y(x-deltaX))/deltaX
Central_Diff = (y(x+deltaX)-y(x-deltaX))/deltaX
PRINT *, 'approximated derivative of y at point x = 3.75 using One
Sided Difference : ', One_side_Diff
PRINT *, 'approximated derivative of y at point x = 3.75 using
Central Difference: ', Central_Diff
END PROGRAM Approx_Der
FUNCTION y(x)
IMPLICIT NONE
REAL :: y
REAL, INTENT( IN ) :: x
y =SIN(x)+2*x**2
END FUNCTION y
! output
approximated derivative of y at point x = 3.75 using One Sided
Difference
: 13.9522362
approximated derivative of y at point x = 3.75 using Central
Difference: 28.3615875