Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended 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

More Books

Students also viewed these Programming questions

Question

-x/2 x/4 If A = -x/2 and A-1 =6 then x equals

Answered: 1 week ago