In: Advanced Math
Write a program (fortran 90) that calls a subroutine to approximate the derivative of y=sin(x)+2x^2 using a one-sided difference approach fx = (fi-fi-1)/deltaX and a centered difference approach fx = (fi+1-fi-1)/deltaX. The value of the function f and its derivative fx should be evaluated at x=3.75. Your code should print both values tot he screen when it runs.
! 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