Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i need help with Forward/Backward/Central Difference!!! (MATLAB) PLEASE HELP, this is the 4th time i've posted this.. ----------------------------------------------------------------------------------------------------------- Problem 8.2 Given the function f (x)
i need help with Forward/Backward/Central Difference!!! (MATLAB)
PLEASE HELP, this is the 4th time i've posted this..
-----------------------------------------------------------------------------------------------------------
Problem 8.2 Given the function f (x) e 0.5x sin(x), let f (x) df be the exact derivative dx We can generate a discrete function as a set of points txi,yi, where yi f(xi). Write a MATLAB code to do the following: 1. Generate an array of xi values, starting at x 3 0.0, ending at x 4.0, and at intervals of h Ax- 1.0 2. Generate an array of yi values, where yi 0.5xi sin(xi). 3. Using first-order backwards-difference discretization techniques, approximate the first derivative, zi f (xi). Note: You cannot do this at every point. It is OK if you exclude a point. 4. Calculate the error of this approximation, Ei s- zi f (xi) Note: You should only calculate the error at points where you were able to calculate za 5. Display the average value 6. Repeat Steps 1-5 using h 0.1 7. Repeat Steps 1-5 using h 0.01 Problem 8.3 Repeat Problem 8.2, but use first-order forward-difference techniques to calculate the derivative. Problem 8.4 Repeat Problem 8.2, but use a central-difference technique to calculate the derivative. Note that you may need to exclude more than one point from your calculations Problem 8.2 Given the function f (x) e 0.5x sin(x), let f (x) df be the exact derivative dx We can generate a discrete function as a set of points txi,yi, where yi f(xi). Write a MATLAB code to do the following: 1. Generate an array of xi values, starting at x 3 0.0, ending at x 4.0, and at intervals of h Ax- 1.0 2. Generate an array of yi values, where yi 0.5xi sin(xi). 3. Using first-order backwards-difference discretization techniques, approximate the first derivative, zi f (xi). Note: You cannot do this at every point. It is OK if you exclude a point. 4. Calculate the error of this approximation, Ei s- zi f (xi) Note: You should only calculate the error at points where you were able to calculate za 5. Display the average value 6. Repeat Steps 1-5 using h 0.1 7. Repeat Steps 1-5 using h 0.01 Problem 8.3 Repeat Problem 8.2, but use first-order forward-difference techniques to calculate the derivative. Problem 8.4 Repeat Problem 8.2, but use a central-difference technique to calculate the derivative. Note that you may need to exclude more than one point from your calculationsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started