Write a program (fortran 90) that calls a subroutine to approximate the derivative of y=sin(x)+2x^2 using...
Free
60.1K
Verified Solution
Question
Advance Math
Write a program (fortran 90) that calls a subroutine toapproximate the derivative of y=sin(x)+2x^2 using a one-sideddifference approach fx = (fi-fi-1)/deltaX and a centered differenceapproach fx = (fi+1-fi-1)/deltaX. The value of the function f andits derivative fx should be evaluated at x=3.75. Your code shouldprint both values tot he screen when it runs.
Write a program (fortran 90) that calls a subroutine toapproximate the derivative of y=sin(x)+2x^2 using a one-sideddifference approach fx = (fi-fi-1)/deltaX and a centered differenceapproach fx = (fi+1-fi-1)/deltaX. The value of the function f andits derivative fx should be evaluated at x=3.75. Your code shouldprint both values tot he screen when it runs.
Answer & Explanation Solved by verified expert
! 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
Get Answers to Unlimited Questions
Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!
Membership Benefits:
- Unlimited Question Access with detailed Answers
- Zin AI - 3 Million Words
- 10 Dall-E 3 Images
- 20 Plot Generations
- Conversation with Dialogue Memory
- No Ads, Ever!
- Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Other questions asked by students
StudyZin's Question Purchase
1 Answer
$0.99
(Save $1 )
One time Pay
- No Ads
- Answer to 1 Question
- Get free Zin AI - 50 Thousand Words per Month
Unlimited
$4.99*
(Save $5 )
Billed Monthly
- No Ads
- Answers to Unlimited Questions
- Get free Zin AI - 3 Million Words per Month
*First month only
Free
$0
- Get this answer for free!
- Sign up now to unlock the answer instantly
You can see the logs in the Dashboard.