# (Solved) : Numerical Differentiation Numerical Integration General Use Traprule Function Developed Cl Q41396297 . . .

using matlab Numerical Differentiation and Numerical Integration – General Use the trap.rule function we developed in class which used the built-in trapz function for numerical integration to solve the following problems 1. Moore 13.13 – Consider the equation below: y=12r – 5×2 +3 (a) Define an vector from -5 to 5 with 100 points and use to determine the derivative of y below using a reasonable step size. (b) Compare the numerical derivative to the analytical derivative using the error: numerical – true crror true (c) How does the error change with step size h? Did you run into any issues with e? Plot your results. 2. The numerical differentiation function we developed in class was based on the forward difference. A more accurate estimate uses the central difference and is given by: of f(x+h)-f(x-) 2h (a) Write a function called deriv.central which takes arguments fon (function to differen- tiate). x where to evaluate the derivate), and h (step size). (b) Test your new derivative function to compute the derivative of the following functions at I sin (1), sinº (z?), and sin (zº) Cos’ (‘) 3. Moore 13.17. Consider the following equation: y = 52 – 2x +3 (a) Use trap.rule to integrate this function from 1 to 1. (b) Use trapz to integrate this function from-1 to 1. (c) Compare the numerical integral to the analytical integral using the error: crror numerical-rue x 100% tre (d) How does the error change with step size h? Did you run into any issues with e? Plot your results Show transcribed image text Numerical Differentiation and Numerical Integration – General Use the trap.rule function we developed in class which used the built-in trapz function for numerical integration to solve the following problems 1. Moore 13.13 – Consider the equation below: y=12r – 5×2 +3 (a) Define an vector from -5 to 5 with 100 points and use to determine the derivative of y below using a reasonable step size. (b) Compare the numerical derivative to the analytical derivative using the error: numerical – true crror true (c) How does the error change with step size h? Did you run into any issues with e? Plot your results. 2. The numerical differentiation function we developed in class was based on the forward difference. A more accurate estimate uses the central difference and is given by: of f(x+h)-f(x-) 2h (a) Write a function called deriv.central which takes arguments fon (function to differen- tiate). x where to evaluate the derivate), and h (step size). (b) Test your new derivative function to compute the derivative of the following functions at I sin (1), sinº (z?), and sin (zº) Cos’ (‘) 3. Moore 13.17. Consider the following equation: y = 52 – 2x +3 (a) Use trap.rule to integrate this function from 1 to 1. (b) Use trapz to integrate this function from-1 to 1. (c) Compare the numerical integral to the analytical integral using the error: crror numerical-rue x 100% tre (d) How does the error change with step size h? Did you run into any issues with e? Plot your results