Question
1. Write a function MyTrapezoidQuad that takes as inputs a function f and an array of values xs with spacing h between them. The
1. Write a function MyTrapezoidQuad that takes as inputs a function f and an array of values xs with spacing h between them. The function should return the approximated integral of f over the interval (zo...) using the trapezoid rule on the given points. Hint: Use the pseudocode in Listing 1 to write your function. Use your Matlab function to approximate the integral of: A= - [ e cos(x)dr = (e$ - 1) Jo using n=2,4,8, 16, 32, 64, 128, 256 subintervals (h= 20=). Re- port the results of your approximation in a table with columns: " n the number of subintervals T(h) - the approximated integral values using Trapezoid rule En the absolute error |A-T(h)| -the error ratio (where=1 Hint: Since Trapezoid rule is order 2 in h, your error should decrease by a factor of 4, (22), when you double n.
Step 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 StartedRecommended Textbook for
Calculus For Business, Economics And The Social And Life Sciences
Authors: Laurence Hoffmann, Gerald Bradley, David Sobecki, Michael Price
11th Brief Edition
978-0073532387, 007353238X
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App