Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python Integrate a function by the trapezoidal rule A further improvement of the approximate integration method from the last question is to divide the area

pythonimage text in transcribed

Integrate a function by the trapezoidal rule A further improvement of the approximate integration method from the last question is to divide the area under the f(x) curve into n equally-spaced trapezoids. 4 points Based on this idea, the following formula can be derived for approximating the integral: where h is the width of the trapezoids, h = (b-a), and x = a + ih, i E 0, trapezoids. The figure above visualizes the idea of the trapezoidal rule. ,n, are the coordinates of the sides of the mplement 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.p, 10 ) should be 0.9979 (with some numerical error). The result of trapezint( abs,-1,1,10) should be 1.0 This assignment is based on Langtangen, Exercise 3.11a.) Integrate a function by the trapezoidal rule A further improvement of the approximate integration method from the last question is to divide the area under the f(x) curve into n equally-spaced trapezoids. 4 points Based on this idea, the following formula can be derived for approximating the integral: where h is the width of the trapezoids, h = (b-a), and x = a + ih, i E 0, trapezoids. The figure above visualizes the idea of the trapezoidal rule. ,n, are the coordinates of the sides of the mplement 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.p, 10 ) should be 0.9979 (with some numerical error). The result of trapezint( abs,-1,1,10) should be 1.0 This assignment is based on Langtangen, Exercise 3.11a.)

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions