Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use python (with libraries) to solve this question. 4. Another approximation for integrals is the Trapezoid Rule: ix co) +2f(x1) + 2f (22) +...+2f(xn-2) +

image text in transcribed

Use python (with libraries) to solve this question.

4. Another approximation for integrals is the Trapezoid Rule: ix co) +2f(x1) + 2f (22) +...+2f(xn-2) + 2f (xn-1) + f(xn) 2 There is a built-in function trapz in the package scipy.integrate (refer to the Overview for importing and using this and the next command). (a) Compute the Trapezoid approximation using n= 100 subintervals. (b) Is the Trapezoid approximation equal to the average of the Left and Right Endpoint approximations? (c) Run the following code to illustrate the trapezoid method with 4 trapezoids (make sure you imported sympy as sp as stated in the Overview): x=sp.symbols('x') f=sp.exp(x/2)/x**3 sp.plot(f,(x,1,5)) xp={1,2,3,4,5) yp=[f.subs({x:i}) for i in xp] import matplotlib.pyplot as plt plt.plot(xp,yp) Notice that the trapezoid approximation is obtained by using lines to estimate f(1) on each subinterval. 4. Another approximation for integrals is the Trapezoid Rule: ix co) +2f(x1) + 2f (22) +...+2f(xn-2) + 2f (xn-1) + f(xn) 2 There is a built-in function trapz in the package scipy.integrate (refer to the Overview for importing and using this and the next command). (a) Compute the Trapezoid approximation using n= 100 subintervals. (b) Is the Trapezoid approximation equal to the average of the Left and Right Endpoint approximations? (c) Run the following code to illustrate the trapezoid method with 4 trapezoids (make sure you imported sympy as sp as stated in the Overview): x=sp.symbols('x') f=sp.exp(x/2)/x**3 sp.plot(f,(x,1,5)) xp={1,2,3,4,5) yp=[f.subs({x:i}) for i in xp] import matplotlib.pyplot as plt plt.plot(xp,yp) Notice that the trapezoid approximation is obtained by using lines to estimate f(1) on each subinterval

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions