Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i-0 where h is the width of the trapezoids, h = (b-a), and zi = a + ih, i 0, . . . , n,

image text in transcribed

i-0 where h is the width of the trapezoids, h = (b-a), and zi = a + ih, i 0, . . . , n, are the coordinates of the sides of the trapezoids. The figure above visualizes the idea of the trapezoidal rule Implement this formula in a Python function trapezint( f,a,b,n) . You may need to check and see if b > a, otherwise you may need to swap the variables. For instance, the result of trapez int ( math. sin,0,0.5*math. pi, 10 ) should be 0.9979 (with some numerical error). The result of trapezint( abs,-1,1,10 should be 1.e This assignment is based on Langtangen, Exercise 3.11a.) 1 def trapezint(f,a,b,n): 2h-(b-a) Answer* 4fori in range (n): 5 6 7 8 9 xi-a+(i*h) if b>a: t+-0.5*h*(f(xi)+f (xi+h)) return t if b

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

Step: 3

blur-text-image

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

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago