Question: Python coding question Numerical integration Be sure to watch the Numerical integration video before starting this section Many functions in engineering and presies cannot be

Python coding question
Python coding question Numerical integration Be sure to watch the Numerical integration
video before starting this section Many functions in engineering and presies cannot
be integrated analytical to you can't wite down the result of the
integration using dementary functions. However, any function can be integrated to some
specified Decision using a computer. This is the topic that we shall
now explore The algorithm One of the most baske integration algorithmes e

Numerical integration Be sure to watch the Numerical integration video before starting this section Many functions in engineering and presies cannot be integrated analytical to you can't wite down the result of the integration using dementary functions. However, any function can be integrated to some specified Decision using a computer. This is the topic that we shall now explore The algorithm One of the most baske integration algorithmes e Traperiun Rule (also known as the Traperoldat Rull, where the interfirbo is approximated by evaluating fat a sequence of uniformly spaced in the the range connecting the points by straightines, and summing the weas of the trapeziums so formed For example, p.) ==-Kiu' + ir + the value of Shots can be calculated by summing the areas of the ten orange trapezums shown in the following tgure, where the spacing between sampes, Ar. 1808 The area of a traperiun with widm A, and edige heights of her and is given by Thus in general the numeric approximation to an integru Cum where a = to and bass gwen by Since al but the most and rightmost values of your appear twice in this summation, more efficient representations are possible, but the above will suffice for our purposes Note: If you're unter with the summation rotation used in the above equation you can think of it os rendez NOTIC) Ar+M+S) Aru)1(es) Ar+E + Recall the error hunction we preisformat eine I= IPHPerf(2)=/--+derim 30 The integral in the above alion may be evaluated numerically to give the value of for any real wile action relates the rezultate perfunctie w where we the value of the emer function entre per that the Integration interval should be divided into Notes: . This oftest is to users to catere erronction to you entweder function of Pythor's You will never need to more the mother to help you with the End on the formata Hit Search the documentation et For example Teat 1. 1.535 retragener Para - 0.1 Correct anstrerer, - 8. 113461 - 1-5 pricorrect war." tror att True intretineri - 1.222701 X2 30 25 20 f(x) 15 10 5 2 The area of a trapezium with width Ar and edge heights of hrafe and hright is given by Atrapezium= Ar Thus in general the numerical approximation to an integral Lif(r)dr where a = 10 and b = y, is given by (*)drl=;)+{n+) Ar HA Since all but the leftmost and rightmost values of f(x) appear twice in this summation, more efficient representations are possible, but the above will suffice for our purposes. Note: If you're unfamiliar with the summation notation used in the above equation, you can think of it as (rcayde 316dS24 MG)Elled as the f(02 ()dx=()F() x; f(+() Ax+ + [?][?]erf(x)=x/e-tdt[?][?] Recall the error function we saw previously. It is formally defined as t=s x t=0 The integral in the above equation may be evaluated numerically to give the value of erf(r) for any real / Write a function trapezium_erf(x, num_traps) that uses the Trapezium Rule to evaluate the error function integral where we would like the value of the error function and num_traps is the number of trapeziums that the integration interval should be divided into. Notes: The point of this question is to use numerical integration to calculate the error function yourself, so you are not allowed to use an error function from any of Python's libraries. You will, however, need to import numpy or the math module to help you with the square root, , and e in the formula. Hint: Search the documentation for sart, pi, and exp. For example: For example: Test Result 0.835 Correct! x = 1.0 area = trapezium_erf(x, 3) print(f"{area:.3f}") x = 0.1 ans = trapezium_erf(x, 9999) if abs(ans - 0.11246)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!