Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This code was not right. CODE IN PYTHON PLEASE # Import math for mathematic function import math # Function trapezint() used to find the integration

image text in transcribed

image text in transcribed

This code was not right. CODE IN PYTHON PLEASE

image text in transcribed
image text in transcribed
# Import math for mathematic function import math # Function trapezint() used to find the integration # of a function. A function f, intial Limit a, end # Limit b and n is number of subintervals def trapezint(f, a, b, n): # If a is greater than b if a > b: # Swap value of a & b a, b = b, a # Find the width of trapezoid h = (b - a) / float(n) # Find intial integral intgr = 0.5 * h * (f(a) + f(b)) # Loop to compute next values in interval for i in range(1, int(n)): # Compute next valeu & add with previous integration intgr = intgr + h * f(a + i * h) # Return the inetgration return intgr # Call function trapezint(math.sin, 0, 0.5*math.pi, 10) print("{:.4f}".Format(trapezint(math.sin, 0, 0.5*math.pi, 10)) # Call function trapezint(abs, -1, 1, 10) print("{:.1f}".format(trapezint(abs, -1, 1, 10))) = CheggBooks Study Writing Flashcards Math Solver Internships Abock Come Vi plore Q Buftsueams Webastian Turnitin I kunt me Error Facebook I My Housing V a b Based on this idea, the following formula can be derived for approximating the integrali Vars ()+1(20.) where hi the width of the traceroldohan hidan AVARA Eay ahead in class with practice exams Type here to search Chegy Judy 16 Based on this idea, the Tollowing formuta can be denied for approximating the integral de la = 43.2)+12), ho where he is the width of the trapezoids. h =(-a), and r;=a+ih i e e, trapezoids. The figure above visualizes the idea of the trapezoidal rule. n, are the coordinates of the sides of the Implement this formula in a Python function trapezint f.a, b, 1. You may need to check and see if b > a, otherwise you may neec to swap the variables. For instance, the result of trapezint math.sin. 0.0.5 aath pl.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.11.) Show transcribed image text Expert Answer o

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

More Books

Students also viewed these Databases questions

Question

=+Are there shop stewards?

Answered: 1 week ago